简体   繁体   中英

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.

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. You must either specify a RuntimeIdentifier or set SelfContained to false. [c:\test\Service\emp.csproj]

Why I am getting this error when I am specifying --runtime flag? I am able to publish using Visual Studio without any issues.

I am able to resolve the issue by adding <RuntimeIdentifier>linux-x64</RuntimeIdentifier> line in.csproj file:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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