How do I keep values defined in one build target alive in other targert? If PropertyGroup is not the write MsBuild entity I should use here, what is? ReleaseDir is printed ok in "Package" target, but is empty in "DoPackage"
<Target Name="Package">
<PropertyGroup>
<ReleasesDir>c:\tmp</ReleasesDirBase>
</PropertyGroup>
<Message Text="$(ReleaseDir)"/>
<CallTarget Targets="DoPackage" Condition="!Exists('$(ReleaseDir)')"/>
</Target>
<!-- Do the acutal packaging -->
<Target Name="DoPackage">
<Message Text="Creating package in '$(ReleaseDir)'"/>
<Error Condition="'$(ReleaseDir)' == ''" Text="No ReleaseDir defined"/>
<MakeDir Directories="$(ReleaseDir)"/>
...
</Target>
There is a well known issue with properties and the CallTarget task. You should use DependsOnTargets instead.
<Target Name="Package">
<PropertyGroup>
<ReleasesDir>c:\tmp</ReleasesDir>
</PropertyGroup>
<Message Text="$(ReleasesDir)"/>
</Target>
<Target Name="PrePackage" DependsOnTargets="Package">
<CallTarget Targets="DoPackage" Condition="!Exists('$(ReleasesDir)')"/>
</Target>
<!-- Do the actual packaging -->
<Target Name="DoPackage" DependsOnTargets="Package">
<Message Text="Creating package in '$(ReleasesDir)'"/>
<Error Condition="'$(ReleasesDir)' == ''" Text="No ReleaseDir defined"/>
<MakeDir Directories="$(ReleasesDir)"/>
</Target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With