tags:

views:

48

answers:

1

I am trying to pipe the output from a command to an Environment variable thus:

<Exec Command="for /f &quot;tokens=*&quot; %%i in ('svn info') do SET SVNINFO=%%i" />

and then use SVNINFO as a property in MSBuild.

While the command line counterpart:

for /f "tokens=*" %i in ('svn info') do SET SVNINFO=%i

works, the change in the value of the Environment variable when called from the Exec does not persist. (I am not able to obtain its value as a property.) Am I missing something here? Is there any better way to achieve this?

A: 

Maybe using the Exec Task Output is a better way:

<Project DefaultTargets="DefaultTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    <Target Name="Exe">
        <Exec Command="echo %PATH%">
            <Output TaskParameter="Outputs" PropertyName="ExecOutput" />
        </Exec>
    </Target>

    <Target Name="DefaultTarget" DependsOnTargets="Exe">
        <Message Text="Result from Exec is $(ExecOutput)" />
    </Target>

</Project>
Filburt