How to pass dynamic properties to an MSbuild task? Is it possible to pass a dynamic property group to an MSbuild task? So if I have the following properties and values:

&lt;MyPropertyGroup&gt;
   &lt;Foo&gt;bar&lt;/Foo&gt;
   &lt;Foo1&gt;bar1&lt;/Foo1&gt;
   &lt;Foo2&gt;bar2&lt;/Foo2&gt;
&lt;/MyPropertyGroup&gt;


I could call MSBuild with a short property list:

&lt;MSBuild Projects="$(SolutionFile)" Targets="Build" Properties="MyPropertyGroup" /&gt;

But it would be the same as calling the task like this:

&lt;MSBuild Projects="$(SolutionFile)" Targets="Build" Properties="Foo=bar;Foo1=bar1;Foo2=bar2" /&gt;


This is helpful if there's a large property list, and allows for only 1 place needs to be maintained.
This question was kindly answered on StackOverflow. For anyone else looking for an answer:

&lt;PropertyGroup&gt;
  &lt;BuildParameters&gt;
    Configuration=Debug;
    Platform=Any CPU;
        SomeOtherProperty=Foo
  &lt;/BuildParameters&gt;
&lt;/PropertyGroup&gt;
…
&lt;PropertyGroup&gt;
  &lt;!-- this property can even be extended afterwards, e.g. when a condition is needed --&gt;
  &lt;BuildParameters Condition=" '$(ShallAppendThings)' == 'true' "&gt;
    $(BuildParameters);
    AnotherProperty=SomeValue
  &lt;/BuildParameters&gt;
&lt;/PropertyGroup&gt;
…

&lt;MSBuild Projects="$(SolutionFile)" Targets="Build" Properties="$(BuildProperties)" /&gt;


source:
https://stackoverflow.com/questions/46226120/how-to-pass-dynamic-properties-to-an-msbuild-task