'How to pass env-var to MSBuild Task and make it effective for all sub-process? (concrete code)
I have a question about passing environment variables to MSBuild Task. See my code below:
a.proj
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="A1">
<Target Name="A0">
<Message Text="A0 start."/>
<MSBuild Projects="b.proj" Properties="myvar=000" />
<Message Text="A0 end."/>
</Target>
<Target Name="A1" DependsOnTargets="A0">
<Message Text="A1 start."/>
<MSBuild Projects="b.proj" Properties="myvar=111" />
<Message Text="A1 end."/>
</Target>
</Project>
b.proj
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="B">
<Message Text="B start."/>
<Exec command="c.bat" />
</Target>
</Project>
c.bat
echo [C]myvar=%myvar%
I hope that c.bat can see myvar's value passed from a.proj. My code above failed to do that.
Consider(Assume) a running <MSBuild> Task a process on the OS, then, I'd like to pre-set environment variable myvar for that process, so that its subprocesses(no matter how deep) can all see myvar's value.
How can I achieve that? Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

