简体   繁体   中英

Add BuildNumber in GitTemplate.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)]"

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM