[英]error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier
I am running following command to publish .NET CORE 5.0 web api project using command line on windows 10 box.我正在运行以下命令发布 .NET CORE 5.0 web api 项目在 Z0F4137ED1802B5044526 上使用命令行
c:\test\Service>dotnet publish -c release Emp.sln --framework net5.0 /p:DebugType=None /p:DebugSymbols=false --nologo --self-contained --runtime linux-x64 -v m
But I am getting following error:但我收到以下错误:
C:\ProgramFiles\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(126,5): error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. C:\ProgramFiles\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(126,5): error NETSDK1031: It is not supported to build or publish a self-包含的应用程序未指定 RuntimeIdentifier。 You must either specify a RuntimeIdentifier or set SelfContained to false.
您必须指定 RuntimeIdentifier 或将 SelfContained 设置为 false。 [c:\test\Service\emp.csproj]
[c:\test\Service\emp.csproj]
Why I am getting this error when I am specifying --runtime flag?为什么我在指定 --runtime 标志时收到此错误? I am able to publish using Visual Studio without any issues.
我可以使用 Visual Studio 发布,没有任何问题。
I am able to resolve the issue by adding <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
line in.csproj file:我可以通过在 .csproj 文件中添加
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
行来解决此问题:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
This seems to have fixed the issue.这似乎解决了这个问题。 But I will wait for a better answer.
但我会等待更好的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.