microsoft / microsoft/cppwinrt
Bug: CppWinRTCopyWinMDToOutputDirectory: Outputs mismatch when merged WinMD name differs from RootNamespace
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 281
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the build target that defines CppWinRTCopyWinMDToOutputDirectory and inspect its Inputs, Outputs, Copy destination, and FileWrites metadata. Align the declared output and FileWrites entries with the copied merged WinMD filename, then verify that repeated builds and downstream packaging no longer rebuild unnecessarily.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100