我正在尝试自动化构建javascript捆绑软件的本地部署脚本,然后在TFS命令行工具的帮助下,将捆绑软件签入TFS存储库中。
现在我已经有了构建捆绑包的管道,但是我仍然需要最后一个Task,它将创建的文件放入TFS。重要的是要注意,TFS在另一个项目中。
是否有Taks可以签入TFS?如果没有,在没有使用自定义脚本的情况下该怎么办?
答案 0 :(得分:1)
我写了一些PowerShell脚本来从构建中进行检入:
$newCodeFolderPath = "$($env:Agent_BuildDirectory)\newCode"
$tempWorkspacePath = "$($env:Agent_BuildDirectory)\tempWorkspace"
New-Item -Path $newCodeFolderPath -ItemType directory
Copy-Item -Path "/your/fules/you/want/checkin" -Recurse -Destination $newCodeFolderPath
New-Item -Path $tempWorkspacePath -ItemType directory
cd $tempWorkspacePath
#For VS 2017 (in other versions the tf.exe location is different)
$tfExe = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"
& $tfExe workspace /collection:{TfsCollection} /new "TempWorkspace" /noprompt
& $tfExe workfold "{TFS proeject path (where you want to check in)}" $tempWorkspacePath
Copy-Item -Path "$($newCodeFolderPath)/*" -Recurse -Destination $tempWorkspacePath
& $tfExe add * /recursive /noignore
& $tfExe checkin /recursive /comment:"from build"
& $tfExe workspace /delete /collection:{TfsCollection} "Tempworkspace"
cd c:/
Remove-Item -Path $newCodeFolderPath -Force -Recurse
Remove-Item -Path $tempWorkspacePath -Force -Recurse