繁体   English   中英

error NETSDK1031:不支持在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序

[英]error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier

我正在运行以下命令发布 .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

但我收到以下错误:

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。 您必须指定 RuntimeIdentifier 或将 SelfContained 设置为 false。 [c:\test\Service\emp.csproj]

为什么我在指定 --runtime 标志时收到此错误? 我可以使用 Visual Studio 发布,没有任何问题。

我可以通过在 .csproj 文件中添加<RuntimeIdentifier>linux-x64</RuntimeIdentifier>行来解决此问题:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>

这似乎解决了这个问题。 但我会等待更好的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM