Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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>

With this I am able to build solution using command line but when running the app through Visual Studio on Windows machine, I am getting error:

The debug executable ''c:\user\testuser\emp\bin\debug\net5.0\linux-x64\textdb.exe' specified in the 'emp' debug profile does not exists

I am able to solve the second issue (being able to build on Windows using Visual studio & being able to publish targeting Linux using command line) by add this to csproj file. Specifying multiple values in RuntimeIdentifiers

 <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RuntimeIdentifiers>win10-x64;linux-x64</RuntimeIdentifiers>
  </PropertyGroup>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!