microsoft / microsoft/cppwinrt

Bug: CppWinRTCopyWinMDToOutputDirectory: Outputs mismatch when merged WinMD name differs from RootNamespace

Open Beginner friendly
#1,554 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.