The target framework of my project is set to net5.0-windows
.
A C# file contains a call to Microsoft.Win32.Registry.SetValue()
which gives me the following warning:
warning CA1416: 'Registry.SetValue(string, string?, object, RegistryValueKind)' is supported on 'windows'
Why do I get this warning if my project is set to net5.0-windows
?
Update: What is the proper way to handle error CA1416 for .NET core builds? as pointed out by pavel-anikhouski does not fix the problem.
My issue arises because I use a shared AssemblyInfo.cs file in my project and have <GenerateAssemblyInfo>
set to false
.
Adding the following line to AssemblyInfo.cs fixes the issue:
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]
The issue and workaround at GitHub: https://github.com/dotnet/sdk/issues/14502
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.