CsWinRT nuget package should support enforcement of publicly available dependencies (winrt.runtime.dll)
Recently, an update to CsWinRT required an increment to the AssemblyVersion of winrt.runtime.dll. Winrt.runtime.dll is distributed in the Microsoft.Windows.SDK.Net.Ref framework package, which is in turn integrated into the .NET SDK, which is in turn ingested into Visual Studio updates. Because of this, published updates to winrt.runtime.dll can significantly lag published updates of dependent CsWinRT projection assemblies such as Microsoft.WinUI.dll. This can result in build breaks due to assembly resolution.
Proposal: create an opt-in mode that enforces public availability of dependencies like winrt.runtime.dll. A project property like CsWinRTAssertAvailability would validate whether the AssemblyVersion of winrt.runtime.dll referenced by the locally configured .NET SDK is >= the AssemblyVersion of the CsWinRT nuget package's lib\net5.0\winrt.runtime.dll. If the comparison failed, the build would fail (cswinrt.exe would be prevented from executing).
The trail of breadcrumbs to establish the comparison:
- given the version of .NET SDK being used:
dotnet --version 5.0.203
- locate the corresponding .NET SDK root:
dotnet --list-sdks |findstr /c:"5.0.100 " 5.0.203 [C:\Program Files\dotnet\sdk]
- locate that .NET SDK's Microsoft.NETCoreSdk.BundledVersions.props file: C:\Program Files\dotnet\sdk\5.0.203\Microsoft.NETCoreSdk.BundledVersions.props
- scan the props file for the Microsoft.Windows.SDK.NET.Ref framework reference version: TargetingPackVersion="10.0.19041.15"
- locate the winrt.runtime.dll for that version of the nuget package: D:\NUGET_PACKAGES\microsoft.windows.sdk.net.ref\10.0.19041.15\lib\WinRT.Runtime.dll
Seems like this is highlighting a limitation of .NET. Would be good to get @dsplaisted to see if there is something we should explore with .NET.
I'm not clear on the details of the problem. Do you have a repro?
I also thought we had enforcement for something similar, you will get a build error if you transitively depend on a newer version of Microsoft.Windows.SDK.NET.dll than your .NET SDK provides. Do we also need that check for winrt.runtime.dll?