question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot publish self-contained worker project referencing another

See original GitHub issue

When trying to publish single file exe for worker projects get error runtime identifier is required, but it was!

This happens when referencing another core 3 console project.

$ dotnet publish -r linux-x64 -c Release --self-contained true
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 102.79 ms for C:\Dev\magnet-filewatcher\src\watcher\watcher.csproj.
  Restore completed in 102.79 ms for C:\Dev\magnet-filewatcher\src\worker\worker.csproj.
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(127,5): error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier.  Please either specify a RuntimeIdentifier or set SelfContained to false. [C:\Dev\magnet-filewatcher\src\watcher\watcher.csproj]

Steps to reproduce

  • Create new worker project with dotnet new worker
  • Add reference to your another core 3.0 console project with dotnet add reference
  • .NET Core SDK (3.0.100)
  • Windows 10 X64 es).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:35
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
darkguy2008commented, Nov 20, 2020

This is still happening in .NET 5. Any fixes? Specifying the RuntimeIdentifier in the .csproj file is NOT a solution because if you develop on Windows, then deploy for Linux, you’ll need to have two .csproj files for each OS, NOT GOOD.

12reactions
gimmicommented, Mar 18, 2020

I had the same problem with NetCore 3.1

This was not working:

dotnet publish .\src\MyProj\MyProj.csproj `
  --configuration Release `
  --runtime win-x64 `
  --self-contained true

Fixed by removing --self-contained true (that is the default anyway)

dotnet publish .\src\MyProj\MyProj.csproj `
  --configuration Release `
  --runtime win-x64
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot publish self-contained worker project referencing ...
This happens when referencing another core 3 console project. $ dotnet publish -r linux-x64 -c Release --self-contained true Microsoft (R) Build ...
Read more >
error NETSDK1031: It is not supported to build or publish a ...
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 ......
Read more >
Error generated when executable project references ...
NET SDK 5, an error is generated if an executable project references another executable project and the SelfContained values don't match.
Read more >
VS2017 15.3 Net Core 2.0 publish a self-contained app for ...
Using the same project, and publishing with dotnet publish the resulting app works fine. The different output folders contains different System.Threading.dll.
Read more >
Publishing A Single EXE File In .NET Core 3.0
NET Core installed so I know I need to build a self contained application for him. Easy, I just run the following command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found