microsoft / microsoft/CsWinRT

Modify interop project to prevent winmd leaking from component project

Open
#756 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug tooling
Dominant language
C#
Stars
665
Forks
134
Avg merge
1d 3h
Merged PRs (30d)
32

Description

Describe the bug

Referencing a C#/WinRT interop project from a .NET 5 app raises a NETSDK1130 error. This is because the component winmd flows through from the C++/WinRT component project. The project referencing structure is .NET 5 app -> .NET 5 library interop project -> C++/WinRT component.

Look into whether C#/WinRT can fix this either by:

  1. Setting the implementation dll as an output in addition to the projection dll for the interop project. Then in the interop project, authors would set <PrivateAssets>all</PrivateAssets> on the project reference to the C++/WinRT component. Caveat is the component might have multiple binaries
  2. Modifying cswinrt NuGet targets. Cswinrt needs to influence reference resolution before project references kick in - binlog would show cross-reference target evaluation and the hook for that change. Referring to the CsWinRTRemoveWinMDReferences target here:
    https://github.com/microsoft/CsWinRT/blob/d361800d2cf6a46d2c7d276126a09bab1d8bc1c4/nuget/Microsoft.Windows.CsWinRT.targets#L47

To Reproduce

  1. Build the Net5ProjectionSample without generating a NuGet package
  2. Add ConsoleAppSample to the sample solution and add a project reference to the interop project, SimpleMathProjection

Here's an example - https://github.com/angelazhangmsft/ProjectionProject

Expected behavior

WinMD doesn't flow through but implementation dll does.

Additional context
Current workaround for consuming interop project by project reference is to add cswinrt NuGet reference in app

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

Reproduce the issue in src/Samples/Net5ProjectionSample by adding ConsoleAppSample and referencing SimpleMathProjection without generating a NuGet package. Start with the referenced Microsoft.Windows.CsWinRT.targets file, especially the CsWinRTRemoveWinMDReferences target, and inspect the project-reference evaluation shown in a binlog. Done means the WinMD no longer flows through the interop project while its implementation DLL does.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
build-system, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.