【问题标题】:Publishing for Release and specific OS in the same time doesn't work for .NET Core 3.1同时发布版本和特定操作系统不适用于 .NET Core 3.1
【发布时间】:2020-11-03 23:33:41
【问题描述】:

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

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

它给出了一个错误:

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

对于切换语法,键入“MSBuild -help”

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

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

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

总而言之,问题是我目前无法为指定操作系统发布发布。

【问题讨论】:

    标签: .net-core


    【解决方案1】:

    您的命令中有一个–r。这是一个破折号 (),后跟一个 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-x64linux-x64 与 Ubuntu 兼容,但也与许多其他发行版兼容。

    【讨论】:

    • 谢谢。命令“dotnet publish -c Release -r ubuntu-x64 --self-contained true”对我有用。
    猜你喜欢
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 2016-12-11
    • 1970-01-01
    • 2012-02-05
    • 2014-12-28
    • 1970-01-01
    相关资源
    最近更新 更多