TFS Build和Powershell Post-Build脚本

时间:2016-10-25 14:06:36

标签: powershell tfsbuild

我需要在不控制代理或任何丢弃位置的地方使用TFS构建过程。

我有一个后期构建脚本,显示为Here ...但我不知道如何编辑它以便它保留多个项目目录中的文件夹结构。

我知道我需要编辑文件副本本身,但我不确定如何在PowerShell中执行此操作...

let myRegex = "2 highlight"
for match in myRegex.matches(in: textField.text!, options: [], range: NSRange(location: 0, length: textField.text!.utf16.count)) as [NSTextCheckingResult] {
   attributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.yellow, range: match.range)
}
textField.attributedText = attributedString

最终目标是,不是将所有构建dll都放在一个目录中,而是将它们按照项目的文件夹结构化。

1 个答案:

答案 0 :(得分:0)

以下是一个实现所需功能的简单脚本,您可以根据文件夹结构和要求对其进行更新。

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
}