diff --git a/src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs b/src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs index a2a07a396de1..e352534fe124 100644 --- a/src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs @@ -33,6 +33,10 @@ internal static class RunCommandParser public static readonly Option InteractiveOption = CommonOptions.InteractiveMsBuildForwardOption(); + public static readonly Option SelfContainedOption = CommonOptions.SelfContainedOption(); + + public static readonly Option NoSelfContainedOption = CommonOptions.NoSelfContainedOption(); + public static Command GetCommand() { var command = new Command("run", LocalizableStrings.AppFullName); @@ -47,6 +51,8 @@ public static Command GetCommand() command.AddOption(NoBuildOption); command.AddOption(InteractiveOption); command.AddOption(NoRestoreOption); + command.AddOption(SelfContainedOption); + command.AddOption(NoSelfContainedOption); command.AddOption(CommonOptions.VerbosityOption()); command.AddOption(CommonOptions.ArchitectureOption()); command.AddOption(CommonOptions.OperatingSystemOption()); diff --git a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs index 1e105053b32d..01e96b09f5b6 100644 --- a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs +++ b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs @@ -192,17 +192,19 @@ public void It_warns_on_rid_without_self_contained_options() .HaveStdOutContaining("NETSDK1179"); } - [Fact] - public void It_does_not_warn_on_rid_with_self_contained_options() + [WindowsOnlyTheory] + [InlineData("build")] + [InlineData("run")] + public void It_does_not_warn_on_rid_with_self_contained_options(string commandName) { - var testInstance = _testAssetsManager.CopyTestAsset("HelloWorld") + var testInstance = _testAssetsManager.CopyTestAsset("HelloWorld", identifier: commandName) .WithSource() .WithTargetFrameworkOrFrameworks("net6.0", false) .Restore(Log); - new DotnetBuildCommand(Log) + new DotnetCommand(Log) .WithWorkingDirectory(testInstance.Path) - .Execute("-r", "win-x64", "--self-contained") + .Execute(commandName, "-r", "win-x64", "--self-contained") .Should() .Pass() .And