diff --git a/src/Cli/dotnet/Commands/Build/BuildCommandDefinition.cs b/src/Cli/dotnet/Commands/Build/BuildCommandDefinition.cs index 65bb225e8de4..2b204fc9eecc 100644 --- a/src/Cli/dotnet/Commands/Build/BuildCommandDefinition.cs +++ b/src/Cli/dotnet/Commands/Build/BuildCommandDefinition.cs @@ -42,7 +42,7 @@ internal sealed class BuildCommandDefinition : Command public readonly Option NoRestoreOption = CommonOptions.CreateNoRestoreOption(); - public readonly Option SelfContainedOption = CommonOptions.CreateSelfContainedOption(); + public readonly Option SelfContainedOption = CommonOptions.CreateSelfContainedOption(); public readonly Option NoSelfContainedOption = CommonOptions.CreateNoSelfContainedOption(); diff --git a/src/Cli/dotnet/Commands/Publish/PublishCommandDefinition.cs b/src/Cli/dotnet/Commands/Publish/PublishCommandDefinition.cs index 7fcf76edb936..b58dc9742f63 100644 --- a/src/Cli/dotnet/Commands/Publish/PublishCommandDefinition.cs +++ b/src/Cli/dotnet/Commands/Publish/PublishCommandDefinition.cs @@ -43,7 +43,7 @@ internal sealed class PublishCommandDefinition : Command public readonly Option NoRestoreOption = CommonOptions.CreateNoRestoreOption(); - public readonly Option SelfContainedOption = CommonOptions.CreateSelfContainedOption(); + public readonly Option SelfContainedOption = CommonOptions.CreateSelfContainedOption(); public readonly Option NoSelfContainedOption = CommonOptions.CreateNoSelfContainedOption(); diff --git a/src/Cli/dotnet/CommonOptions.cs b/src/Cli/dotnet/CommonOptions.cs index 3f54e0d0db2c..eb75daec6555 100644 --- a/src/Cli/dotnet/CommonOptions.cs +++ b/src/Cli/dotnet/CommonOptions.cs @@ -277,12 +277,13 @@ public static Option CreateDisableBuildServersOption() => Arity = ArgumentArity.Zero, }; - public static Option CreateSelfContainedOption() => - new Option("--self-contained", "--sc") + public static Option CreateSelfContainedOption() => + new Option("--self-contained", "--sc") { - Description = CliStrings.SelfContainedOptionDescription + Description = CliStrings.SelfContainedOptionDescription, + Arity = ArgumentArity.ZeroOrOne } - .ForwardIfEnabled([$"--property:SelfContained=true", "--property:_CommandLineDefinedSelfContained=true"]); + .ForwardAsMany(o => o.HasValue ? [$"--property:SelfContained={o.Value}", "--property:_CommandLineDefinedSelfContained=true"] : []); public static Option CreateNoSelfContainedOption() => new Option("--no-self-contained")