<p>This question was kindly answered on StackOverflow. For anyone else looking for an answer:</p>

<pre><code>&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;
</code></pre>

<p>source:
<a href="https://stackoverflow.com/questions/46226120/how-to-pass-dynamic-properties-to-an-msbuild-task">https://stackoverflow.com/questions/46226120/how-to-pass-dynamic-properties-to-an-msbuild-task</a></p>

CC BY-SA 3.0
2017-09-15T14:02:55.227Z
2017-09-15T14:02:55.227Z
nichos
<p>Is it possible to pass a dynamic property group to an MSbuild task? So if I have the following properties and values:</p>

<pre><code>&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;
</code></pre>

<p>I could call MSBuild with a short property list:</p>

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

<p>But it would be the same as calling the task like this:</p>

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

<p>This is helpful if there's a large property list, and allows for only 1 place needs to be maintained.</p>

CC BY-SA 3.0
2017-09-13T08:55:45.540Z
How does it relate to a devops culture or tooling ? This sounds just a programming question...
Tensibai
CC BY-SA 3.0
2017-09-13T15:42:08.703Z
You don't feel this is a devops question? DevOps includes builds and automation. Specifically this question is related to tools and infrastructure as code. Looking around devops.stackexchange there are several questions relating to automation, builds, jenkins, etc. It does cross the line, but when I think of infrastructure as code, I think devops rather than a stackoverflow question.
nichos
CC BY-SA 3.0
2017-09-13T15:54:14.833Z
That's highly unclear from your question actually what the goal of this MSbuild is. Keep in mind that's your responsibility to avoid misconception when asking your tags are very vague and your question doesn't explain it is for infrastructure in any way
Tensibai
<automation><builds>
How to pass dynamic properties to an MSbuild task?
nichos
# How to pass dynamic properties to an MSbuild task?

(Asked by: username_0 on 2017-09-12)

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

   bar
   bar1
   bar2


I could call MSBuild with a short property list:

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


This is helpful if there's a large property list, and allows for only 1 place needs to be maintained.

**Tags:** automation, builds

> **Comments:**
> **username_1**: How does it relate to a devops culture or tooling ? This sounds just a programming question...  
> **username_0**: You don't feel this is a devops question? DevOps includes builds and automation. Specifically this question is related to tools and infrastructure as code. Looking around devops.stackexchange there are several questions relating to automation, builds, jenkins, etc. It does cross the line, but when I think of infrastructure as code, I think devops rather than a stackoverflow question.  
> **username_1**: That's highly unclear from your question actually what the goal of this MSbuild is. Keep in mind that's your responsibility to avoid misconception when asking your tags are very vague and your question doesn't explain it is for infrastructure in any way  

---

## 1 answers

### Answer by username_0 on 2017-09-15. Score: 0 | Accepted answer

This question was kindly answered on StackOverflow. For anyone else looking for an answer:

  
    Configuration=Debug;
    Platform=Any CPU;
        SomeOtherProperty=Foo
  

…

  
  
    $(BuildParameters);
    AnotherProperty=SomeValue
  

…



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


---

