.net core 同时发布发行版和特定操作系统不会';NET Core 3.1不适用

.net core 同时发布发行版和特定操作系统不会';NET Core 3.1不适用,.net-core,.net Core,我正在为我的.NETCore3.1尝试以下命令。文件夹D:\core中的控制台应用程序: D:\core>dotnetpublish-c发行版-r ubuntu-x64——自包含的true 它给出了一个错误: MSBUILD:错误MSB1008:只能指定一个项目。开关: ubuntu-x64 对于开关语法,键入“MSBuild-help” 当我分别使用这两个命令时,它们工作得非常好,但我需要Ubuntu版本;当我不尝试为Ubuntu指定版本时,它会在调试文件夹中创建发布文件夹: D:\core>

我正在为我的.NETCore3.1尝试以下命令。文件夹D:\core中的控制台应用程序:

D:\core>dotnetpublish-c发行版-r ubuntu-x64——自包含的true

它给出了一个错误:

MSBUILD:错误MSB1008:只能指定一个项目。开关: ubuntu-x64

对于开关语法,键入“MSBuild-help”

当我分别使用这两个命令时,它们工作得非常好,但我需要Ubuntu版本;当我不尝试为Ubuntu指定版本时,它会在调试文件夹中创建发布文件夹:

D:\core>dotnetpublish–r ubuntu-x64--自包含的true

D:\core>dotnet发布-c版本


总而言之,问题是我目前无法发布特定操作系统的发行版。

您的命令中有一个
-r
。这是一个em破折号(
),后跟一个
r
。您是否尝试过使用普通的破折号/连字符

这对我很有用:

$ 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/


旁白:您应该使用
linux-x64
运行时id,而不是
ubuntu-x64
linux-x64
与Ubuntu兼容,但也与许多其他发行版兼容。

您的命令中有一个
-r
。这是一个em破折号(
),后跟一个
r
。您是否尝试过使用普通的破折号/连字符

这对我很有用:

$ 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/

旁白:您应该使用
linux-x64
运行时id,而不是
ubuntu-x64
linux-x64
与Ubuntu兼容,但也与许多其他发行版兼容。

谢谢。命令“dotnet publish-c Release-r ubuntu-x64--self-contained true”对我很有用。谢谢。命令“dotnet publish-c Release-r ubuntu-x64--self-contained true”对我很有用。