简体   繁体   English

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

[英]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.

相关问题 “不支持”在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序 - It is “not supported” to build or publish a self-contained application without specifying a RuntimeIdentifier 在 Windows 中发布便携式和独立的 .NET 应用程序 7 - Publish Portable and Self-Contained .NET Application in Windows 7 尝试发布自包含时出现 VS Studio 2019 错误 - VS Studio 2019 error when trying to publish self-contained .NET Core 自包含发布引用 - 如何删除未使用的? - .NET Core self-contained publish references - how to remove unused? dotnet publish --Linux 容器上的自包含选项 - dotnet publish --self-contained option on Linux container 是否可以将MsTest项目构建为独立的可执行文件? 怎么样? - Is it possible to build an MsTest project into a self-contained executable? How? 独立的普通纪念品 - Self-contained generic memento 引用的项目是一个非独立的可执行文件。 自包含的可执行文件不能引用非自包含的可执行文件 - The referenced project is a non self-contained executable. A non self-contained executable cannot be referenced by a self-contained executable 获取自带EXE的路径? - Get self-contained EXE's path? 您能否将资源发送到 .NET 5 中独立的单文件应用程序中的进程? - Can you send resources to a process in a self-contained, single file application in .NET 5?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM