Merge branch 'rel/1.0.0' into LocAddCommand

This commit is contained in:
Piotr Puszkiewicz 2016-12-05 10:53:52 -08:00 committed by GitHub
commit 337becdefd
3 changed files with 62 additions and 16 deletions

View file

@ -115,6 +115,12 @@
public const string SolutionDoesNotExist = "Specified solution file {0} does not exist, or there is no solution file in the directory.";
public const string SolutionAlreadyContainsAProject = "Solution {0} already contains project {1}.";
/// add p2p
public const string ReferenceDoesNotExistForce = "Reference {0} does not exist. If you still want to add it, please use --force option. Please note that this may have adverse effects on the project. ";
public const string ReferenceIsInvalid = "Reference `{0}` is invalid.";
public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add. Please run dotnet add --help for more information.";
public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`.";
/// add package
public const string PackageReferenceDoesNotExist = "Package reference `{0}` does not exist.";
public const string PackageReferenceIsInvalid = "Package reference `{0}` is invalid.";
@ -130,6 +136,13 @@
public const string ProjectAddedToTheSolution = "Project `{0}` added to the solution.";
public const string SolutionAlreadyHasAProject = "Solution {0} already contains project {1}.";
/// del p2p
public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}.";
public const string ReferenceRemoved = "Reference `{0}` deleted from the project.";
public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
public const string ReferenceDeleted = "Reference `{0}` deleted.";
public const string SpecifyAtLeastOneReferenceToDelete = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
/// del pkg
public const string PackageReferenceNotFoundInTheProject = "Package reference `{0}` could not be found in the project.";
public const string PackageReferenceRemoved = "Reference `{0}` deleted from the project.";

View file

@ -2,15 +2,50 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
{
internal class LocalizableStrings
{
/// del p2p
public const string AppFullName = ".NET Remove Project to Project (p2p) reference Command";
public const string AppDescription = "Command to remove project to project (p2p) reference";
public const string AppArgumentSeparatorHelpText = "Project to project references to remove";
public const string CmdArgProject = "PROJECT";
public const string CmdArgumentDescription = "The project file to modify. If a project file is not specified, it searches the current working directory for an MSBuild file that has a file extension that ends in `proj` and uses that file.";
public const string CmdFramework = "FRAMEWORK";
public const string CmdFrameworkDescription = "Remove reference only when targetting a specific framework";
public const string ProjectException = "Project";
public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}.";
public const string ReferenceRemoved = "Reference `{0}` deleted from the project.";
public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
public const string ReferenceDeleted = "Reference `{0}` deleted.";
public const string SpecifyAtLeastOneReferenceToDelete = "You must specify at least one reference to delete. Please run dotnet delete --help for more information.";
public const string NetRemoveCommand = ".NET Remove Command";
public const string Usage = "Usage";
public const string Options = "Options";
public const string HelpDefinition = "Show help information";
public const string Arguments = "Arguments";
public const string ArgumentsObjectDefinition = "The object of the operation. If a project file is not specified, it defaults to the current directory.";
public const string ArgumentsCommandDefinition = "Command to be executed on <object>.";
public const string ArgsDefinition = "Any extra arguments passed to the command. Use `dotnet add <command> --help` to get help about these arguments.";
public const string Commands = "Commands";
public const string CommandP2PDefinition = "Remove project to project (p2p) reference from a project";
}
}
}

View file

@ -16,29 +16,27 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectToProjectReference
CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false)
{
Name = "dotnet remove p2p",
FullName = ".NET Remove Project to Project (p2p) reference Command",
Description = "Command to remove project to project (p2p) reference",
FullName = LocalizableStrings.AppFullName,
Description = LocalizableStrings.AppDescription,
AllowArgumentSeparator = true,
ArgumentSeparatorHelpText = "Project to project references to remove"
ArgumentSeparatorHelpText = LocalizableStrings.AppArgumentSeparatorHelpText
};
app.HelpOption("-h|--help");
CommandArgument projectArgument = app.Argument(
"<PROJECT>",
"The project file to modify. If a project file is not specified," +
" it searches the current working directory for an MSBuild file that has" +
" a file extension that ends in `proj` and uses that file.");
$"<{LocalizableStrings.CmdArgProject}>",
LocalizableStrings.CmdArgumentDescription);
CommandOption frameworkOption = app.Option(
"-f|--framework <FRAMEWORK>",
"Remove reference only when targetting a specific framework",
$"-f|--framework <{LocalizableStrings.CmdFramework}>",
LocalizableStrings.CmdFrameworkDescription,
CommandOptionType.SingleValue);
app.OnExecute(() => {
if (string.IsNullOrEmpty(projectArgument.Value))
{
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, "<Project>");
throw new GracefulException(CommonLocalizableStrings.RequiredArgumentNotPassed, $"<{LocalizableStrings.ProjectException}>");
}
var msbuildProj = MsbuildProject.FromFileOrDirectory(projectArgument.Value);