ModernWpf: Build Error on .NET 5
After upgrading from .NET 5 preview 7 to .NET 5 RC 2 I’m getting this error on project build:
Microsoft.NET.Sdk.targets(934, 5): [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.
To reproduce:
Create WPF app using .NET 5, install newest version of ModernWpfUI (I’m getting error on older versions too), run build.
Thanks in advance!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (5 by maintainers)
Commits related to this issue
- fixes Isssue #187 — committed to workgroupengineering/ModernWpf by workgroupengineering 3 years ago
@rfloresarg just change targetframework to this:
net5.0-windows10.0.18362.0The project needs to target net5.0-windows10.0.18362.0 or higher, since this library calls WinRT APIs. You can find related documentation here. The app will still be able to run on older versions of Windows.
Can reproduce, this fixes everything for me. Thanks for the fix! It’s quite important for me to use the non-forked Nuget versions.
Thanks, @ShankarBUS @ghost1372 ! I haven’t used OS versions in target framework monikers before, so I misunderstood what it means. I’ll test this on an older OS when I can, but there should be no issues. Here’s a relevant doc for someone who might misunderstand it as I did: https://docs.microsoft.com/en-us/dotnet/standard/frameworks#os-version-in-tfms
I’m using proper target framework name and latest preview. It’s because of that Nuget package.
Isn’t it possible to swap from WinRT to WinSDK? With
net6.0-windows10.0.18362.0I run into@skel35,
It’s just the target SDK!
It will work older Windows versions!
Try it out yourself 🙃.
After targeting net5.0-windows10.0.18362.0 as you’ve said earlier throw another error:
Based on this issue stated that
and after adding the references, there are some conflict like.
Edit:
It’s working, I just explicitly referenced Windows.UI.Color (as for my cases)