From f6b804f97f0c2fbd4b7cd1c10231a8470656eb78 Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Wed, 29 Sep 2021 15:29:30 -0700 Subject: [PATCH 1/2] Fix over-warning bug when specifying runtime CLI option on dotnet run --- src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs | 6 ++++++ .../dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) 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..b1975d846746 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() + [Theory] + [InlineData("build")] + [InlineData("run")] + public void It_does_not_warn_on_rid_with_self_contained_options(string commandName) { var testInstance = _testAssetsManager.CopyTestAsset("HelloWorld") .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 From 223927687395b4df0883c65af69c3c6e721bebfa Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 30 Sep 2021 14:41:49 -0700 Subject: [PATCH 2/2] Fix test infra issue --- src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs index b1975d846746..01e96b09f5b6 100644 --- a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs +++ b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs @@ -192,12 +192,12 @@ public void It_warns_on_rid_without_self_contained_options() .HaveStdOutContaining("NETSDK1179"); } - [Theory] + [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);