How can I define properties dynamically and pass them to another target in msbuild?

I am trying to reuse a task in Ant in a way:

<Target Name="Release"> <Message Text="Env: $(Env)"/> </Target> <Target Name="ReleaseIntegration"> <CreateProperty Value="Development"> <Output TaskParameter="Value" PropertyName="Env" /> </CreateProperty> <Message Text="Env: $(Env)"/> <CallTarget Targets="Release"/> </Target> 

And I get:

 Env: Development Env: 

Any ideas on how to get this property into a Release target?

+4
source share
1 answer

There is an error with dynamic elements and properties:

The problem is related to the impossibility of accessing the elements and properties created within the target object until the actual completion of the goal is completed

(More info here ).

The workaround is simple: use one goal to create the property.

 <Target Name="Release"> <Message Text="Env: $(Env)"/> </Target> <Target Name="CreateProperty"> <CreateProperty Value="Development"> <Output TaskParameter="Value" PropertyName="Env" /> </CreateProperty> </Target> <Target Name="ReleaseIntegration" DependsOnTargets="CreateProperty"> <Message Text="Env: $(Env)"/> <CallTarget Targets="Release"/> </Target> 

You'll get:

 Env: Development Env: Development 
+6
source

All Articles