Modify interop project to prevent winmd leaking from component project
Nobody has claimed this yet.
- 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:
- 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 - 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
CsWinRTRemoveWinMDReferencestarget here:
https://github.com/microsoft/CsWinRT/blob/d361800d2cf6a46d2c7d276126a09bab1d8bc1c4/nuget/Microsoft.Windows.CsWinRT.targets#L47
To Reproduce
- Build the Net5ProjectionSample without generating a NuGet package
- 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
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
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