user10025519
user10025519

Reputation: 83

Publishing for Release and specific OS in the same time doesn't work for .NET Core 3.1

I'm trying the following command for my .NET Core 3.1. Console application in the folder D:\core:

D:\core>dotnet publish -c Release –r ubuntu-x64 --self-contained true

And it gives an error:

MSBUILD : error MSB1008: Only one project can be specified. Switch: ubuntu-x64

For switch syntax, type "MSBuild -help"

When I use these two commands separately they work perfectly fine, but I need Release for Ubuntu; when I don't try to specify Release for Ubuntu it creates Publish folder in Debug folder:

D:\core>dotnet publish –r ubuntu-x64 --self-contained true

D:\core>dotnet publish -c Release

To summarize, the problem is that I can't currently publish for Release for a specified OS.

Upvotes: 0

Views: 575

Answers (1)

omajid
omajid

Reputation: 15203

You have a –r in your command. That's a em-dash () followed by an r. Have you tried using a normal dash/hyphen?

That works for me:

$ dotnet new console
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/omajid/temp/HelloWorld/HelloWorld.csproj...
  Determining projects to restore...
  Restored /home/omajid/temp/HelloWorld/HelloWorld.csproj (in 66 ms).

Restore succeeded.

$ dotnet publish -c Release -r ubuntu-x64 --self-contained true
Microsoft (R) Build Engine version 16.7.0-preview-20220-01+80e487bff for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /home/omajid/temp/HelloWorld/HelloWorld.csproj (in 16.86 sec).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  HelloWorld -> /home/omajid/temp/HelloWorld/bin/Release/net5.0/ubuntu-x64/HelloWorld.dll
  HelloWorld -> /home/omajid/temp/HelloWorld/bin/Release/net5.0/ubuntu-x64/publish/

Aside: you should use the linux-x64 runtime id rather than ubuntu-x64. linux-x64 is compatible with Ubuntu, but also many other distributions too.

Upvotes: 2

Related Questions