 88e2e9e993
			
		
	
	
	
	
	88e2e9e993This commit attempts to make the command line help user experience for `dotnet` more consistent for all of the built-in SDK commands. The following has been changed: * Organized the top-level help into a section detailing how to run .NET applications and a section on running SDK commands. * Sorted the SDK commands by name (previous ordering was undefined). * Removed `--verbosity` from the "common options section" since it is not a top-level option, nor is it common to all commands. * Added missing parameter names for parameterized options (especially for the `dotnet tool` subcommands). * Fixed the localization of parameter names for parameterized options. * Added missing `PROJECT` parameter to a few commands. * Fixed the localization of the build command's `PROJECT` parameter description. * Fixed the confusing descriptions for the `--framework`, `--configuration`, and `--runtime` options that were being shared between different commands. * Fixed the "unknown command" error for `dotnet help <command>` to show in red. * Deleted .resx for `dotnet msbuild` that is no longer used. * Change the option descriptions to be more consistent in their grammatical structure. * Removed extra blank line from end of help output. Fixes #7431. Fixes #9230. Fixes #9165.
		
			
				
	
	
		
			84 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C#
		
	
	
	
	
	
| // Copyright (c) .NET Foundation and contributors. All rights reserved.
 | |
| // Licensed under the MIT license. See LICENSE file in the project root for full license information.
 | |
| 
 | |
| using System;
 | |
| using System.IO;
 | |
| using FluentAssertions;
 | |
| using Microsoft.DotNet.Tools;
 | |
| using Microsoft.DotNet.Tools.Test.Utilities;
 | |
| using Xunit;
 | |
| 
 | |
| namespace Microsoft.DotNet.Cli.Remove.Package.Tests
 | |
| {
 | |
|     public class GivenDotnetRemovePackage : TestBase
 | |
|     {
 | |
|         private const string HelpText = @"Usage: dotnet remove <PROJECT> package [options] <PACKAGE_NAME>
 | |
| 
 | |
| Arguments:
 | |
|   <PROJECT>        The project file to operate on. If a file is not specified, the command will search the current directory for one.
 | |
|   <PACKAGE_NAME>   The package reference to remove.
 | |
| 
 | |
| Options:
 | |
|   -h, --help   Show command line help.";
 | |
| 
 | |
|         private const string RemoveCommandHelpText = @"Usage: dotnet remove [options] <PROJECT> [command]
 | |
| 
 | |
| Arguments:
 | |
|   <PROJECT>   The project file to operate on. If a file is not specified, the command will search the current directory for one.
 | |
| 
 | |
| Options:
 | |
|   -h, --help   Show command line help.
 | |
| 
 | |
| Commands:
 | |
|   package <PACKAGE_NAME>     Remove a NuGet package reference from the project.
 | |
|   reference <PROJECT_PATH>   Remove a project-to-project reference from the project.";
 | |
| 
 | |
|         [Theory]
 | |
|         [InlineData("--help")]
 | |
|         [InlineData("-h")]
 | |
|         public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
 | |
|         {
 | |
|             var cmd = new DotnetCommand().ExecuteWithCapturedOutput($"remove package {helpArg}");
 | |
|             cmd.Should().Pass();
 | |
|             cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
 | |
|         }
 | |
| 
 | |
|         [Theory]
 | |
|         [InlineData("")]
 | |
|         [InlineData("unknownCommandName")]
 | |
|         public void WhenNoCommandIsPassedItPrintsError(string commandName)
 | |
|         {
 | |
|             var cmd = new DotnetCommand()
 | |
|                 .ExecuteWithCapturedOutput($"remove {commandName}");
 | |
|             cmd.Should().Fail();
 | |
|             cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed);
 | |
|             cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(RemoveCommandHelpText);
 | |
|         }
 | |
| 
 | |
|         [Fact]
 | |
|         public void WhenReferencedPackageIsPassedItGetsRemoved()
 | |
|         {
 | |
|             var projectDirectory = TestAssets
 | |
|                 .Get("TestAppSimple")
 | |
|                 .CreateInstance()
 | |
|                 .WithSourceFiles()
 | |
|                 .Root
 | |
|                 .FullName;
 | |
| 
 | |
|             var packageName = "Newtonsoft.Json";
 | |
|             var add = new DotnetCommand()
 | |
|                 .WithWorkingDirectory(projectDirectory)
 | |
|                 .ExecuteWithCapturedOutput($"add package {packageName}");
 | |
|             add.Should().Pass();
 | |
|           
 | |
| 
 | |
|             var remove = new DotnetCommand()
 | |
|                 .WithWorkingDirectory(projectDirectory)
 | |
|                 .ExecuteWithCapturedOutput($"remove package {packageName}");
 | |
| 
 | |
|             remove.Should().Pass();
 | |
|             remove.StdOut.Should().Contain($"Removing PackageReference for package '{packageName}' from project '{projectDirectory + Path.DirectorySeparatorChar}TestAppSimple.csproj'.");
 | |
|             remove.StdErr.Should().BeEmpty();
 | |
|         }
 | |
|     }
 | |
| }
 |