title: Dynamically create a property in msbuild to be used in a calltarget subtarget
body: <p>How do I create a property in msbuild so that I can use it in a CallTarget directive?</p>
  
  <p>Essentially I am trying to call a target 'subroutine' where the properties act as parameters.</p>
  
  <p>I tried making a toy csproj file which attempts to create a property, and then calls a target which echos it. It echos null.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;Target Name="Test"&gt;
      &lt;CreateProperty Value="AAA"&gt;
          &lt;Output TaskParameter="Value" PropertyName="Foo" /&gt;
      &lt;/CreateProperty&gt;
      &lt;CallTarget Targets="Test2" /&gt;
    &lt;/Target&gt;
    &lt;Target Name="Test2"&gt;
      &lt;Message Text="Target Test2: Foo=$(Foo)" /&gt;
    &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Running <code>msbuild TestProj.csproj /t:Test</code> outputs: </p>
  
  <pre><code>Test:
    Target Test: Foo=AAA
  Test2:
    Target Test2: Foo=
  </code></pre>
  
  <p>I guess the problem is I'm thinking about msbuild in an imperative fashion (which is apparently a common mistake), so I'm hoping someone can correct what appears to be a very fundamental misunderstanding in how msbuild works.</p>