Last week I got the following question from a colleague:
Here is an example where I set the Version constant to the BuildNumber:
Do you have an idea how to define a preprocessor variable in TFS 2010? Actually, these variables is used by Wix installer in the following project.There are 2 options I’m aware of to solve this problem:
Apparently it is not possible to add this as a classical Msbuild argument (it is possible to add a constant but not define its value). In the nant build script, this is defined like this :
<msbuild project="${src.dir}\${project.name}.sln">
…
<property name="SolutionDefineConstants" value="Version=${project.version};BinDir=${out.dir}\\" />
…
</msnbuild>
- Inside the build definition you can pass the parameter for msbuild like /p:DefineConstants="Version=1.2.1.0".
- If the value you want to provide is only available inside the build definition itself(e.g. the build number), you’ll have to open the Build Definition Template and add an extra assign activity to override the MSBuildArguments value.
Here is an example where I set the Version constant to the BuildNumber:
MSBuildArguments + " /p:DefineConstants=""Version=" + BuildDetail.BuildNumber + """"