簡體   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