Msbuild: A property set in a target before CallTarget isn't set at the called target

Created on 9 Sep 2016  路  2Comments  路  Source: dotnet/msbuild

Example:

<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Echo">
    <Message Importance="High"
             Text="Property Prop: $(Prop)" />
  </Target>

  <Target Name="Build">
    <PropertyGroup>
      <Prop>defined</Prop>
    </PropertyGroup>
    <CallTarget Targets="Echo" />
  </Target>
</Project>
d:\work>msbuild calltarget-property-setting.proj
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 9/8/2016 4:38:12 PM.
Project "d:\work\calltarget-property-setting.proj" on node 1 (default targets).
Echo:
  Property Prop:
Done Building Project "d:\work\calltarget-property-setting.proj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.02

That's surprising! It certainly _seems_ to have been set correctly (and a diag log indicates that too), but it's not available in the other target.

This was pointed out by @rohit21agrawal over IM.

backlog bug

All 2 comments

Was this page helpful?
0 / 5 - 0 ratings