Skip to content

Use non-boolean self-contained arguments for dotnet publish #4720

@peymanr34

Description

@peymanr34

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

6.0.0

Operating system

Windows

Operating system architecture

x64

CI Server

No response

What are you seeing?

According to the sources mentioned below and this comment we should be using --no-self-contained instead of --self-contained false to publish framework-dependent applications.

--self-contained false has no impact - the --self-contained option, while accepting a boolean, only ever sets the SelfContained MSbuild property to true. you want --no-self-contained to disable self-contained builds.

In the official dotnet publish docs, the --self-contained false argument has been mentioned only once (just in the examples) and it's usage seems discouraged.

See Also:

What is expected?

The --self-contained and --no-self-contained arguments should be used.

Steps to Reproduce

  • Run the following task:
var configuration = Argument("configuration", "Release");
var runtime = Argument("app-runtime", "win-x64");
var selfContained = Argument<bool>("app-self-contained", false);

Task("Publish")
    .Does(() =>
{
    DotNetPublish("./Source/Project.csproj", new DotNetPublishSettings
    {
        NoRestore = true,
        OutputDirectory = "./Setup/Files",
        Configuration = configuration,
        Runtime = runtime,
        SelfContained = selfContained,
    });
});

Output log

Executing task: Publish
Resolved tool to path C:/Program Files/dotnet/dotnet.exe
Executing: "C:/Program Files/dotnet/dotnet.exe" publish "./Source/Project.csproj" --output "F:/<omitted>/Setup/Files" --runtime win-x64 --configuration Release --no-restore --self-contained false 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions