diff --git a/src/Cli/dotnet/CommonOptions.cs b/src/Cli/dotnet/CommonOptions.cs index bda8bdca8970..fe1d4c775e71 100644 --- a/src/Cli/dotnet/CommonOptions.cs +++ b/src/Cli/dotnet/CommonOptions.cs @@ -133,7 +133,7 @@ public static ForwardedOption InteractiveOption(bool acceptArgument = fals Description = CliStrings.CommandInteractiveOptionDescription, Arity = acceptArgument ? ArgumentArity.ZeroOrOne : ArgumentArity.Zero, // this default is called when no tokens/options are passed on the CLI args - DefaultValueFactory = (ar) => IsCIEnvironmentOrRedirected() + DefaultValueFactory = (ar) => !IsCIEnvironmentOrRedirected() }; public static CliOption InteractiveMsBuildForwardOption = InteractiveOption(acceptArgument: true).ForwardAsSingle(b => $"-property:NuGetInteractive={(b ? "true" : "false")}"); diff --git a/test/dotnet-watch.Tests/CommandLineOptionsTests.cs b/test/dotnet-watch.Tests/CommandLineOptionsTests.cs index 60a93026f998..30d70643855a 100644 --- a/test/dotnet-watch.Tests/CommandLineOptionsTests.cs +++ b/test/dotnet-watch.Tests/CommandLineOptionsTests.cs @@ -414,7 +414,7 @@ public void ShortFormForLaunchProfileArgumentWorks() Assert.Equal("CustomLaunchProfile", options.LaunchProfileName); } - private const string NugetInteractiveProperty = "-property:NuGetInteractive=true"; + private const string NugetInteractiveProperty = "-property:NuGetInteractive=false"; /// /// Validates that options that the "run" command forwards to "build" command are forwarded by dotnet-watch. @@ -424,7 +424,7 @@ public void ShortFormForLaunchProfileArgumentWorks() [InlineData(new[] { "--framework", "net9.0" }, new[] { "-property:TargetFramework=net9.0", NugetInteractiveProperty })] [InlineData(new[] { "--runtime", "arm64" }, new[] { "-property:RuntimeIdentifier=arm64", "-property:_CommandLineDefinedRuntimeIdentifier=true", NugetInteractiveProperty })] [InlineData(new[] { "--property", "b=1" }, new[] { "--property:b=1", NugetInteractiveProperty })] - [InlineData(new[] { "--interactive" }, new[] { NugetInteractiveProperty })] + [InlineData(new[] { "--interactive" }, new[] { "-property:NuGetInteractive=true" })] [InlineData(new[] { "--no-restore" }, new[] { NugetInteractiveProperty, "-restore:false" })] [InlineData(new[] { "--sc" }, new[] { NugetInteractiveProperty, "-property:SelfContained=True", "-property:_CommandLineDefinedSelfContained=true" })] [InlineData(new[] { "--self-contained" }, new[] { NugetInteractiveProperty, "-property:SelfContained=True", "-property:_CommandLineDefinedSelfContained=true" })] diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetBuildInvocation.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetBuildInvocation.cs index e1ec4ba71e35..b16aa4f38288 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetBuildInvocation.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetBuildInvocation.cs @@ -10,7 +10,7 @@ public class GivenDotnetBuildInvocation : IClassFixture { - private const string NugetInteractiveProperty = "-property:NuGetInteractive=true"; + private const string NugetInteractiveProperty = "-property:NuGetInteractive=false"; private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-verbosity:normal", "-target:Clean", NugetInteractiveProperty]; diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetOsArchOptions.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetOsArchOptions.cs index 54a1ef267eee..efce58f982e5 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetOsArchOptions.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetOsArchOptions.cs @@ -14,7 +14,7 @@ public GivenDotnetOsArchOptions(ITestOutputHelper log) : base(log) } private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo"]; - private const string NugetInteractiveProperty = "-property:NuGetInteractive=true"; + private const string NugetInteractiveProperty = "-property:NuGetInteractive=false"; private static readonly string[] DefaultArgs = ["-restore", "-consoleloggerparameters:Summary", NugetInteractiveProperty]; private static readonly string WorkingDirectory = diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs index 15a01f9b40a3..898ea5d9e9c7 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs @@ -10,7 +10,7 @@ public class GivenDotnetPackInvocation : IClassFixture { - private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-target:Restore", "-property:NuGetInteractive=true"]; + private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-target:Restore"]; + private static readonly string NuGetDisabledProperty = "-property:NuGetInteractive=false"; private static readonly string WorkingDirectory = TestPathUtilities.FormatAbsolutePath(nameof(GivenDotnetRestoreInvocation)); @@ -49,7 +50,7 @@ public void MsbuildInvocationIsCorrect(string[] args, string[] expectedAdditiona RestoreCommand.FromArgs(args, msbuildPath) .GetArgumentTokensToMSBuild() .Should() - .BeEquivalentTo([.. ExpectedPrefix, .. expectedAdditionalArgs]); + .BeEquivalentTo([.. ExpectedPrefix, .. expectedAdditionalArgs, NuGetDisabledProperty]); }); } } diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetRunInvocation.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetRunInvocation.cs index 1b2ac0950389..a98dbd8572f0 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetRunInvocation.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetRunInvocation.cs @@ -8,7 +8,8 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests [Collection(TestConstants.UsesStaticTelemetryState)] public class GivenDotnetRunInvocation : IClassFixture { - private static readonly string[] ConstantRestoreArgs = ["-nologo", "-verbosity:minimal", "-property:NuGetInteractive=true"]; + private static readonly string[] ConstantRestoreArgs = ["-nologo", "-verbosity:quiet"]; + private static readonly string NuGetDisabledProperty = "-property:NuGetInteractive=false"; public ITestOutputHelper Log { get; } @@ -41,7 +42,7 @@ public void MsbuildInvocationIsCorrect(string[] args, string[] expectedArgs) var command = RunCommand.FromArgs(args); command.RestoreArgs .Should() - .BeEquivalentTo([.. ConstantRestoreArgs, .. expectedArgs]); + .BeEquivalentTo([.. ConstantRestoreArgs, .. expectedArgs, NuGetDisabledProperty]); }); } finally diff --git a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetTestInvocation.cs b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetTestInvocation.cs index b146ead52b80..30fce45eb55f 100644 --- a/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetTestInvocation.cs +++ b/test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetTestInvocation.cs @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Cli.MSBuild.Tests [Collection(TestConstants.UsesStaticTelemetryState)] public class GivenDotnetTestInvocation : IClassFixture { - private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-restore", "-nologo", "-target:VSTest", "-property:NuGetInteractive=true"]; + private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-restore", "-nologo", "-target:VSTest", "-property:NuGetInteractive=false"]; private static readonly string WorkingDirectory = TestPathUtilities.FormatAbsolutePath(nameof(GivenDotnetTestInvocation)); diff --git a/test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs b/test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs index 9a94cfe86f97..059877551298 100644 --- a/test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs +++ b/test/dotnet.Tests/CommandTests/Package/Remove/GivenDotnetRemovePackage.cs @@ -18,7 +18,7 @@ dotnet remove [] package ... [options] The package reference to remove. Options: - --interactive Allows the command to stop and wait for user input or action (for example to complete authentication). [default: True] + --interactive Allows the command to stop and wait for user input or action (for example to complete authentication). [default: False] -?, -h, --help Show command line help."; private Func RemoveCommandHelpText = (defaultVal) => $@"Description: diff --git a/test/dotnet.Tests/CommandTests/Reference/Add/AddReferenceParserTests.cs b/test/dotnet.Tests/CommandTests/Reference/Add/AddReferenceParserTests.cs index 20204cc1fa26..1efd8b75d6df 100644 --- a/test/dotnet.Tests/CommandTests/Reference/Add/AddReferenceParserTests.cs +++ b/test/dotnet.Tests/CommandTests/Reference/Add/AddReferenceParserTests.cs @@ -38,15 +38,6 @@ public void AddReferenceHasInteractiveFlag() .Should().BeTrue(); } - [Fact] - public void AddReferenceDoesHaveInteractiveFlagByDefault() - { - var result = Parser.Instance.Parse("dotnet add reference my.csproj"); - - result.GetValue(ReferenceAddCommandParser.InteractiveOption) - .Should().BeTrue(); - } - [Fact] public void AddReferenceWithoutArgumentResultsInAnError() { diff --git a/test/dotnet.Tests/CommandTests/Reference/Add/GivenDotnetAddReference.cs b/test/dotnet.Tests/CommandTests/Reference/Add/GivenDotnetAddReference.cs index ca40c346bcf4..d9e6a860925f 100644 --- a/test/dotnet.Tests/CommandTests/Reference/Add/GivenDotnetAddReference.cs +++ b/test/dotnet.Tests/CommandTests/Reference/Add/GivenDotnetAddReference.cs @@ -19,7 +19,7 @@ dotnet reference add ... [options] Options: -f, --framework Add the reference only when targeting a specific framework. --interactive Allows the command to stop and wait for user input or action (for example to complete - authentication). [default: True] + authentication). [default: False] --project The project file to operate on. If a file is not specified, the command will search the current directory for one. -?, -h, --help Show command line help."; diff --git a/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunBuildsCsProj.cs b/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunBuildsCsProj.cs index 9dcfbdc83efe..052377b1a83b 100644 --- a/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunBuildsCsProj.cs +++ b/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunBuildsCsProj.cs @@ -697,23 +697,6 @@ public void ItRunsWithTheSpecifiedVerbosity() } } - [Fact] - public void ItDoesShowImportantLevelMessageByDefault() - { - var testAppName = "MSBuildTestApp"; - var testInstance = _testAssetsManager.CopyTestAsset(testAppName) - .WithSource() - .WithProjectChanges(ProjectModification.AddDisplayMessageBeforeRestoreToProject); - - var result = new DotnetCommand(Log, "run") - .WithWorkingDirectory(testInstance.Path) - .Execute(); - - // this message should show because interactivity (and therefore nuget auth) is the default - result.Should().Pass() - .And.HaveStdOutContaining("Important text"); - } - [Fact] public void ItDoesNotShowImportantLevelMessageByDefaultWhenInteractivityDisabled() {