cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.85k stars 724 forks source link

`DotNetPublishSettings` is missing a way to set the `--os` option #4107

Closed sfwester closed 1 year ago

sfwester commented 1 year ago

Prerequisites

Cake runner

Cake Frosting

Cake version

3.0.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

Using dotnet version:

$ dotnet --version
6.0.404

when I run

$ dotnet publish --help
Description:
  Publisher for the .NET Platform

Usage:
  dotnet publish [<PROJECT | SOLUTION>...] [options]

Arguments:
  <PROJECT | SOLUTION>  The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.

Options:
...
  --os <os>                            The target operating system.
...

I get an option to set the the target operating system.

However, DotNetPublishSettings.cs does not provide access to the option. (DotnetMSBuildSettings.cs does not either).

What is expected?

I should be able to set the target OS using the DotNetPublishSettings. e.g,

var publishSettings = new DotNetPublishSettings
{
    Os = "win"
};

Steps to Reproduce

var publishSettings = new DotNetPublishSettings
{
    Os = "win"
};

does not compile.

Output log

'DotNetPublishSettings' does not contain a definition for 'Os'
Kuldeep-kd commented 1 year ago

My question is, why is it relevant to add --os in the settings? And what are your expectations from this setting? If you need to use particular target os for the build, you might as well run build.ps1 or build.sh accordingly.

sfwester commented 1 year ago

Just to be sure we are are on the same page I am advocating adding the option to the DotNetPublishSettings class. The dotnet CLI already supports this option.

Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

We use this option to output a windows executable even though we build on a unix box so I don't think calling build.ps1 will help me in this case.

However, reading the docs quoted above, it looks like I can get away with using the Runtime option in DotNetPublishSettings. May still be worth adding Os to get feature parity with the CLI.

cake-build-bot commented 1 year ago

:tada: This issue has been resolved in version v3.1.0 :tada:

The release is available on:

Your GitReleaseManager bot :package::rocket: