net5.0-windows:警告 CA1416:'windows' 支持 'RegistryValueKind.DWord'
net5.0-windows: warning CA1416: 'RegistryValueKind.DWord' is supported on 'windows'
我项目的目标框架设置为net5.0-windows
。
一个 C# 文件包含对 Microsoft.Win32.Registry.SetValue()
的调用,这会给我以下警告:
warning CA1416: 'Registry.SetValue(string, string?, object, RegistryValueKind)' is supported on 'windows'
如果我的项目设置为 net5.0-windows
,为什么我会收到此警告?
更新:
What is the proper way to handle error CA1416 for .NET core builds? 正如 pavel-anikhouski 指出的那样并不能解决问题。
我的问题出现是因为我在我的项目中使用共享 AssemblyInfo.cs 文件并将 <GenerateAssemblyInfo>
设置为 false
。
将以下行添加到 AssemblyInfo.cs 可解决问题:
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]
GitHub 的问题和解决方法:https://github.com/dotnet/sdk/issues/14502
我项目的目标框架设置为net5.0-windows
。
一个 C# 文件包含对 Microsoft.Win32.Registry.SetValue()
的调用,这会给我以下警告:
warning CA1416: 'Registry.SetValue(string, string?, object, RegistryValueKind)' is supported on 'windows'
如果我的项目设置为 net5.0-windows
,为什么我会收到此警告?
更新: What is the proper way to handle error CA1416 for .NET core builds? 正如 pavel-anikhouski 指出的那样并不能解决问题。
我的问题出现是因为我在我的项目中使用共享 AssemblyInfo.cs 文件并将 <GenerateAssemblyInfo>
设置为 false
。
将以下行添加到 AssemblyInfo.cs 可解决问题:
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]
GitHub 的问题和解决方法:https://github.com/dotnet/sdk/issues/14502