Repository navigation
Description
Isolated static graph builds can pass or fail depending on MSBuild node scheduling when a referenced target is only available from a node-local target cache, not from the isolated graph engine cache.
This makes an incomplete ProjectReferenceTargets protocol scheduling-dependent: the same project graph can pass with /m:1, but fail with MSB4252 when parent and child run on different worker nodes under parallel scheduling.
Repro
Create these files in an empty directory.
root.proj:
<Project>
<ItemGroup>
<ProjectReference Include="Parent.proj" Targets="BuildParent" />
<ProjectReference Include="Filler*.proj" Targets="BuildParent" />
<ProjectReferenceTargets Include="Build" Targets="BuildParent" />
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(ProjectReference)" Targets="%(ProjectReference.Targets)" />
</Target>
</Project>Parent.proj:
<Project>
<ItemGroup>
<ProjectReference Include="Child.proj" />
<ProjectReferenceTargets Include="BuildParent" Targets="BuildChild" />
</ItemGroup>
<Target Name="BuildParent" DependsOnTargets="Build">
<Message Importance="high" Text="Parent BuildParent" />
</Target>
<Target Name="Build" DependsOnTargets="GetChildSpecial">
<Message Importance="high" Text="Parent Build" />
</Target>
<Target Name="GetChildSpecial">
<MSBuild Projects="@(ProjectReference)" Targets="Special" />
</Target>
</Project>Child.proj:
<Project>
<Target Name="BuildChild" DependsOnTargets="Special">
<Message Importance="high" Text="Child BuildChild" />
</Target>
<Target Name="Special">
<Message Importance="high" Text="Child Special" />
</Target>
</Project>Create filler projects Filler1.proj through Filler16.proj:
<Project>
<Target Name="Build">
<Exec Command="sleep 0.1" />
<Message Importance="high" Text="Filler" />
</Target>
<Target Name="BuildParent" DependsOnTargets="Build" />
</Project>Then run:
dotnet msbuild root.proj -graph -isolate -m:1 -nologo -v:minimal
dotnet msbuild root.proj -graph -isolate -m:8 -nologo -v:minimalExpected vs actual behavior
The isolated graph result should not depend on node scheduling. Ideally both commands should report the incomplete graph protocol, because Parent.proj calls Child.proj /t:Special but only declares BuildParent -> BuildChild. Alternatively, if dependency-built target results are intentionally reusable, that should work consistently across nodes.
Actual behavior: /m:1 succeeds because Child.proj /t:Special was already run as a dependency of BuildChild on the same node. /m:8 fails when Parent.proj and Child.proj run on different nodes:
Parent.proj(...) : error : MSB4252: Project ".../Parent.proj" with global properties
(IsGraphBuild=true)
is building project ".../Child.proj" with global properties
(IsGraphBuild=true)
with the (Special) target(s) but the build result for the built project is not in the engine cache. In isolated builds this could mean one of the following:
- the reference was called with a target which is not specified in the ProjectReferenceTargets item in project ".../Parent.proj"
- the reference was called with global properties that do not match the static graph inferred nodes
- the reference was not explicitly specified as a ProjectReference item in project ".../Parent.proj"
This came up while investigating dotnet/runtime static graph isolation: /m:1 masked a missing graph target, while parallel graph execution exposed it.
Note
This issue was drafted with assistance from GitHub Copilot.
Activity
Gate isolated cross-project cache satisfaction to graph-declared targ…
Gate isolated cross-project cache satisfaction to graph-declared targ…
Make isolated graph builds fail deterministically on undeclared cross…