Add BuildNumber in GitTemplate.12.xaml

2019-09-04 16:24发布

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)]"

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'.

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

标签: tfs
1条回答
看我几分像从前
2楼-- · 2019-09-04 16:54

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. 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)
    

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)

查看更多
登录 后发表回答