0

I have a targets file which uses the MSBuild task to compile bunch of .csproj files. This works as expected.

Is it possible to take the properties from the commandline?

<Target Name="MyBuild">
   <MSBuild Projects="@(Projects)" Properties="FROM COMMAND LINE"/>
</Target>

msbuild mybuild.proj /p:myProperty=true
paulio
  • 393
  • 7
  • 18

2 Answers2

0

You can do something like this:

<Target Name="MyBuild">
   <MSBuild Projects="@(Projects)" Properties="$(MyProperties)"/>
</Target>

and call MSBuild this way:

msbuild mybuild.proj /p:MyProperties="MyProperty=true;MyOtherProperty=false"
mkko
  • 332
  • 2
  • 7
-1

Environment variables can be used to set MSBuild properties. We use batch files to set env variables based on command line parameters, which then invokes MSBuild after setting env variables based on the command line parameters.

Glenn
  • 1,687
  • 15
  • 21