Compilation fails with NETSDK1130 error, WITHOUT directly referencing a winmd
See original GitHub issueHi,
I’m running into problems with NETSDK1130. Basically I can’t compile 84 of the 100 projects in my solution because of this error.
The message seems very clear:
Referencing a Windows Metadata component directly when targeting .NETCoreApp,Version=v5.0 is not supported. Use the C#/WinRT projection tool (https://aka.ms/cswinrt) or a provided projection for this target.
But that is exactly what I’m doing.
I don’t have direct references to winmd files.
So, I created a small test solution comprising of 1 class library and 1 console app. These are the project files:
ClassLibrary
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="6.1.1" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.0.1" />
</ItemGroup>
</Project>
Console app
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" />
</ItemGroup>
</Project>
Both the class library and the console app contain only the newly scaffolded files (so, without any code).
Now when I try building the solution I get this output:
1>------ Rebuild All started: Project: ClassLibrary, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: TestWinmd, Configuration: Debug Any CPU ------
2>C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(934,5):
error NETSDK1130: Referencing a Windows Metadata component directly when targeting .NETCoreApp,Version=v5.0 is not supported.
Use the C#/WinRT projection tool (https://aka.ms/cswinrt) or a provided projection for this target.
2>Done building project "TestWinmd.csproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
As you can see the ClassLibrary compiles fine and the console app fails.
My conclusion: there are no direct references to Windows Metadata components, therefore the NETSDK1130 error is misplaced.
As far as I can tell this problem started after upgrading nuget packages from .Net 5 RC1 to .Net 5 RC2. The copy of my dev-environment running the .Net 5 RC1 packages, compiles the entire solution just fine.
I’m using .Net 5.0 RC2, and Visual Studio Professional 2019 Version 16.8.0 Preview 5.0
I hope you can point out what I’m doing wrong here, because I have no clue on how to fix this, other that staying on .NET5 RC1.
Thanks, Richard
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top GitHub Comments
I’m having the same exact problem as OP. I regret ever attempting to port my project to .NET 5. I’m going to lose weeks too aren’t I. ($$$) I have to warn the others.
@dsplaisted to respond in email on the discussion we’re having on this.