Ho creato uno script PowerShell che si connette al server TFS con le assemblee TFS. Quindi eseguo il loop dei file sul server (in un percorso specifico) e lo scarico in modo ricorsivo.
# 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)))
}
}
fonte
2014-05-21 07:01:39
Ho dovuto aggiungere '-Server $ tfsCollection' dopo' $ items = Get-TfsChildItem $ AutoDeployDir -Recurse' per farlo funzionare, quindi ha funzionato come un campione. – Dan
Forse perché abbiamo solo una collezione in questa azienda è la ragione per cui non ne avevo bisogno?L'ho realizzato per TFS2013 –
Ah, sono del 2010 - a prescindere, grazie per la sceneggiatura, mi ha risparmiato un sacco di tempo. Volevo solo menzionarlo nel caso in cui qualcun altro avesse un problema simile. – Dan