Version
2.0.220131.2
Summary
Problem
The CppWinRTCopyWinMDToOutputDirectory target has mismatched Inputs/Outputs:
- Inputs:
@(_MdMergedOutput) — the merged WinMD (e.g. Contoso.Core.winmd)
- Outputs:
$(CppWinRTProjectWinMD) — resolves to $(OutDir)$(RootNamespace).winmd (e.g. Contoso.App.winmd)
- Copy DestinationFiles:
@(_MdMergedOutput->'$(OutDir)%(Filename)%(Extension)') — writes the correct file
When the merged WinMD filename differs from $(RootNamespace), the declared Output never matches the actual file written. MSBuild always considers the target out-of-date, causing cascading rebuilds in all downstream projects (.xbf copies, PRI regen, MSIX packaging, C# recompiles via CsWinRT).
This happens when a project's IDL files use a different root namespace than the project's RootNamespace property (e.g. IDL uses Contoso.Core but the project's RootNamespace is Contoso.App).
Fix
Change Outputs to a 1:1 transform matching the Copy task:
Outputs="@(_MdMergedOutput->'$(OutDir)%(Filename)%(Extension)')"
Also update FileWrites to match
Reproducible example
Expected behavior
No response
Actual behavior
No response
Additional comments
No response