如何将文件签入为Visual Studio Team Services中构建的一部分?
我想弄清楚如何关闭我们的构建过程中的循环,我们将版本号作为构建过程的一部分应用于AssemblyInfo。*文件。如何将文件签入为Visual Studio Team Services中构建的一部分?
我们正在从内部tfs迁移到视觉演播室团队服务。我们目前的许多内部部署版本都会更新版本号以使其与内部版本号保持同步,并在构建期间将这些文件还原到源代码控制中。
我已经成功使用script located on msdn作为示例来开始自定义构建过程。
我现在试图检查文件回到源的控制,但我收到的错误:
#[error]TF30063: You are not authorized to access https://subdomain.visualstudio.com/DefaultCollection.
#[error]Process completed with exit code 100 and had 1 error(s) written to the error stream.
我目前使用tf.exe试图做到这一点。首先在powershell脚本的顶部获取工具的路径;
# get the tf command line tool path
$tfexe = [System.IO.Path]::GetFullPath($env:VS140COMNTOOLS + "..\..\common7\ide\tf.exe")
if (-Not (Test-Path $tfexe))
{
Write-Error "Could not find tf.exe at '$tfexe'"
exit 1
}
else
{
Write-Host "Found tf.exe at '$tfexe'"
}
然后修改环签的文件,然后检查文件回。
# Apply the version to the assembly property files
$files = gci $Env:BUILD_SOURCESDIRECTORY -recurse -include "*Properties*","My Project" |
?{ $_.PSIsContainer } |
foreach { gci -Path $_.FullName -Recurse -include AssemblyInfo.* }
if($files)
{
Write-Host "Will apply $NewVersion to $($files.count) files."
foreach ($file in $files) {
#Write-Host "Attempting to checkout file '$file'"
& ($tfexe) vc checkout $file
$filecontent = Get-Content($file)
attrib $file -r
$filecontent -replace $VersionRegex, $NewVersion | Out-File $file
Write-Host "$file.FullName - version applied"
}
# Checkin pending changes together
##[error]TF30063: You are not authorized to access https://subdomain.visualstudio.com/DefaultCollection.
##[error]Process completed with exit code 100 and had 1 error(s) written to the error stream.
Write-Host "Attempting to checkin files"
$comment = "Applied $NewVersion to $($files.count) files. ***NO_CI***"
& ($tfexe) vc checkin /comment:"$comment" /noprompt
}
这是在做正确的方法?如果构建服务没有被授权访问,它会如何获取代码,编译它,然后在某处发布工件?
我不建议在程序集的版本,每次来检查,而不是我建议使用[assembly: AssemblyVersion("1.2.*")]
通配符支持(我删除[AssemblyFileVersion]
所以它会自动匹配。
检查中内部版本发生更改后的文件存在多种问题:
- 索引源和符号功能将使用与变更集关联的代码不匹配的源。将打破高级调试场景。
- 先进的测试功能,打破并可能暗示不必要的检查或变更
- 历史堆满了
**NO_CI**
变更 - 它打破了语义版本,因为这些类型的脚本打破API变化不因子,并可能导致滑稽的行为。
我创建了一个新的建设任务,这将允许你使用任务签入文件:
将它添加到TFS 2015年的您的VisualStudio在线使用tfx
控制台的实例:
tfx build tasks upload -taskpath path\to\project\root
我仍在努力寻找添加和删除的方式,但我遇到了客户端对象模型的问题,不知何故挂起除编辑之外的其他任何东西。
它看起来好像调用tf add
和tf delete
实际上将在构建脚本中与此签入任务结合使用。
欲了解更多信息:
我想现在,因为我没有一个强有力的论点反对不检查文件我会遵循不做检查的建议。 –
我宁愿放弃对'集信息的变化*'文件比检查它们到源控制。 –
@ JuanM.Elosegui为什么? –
同意。因为签入的源代码与用于构建的变更集记录的内容不匹配,不符合符号和索引源,打破高级调试方案,混乱的历史记录,并消除了大多数开发人员的“版本”概念,导致他们在检查重大更改,主要版本等时不会正确增加。我建议使用'1.2。*',并让构建服务器自动应用修订版,同时手动控制主版本和次版本。 – jessehouwing