本文介绍了在 GitTemplate.12.xaml 中添加 BuildNumber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在相关的 TfvcTemplate.12.xaml 中,解决方案是像这样添加内部版本号:

In the related TfvcTemplate.12.xaml the solution is to add the build number like so:

<mtbwa:MSBuild CommandLineArguments="[String.Format(&quot;/p:SkipInvalidConfigurations=true
/p:BuildNumber={1} {0}&quot;, MSBuildArguments, BuildDetail.BuildNumber)]"

在 Git 模板中,参数略有变化,但在以下错误中执行相同的结果

In the Git template the arguments have slightly changed, but doing the same results in the following error

Compiler error(s) encountered processing expression 
"String.Format("/p:SkipInvalidConfigurations=true /p:BuildNumber={1} {0}", 
AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty),  
BuildDetail.BuildNumber)".
'Microsoft.TeamFoundation.Build.Client.BuildDetail' is not accessible in 
this context because it is 'Friend'.

在此模板中公开 BuildNumber 的正确方法是什么?

What is the correct way to expose the BuildNumber in this template?

推荐答案

要完成这项工作,我必须经过两个步骤.

There's two steps I had to go through to make this work.

  1. https://social.msdn.microsoft.com/Forums/vstudio/en-US/49f11ed9-9fa8-4c20-952a-d39ee7e71051/can-no-longer-user-builddetaildroplocation-for-copydirectory-with-tfs-2013-using-build-process?forum=tfsbuild
  2. 在您在步骤 1 中修改的同一个模板中,单击运行 MSBuild"活动,查看属性并打开CommandLineArguments".我将 OctoPack 用于 Octopus Deploy,所以我的论点如下:

  1. https://social.msdn.microsoft.com/Forums/vstudio/en-US/49f11ed9-9fa8-4c20-952a-d39ee7e71051/can-no-longer-user-builddetaildroplocation-for-copydirectory-with-tfs-2013-using-build-process?forum=tfsbuild
  2. Within the same template you modified in step 1 click on the "Run MSBuild" activity, view properties and open "CommandLineArguments". I'm using OctoPack for Octopus Deploy so here's what my arguments look like:

String.Format("/p:SkipInvalidConfigurations=true /p:BuildNumber={1} {0} 
/p:OctoPackPackageVersion={1}", AdvancedBuildSettings.GetValue(Of
String)("MSBuildArguments", String.Empty), BuildDetail.BuildNumber)

如您所见,此处指定了 BuildNumber,因此您只需删除我添加的 Octopus 属性即可.最后在您的 msbuild 文件(例如 .csproj)中,您将使用像这样的内部版本号 $(BuildNumber)

As you can see, BuildNumber is specified there so you can just remove the Octopus property I added. Finally within your msbuild file (.csproj for example) you'd use build number like so $(BuildNumber)

这篇关于在 GitTemplate.12.xaml 中添加 BuildNumber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 05:09