Skip to content

Fix over-warning bug when specifying runtime CLI option on dotnet run #21561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Cli/dotnet/commands/dotnet-run/RunCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ internal static class RunCommandParser

public static readonly Option<bool> 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);
Expand All @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down