मैं एक PowerShell स्क्रिप्ट TFS विधानसभाओं के साथ TFS सर्वर से कनेक्ट करता है कि बनाए गए पृष्ठ पर निष्पादित। मैं फिर सर्वर पर फ़ाइलों (एक विशिष्ट पथ में) के माध्यम से लूप और इसे रिकर्सिव डाउनलोड करें।
# The deploy directory for all the msi, zip etc.
$AutoDeployDir = "Your TFS Directory Server Path"
$deployDirectory = $($Env:TF_BUILD_DROPLOCATION + "\Deploy\" + $Env:TF_BUILD_BUILDNUMBER)
# Add TFS 2013 dlls so we can download some files
Add-Type -AssemblyName 'Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Add-Type -AssemblyName 'Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
$tfsCollectionUrl = 'http://YourServer:8080/tfs/YourCollection'
$tfsCollection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $tfsCollectionUrl
$tfsVersionControl = $tfsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
# Register PowerShell commands
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
# Get all directories and files in the AutoDeploy directory
$items = Get-TfsChildItem $AutoDeployDir -Recurse
# Download each item to a specific destination
foreach ($item in $items) {
# Serverpath of the item
Write-Host "TFS item to download:" $($item.ServerItem) -ForegroundColor Blue
$destinationPath = $item.ServerItem.Replace($AutoDeployDir, $deployDirectory)
Write-Host "Download to" $([IO.Path]::GetFullPath($destinationPath)) -ForegroundColor Blue
if ($item.ItemType -eq "Folder") {
New-Item $([IO.Path]::GetFullPath($destinationPath)) -ItemType Directory -Force
}
else {
# Download the file (not folder) to destination directory
$tfsVersionControl.DownloadFile($item.ServerItem, $([IO.Path]::GetFullPath($destinationPath)))
}
}
स्रोत
2014-05-21 07:01:39
मुझे यह चलाने के लिए '$ आइटम = Get-TfsChildItem $ AutoDeployDir -Recurse' के बाद '-सेवर $ tfsCollection' जोड़ना था, फिर यह एक चैंप की तरह काम करता था। – Dan
शायद क्योंकि हमारे पास इस कंपनी में केवल एक संग्रह है, यही वजह है कि मुझे इसकी आवश्यकता नहीं थी?मैंने इसे TFS2013 –
के लिए बनाया है आह मैं 2010 में हूं - भले ही, स्क्रिप्ट के लिए धन्यवाद, यह मुझे बहुत समय बचाता है। मैं सिर्फ यह उल्लेख करना चाहता था कि अगर किसी और को भी ऐसी ही समस्या हो। – Dan