dotnet run
(在Windows上)导致warning CA1416: This call site is reachable on all platforms. 'WellKnownSidType.WorldSid' is only supported on: 'windows'.
我的程序被设计成只能在windows上运行。
我试着把SupportedPlatform
加到MyApp.csproj
上,但没有运气。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="5.0.5" />
<PackageReference Include="System.DirectoryServices" Version="5.0.0" />
<SupportedPlatform Include="Windows"/>
</ItemGroup>
</Project>
我做错了什么?我怎样才能向dotnet run
显示这个项目是windows专用的?
2条答案
按热度按时间mspsb9vt1#
您可以使用
System.Runtime.Versioning.SupportedOSPlatformAttribute
标记每个特定于Windows的方法,例如:在AssemblyInfo(如果有)中用标记整个组件
或者编辑
.csproj
文件,使其指向Windows特定版本的dotnet,以使这些更改自动进行w3nuxt5m2#
1.已删除AssemblyInfo.cs文件。
1.从.csproj文件中删除了以下内容
< GenerateAssemblyInfo>假的</ GenerateAssemblyInfo>
1.添加到.csproj文件
</ Project>