MikeW
MikeW

Reputation: 1620

Pass a custom ms build property in tfs 2015 web build definition

I have an automated build set up in tfs2015 using a web build definition (i.e. not a xaml build definition) and I am looking to pass a custom property to the msbuild command.

I have tried setting a variable in the definition but this is not used in the build process.

the msbuild command argument that I need to pass is /p:myProperty="bob"

The build definition has variables:

build variables

yet when I build I get the msbuild command:

C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe "C:\Build\Agent\_work\5ad80936\FullSolution.sln" /nologo /m /nr:false /fl /flp:"logfile=C:\Build\Agent\_work\5ad80936\FullSolution.sln.log" /dl:CentralLogger,"C:\Build\Agent\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\Build\Agent\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"  /p:platform="any cpu" /p:configuration="release"

So the BuildConfiguration and BuildPlatform variables are used in the way I would like myProperty to be used, yet this variable is ignored.

I have tried prefixing my variable name with 'Build', but this made no difference.

Can anyone help?

Incidentally, if run the msbuild command locally and append the required argument the build does exactly what I want.

Upvotes: 1

Views: 927

Answers (1)

MikeW
MikeW

Reputation: 1620

I have found the answer, the variables are simply that, variables. To use those variables as msbuild command line arguments requires the setting of another part of the build definition:

On the build tab set the MSBuild Arguments parameter to use the variable that you have created:

enter image description here

The part in the $() is the variable name used in the TFS build definition, the portion before the = is the name of the property in your msbuild script. These do not necessarily need be the same

Upvotes: 2

Related Questions