5

I have a master.proj msbuild script which builds several projects using the MSBuild task.

Here is a typical example:

<Target Name="Log4PostSharp" DependsOnTargets="log4net">
  <MSBuild Projects="Log4PostSharp\Log4PostSharp.sln" Properties="Configuration=$(Configuration)" />
</Target>

But, my problem is that if more properties are given on the command line, they are not passed to the MSBuild task.

Is there a way to pass the MSBuild task all the properties given on the command line?

Thanks.

mark
  • 59,016
  • 79
  • 296
  • 580
  • I asked a similar [question](http://stackoverflow.com/questions/3260913/how-to-access-the-msbuild-command-line-parameters-from-within-the-project-file-b) -- never found a solution to this, which seems to be a serious deficiency in msbuild, IMO. – arathorn Apr 12 '12 at 22:32

1 Answers1

3

You have to explicitly pass your extra property as a semicolon-delimited list of property name/value pairs in Properties attribute. It's not pretty but it's the way to go :

<Target Name="Log4PostSharp" DependsOnTargets="log4net">
  <MSBuild Projects="Log4PostSharp\Log4PostSharp.sln" 
           Properties="Configuration=$(Configuration);
                       Platform=$(Platform);
                       OtherPropertyPassInCommandLine=$(PropertyValue)" />
</Target>
Martin Brown
  • 24,692
  • 14
  • 77
  • 122
Julien Hoarau
  • 48,964
  • 20
  • 128
  • 117
  • 1
    This is not a question of pretty. It is simply impossible. Master.proj is used to build many projects at once. It just cannot know which properties are relevant to which projects. – mark Jun 02 '10 at 08:12