views:

119

answers:

1

I am trying to reuse a task in an Ant 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 how to get this property into Release target?

+3  A: 

There is a bug with dynamic items and properties:

The issue has to do with not being able to access items and properties that are created within a target until the target execution actually completes

(More info here).

The workaround is simple : use one separate target 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 will get:

Env: Development
Env: Development
madgnome
Works, cheers. Msbuild is such a pile of sh!t. I wonder who tested it before release.
Grzenio