简体   繁体   中英

TFS Build and Powershell Post-Build Script

I need to get a TFS build process working where I dont control the agent, or any of the drop locations.

I have a post-build script which is shown Here ...but I dont know how to edit it to so that it preserves the folder structure across multiple project directories.

I know I need to edit the file copy itself, but I am unsure of how to go about doing this in powershell...

foreach ($file in $files) 
{
    #Do something here to create the correct path on the drop server
    Copy $file $Env:TF_BUILD_BINARIESDIRECTORY
}

The end goal is that instead of having all the build dlls in a single directory, I have them structured in folders per project.

Following is a simple script to achieve the feature you want, you can update it base on your folder structure and requirement.

Get-ChildItem -Path $Env:TF_BUILD_BUILDDIRECTORY -Filter *.*proj -Recurse | ForEach-Object {
$projectfolder = $_.BaseName
$currentpath = $_.Directory.ToString()
$copypath = $currentpath + '\obj'
$targetpath = $Env:TF_BUILD_BINARIESDIRECTORY + '\' + $projectfolder
Write-Host "Copying files from $copypath to $targetpath"
Copy-Item $copypath $targetpath -Recurse
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM