Changing the parser description for commands that have implicit restore.
This commit is contained in:
parent
3231295acf
commit
c89618603a
9 changed files with 225 additions and 257 deletions
|
@ -520,4 +520,7 @@
|
||||||
<data name="ShowHelpDescription" xml:space="preserve">
|
<data name="ShowHelpDescription" xml:space="preserve">
|
||||||
<value>Show help information.</value>
|
<value>Show help information.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="NoRestoreDescription" xml:space="preserve">
|
||||||
|
<value>Does not do an implicit restore when executing the command.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
39
src/dotnet/commands/CommandWithRestoreOptions.cs
Normal file
39
src/dotnet/commands/CommandWithRestoreOptions.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.DotNet.Cli;
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools.MSBuild;
|
||||||
|
using Microsoft.DotNet.Tools.Restore;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Tools
|
||||||
|
{
|
||||||
|
public static class CreateWithRestoreOptions
|
||||||
|
{
|
||||||
|
public static Command Command(
|
||||||
|
string name,
|
||||||
|
string help,
|
||||||
|
ArgumentsRule arguments,
|
||||||
|
params Option[] options)
|
||||||
|
{
|
||||||
|
return Create.Command(name, help, arguments, RestoreCommandParser.AddImplicitRestoreOptions(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Command Command(
|
||||||
|
string name,
|
||||||
|
string help,
|
||||||
|
ArgumentsRule arguments,
|
||||||
|
bool treatUnmatchedTokensAsErrors,
|
||||||
|
params Option[] options)
|
||||||
|
{
|
||||||
|
return Create.Command(
|
||||||
|
name,
|
||||||
|
help,
|
||||||
|
arguments,
|
||||||
|
treatUnmatchedTokensAsErrors,
|
||||||
|
RestoreCommandParser.AddImplicitRestoreOptions(options));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,23 +14,20 @@ namespace Microsoft.DotNet.Tools
|
||||||
|
|
||||||
private IEnumerable<string> ArgsToForward { get; }
|
private IEnumerable<string> ArgsToForward { get; }
|
||||||
|
|
||||||
private IEnumerable<string> ArgsToForwardToRestore
|
private IEnumerable<string> ArgsToForwardToRestore()
|
||||||
{
|
{
|
||||||
get
|
var restoreArguments = ArgsToForward.Where(a =>
|
||||||
|
!a.StartsWith("/t:") &&
|
||||||
|
!a.StartsWith("/target:") &&
|
||||||
|
!a.StartsWith("/ConsoleLoggerParameters:") &&
|
||||||
|
!a.StartsWith("/clp:"));
|
||||||
|
|
||||||
|
if (!restoreArguments.Any(a => a.StartsWith("/v:") || a.StartsWith("/verbosity:")))
|
||||||
{
|
{
|
||||||
var restoreArguments = ArgsToForward.Where(a =>
|
restoreArguments = restoreArguments.Concat(new string[] { "/v:q" });
|
||||||
!a.StartsWith("/t:") &&
|
|
||||||
!a.StartsWith("/target:") &&
|
|
||||||
!a.StartsWith("/ConsoleLoggerParameters:") &&
|
|
||||||
!a.StartsWith("/clp:"));
|
|
||||||
|
|
||||||
if (!restoreArguments.Any(a => a.StartsWith("/v:") || a.StartsWith("/verbosity:")))
|
|
||||||
{
|
|
||||||
restoreArguments = restoreArguments.Concat(new string[] { "/v:q" });
|
|
||||||
}
|
|
||||||
|
|
||||||
return restoreArguments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return restoreArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldRunImplicitRestore => !NoRestore;
|
private bool ShouldRunImplicitRestore => !NoRestore;
|
||||||
|
@ -46,7 +43,7 @@ namespace Microsoft.DotNet.Tools
|
||||||
{
|
{
|
||||||
if (ShouldRunImplicitRestore)
|
if (ShouldRunImplicitRestore)
|
||||||
{
|
{
|
||||||
int exitCode = RestoreCommand.Run(ArgsToForwardToRestore.ToArray());
|
int exitCode = RestoreCommand.Run(ArgsToForwardToRestore().ToArray());
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
{
|
{
|
||||||
return exitCode;
|
return exitCode;
|
||||||
|
|
|
@ -12,49 +12,33 @@ namespace Microsoft.DotNet.Cli
|
||||||
internal static class BuildCommandParser
|
internal static class BuildCommandParser
|
||||||
{
|
{
|
||||||
public static Command Build() =>
|
public static Command Build() =>
|
||||||
Create.Command(
|
CreateWithRestoreOptions.Command(
|
||||||
"build",
|
"build",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrMoreArguments()
|
Accept.ZeroOrMoreArguments()
|
||||||
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||||
description:
|
description:
|
||||||
"The MSBuild project file to build. If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."),
|
"The MSBuild project file to build. If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."),
|
||||||
FullBuildOptions
|
CommonOptions.HelpOption(),
|
||||||
);
|
Create.Option(
|
||||||
|
"-o|--output",
|
||||||
private static Option[] FullBuildOptions
|
LocalizableStrings.OutputOptionDescription,
|
||||||
{
|
Accept.ExactlyOneArgument()
|
||||||
get
|
.With(name: LocalizableStrings.OutputOptionName)
|
||||||
{
|
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
||||||
var fullBuildOptions = new List<Option>
|
CommonOptions.FrameworkOption(),
|
||||||
{
|
CommonOptions.RuntimeOption(),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.ConfigurationOption(),
|
||||||
Create.Option(
|
CommonOptions.VersionSuffixOption(),
|
||||||
"-o|--output",
|
Create.Option(
|
||||||
LocalizableStrings.OutputOptionDescription,
|
"--no-incremental",
|
||||||
Accept.ExactlyOneArgument()
|
LocalizableStrings.NoIncrementialOptionDescription),
|
||||||
.With(name: LocalizableStrings.OutputOptionName)
|
Create.Option(
|
||||||
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
"--no-dependencies",
|
||||||
CommonOptions.FrameworkOption(),
|
LocalizableStrings.NoDependenciesOptionDescription,
|
||||||
CommonOptions.RuntimeOption(),
|
Accept.NoArguments()
|
||||||
CommonOptions.ConfigurationOption(),
|
.ForwardAs("/p:BuildProjectReferences=false")),
|
||||||
CommonOptions.VersionSuffixOption(),
|
CommonOptions.NoRestoreOption(),
|
||||||
Create.Option(
|
CommonOptions.VerbosityOption());
|
||||||
"--no-incremental",
|
|
||||||
LocalizableStrings.NoIncrementialOptionDescription),
|
|
||||||
Create.Option(
|
|
||||||
"--no-dependencies",
|
|
||||||
LocalizableStrings.NoDependenciesOptionDescription,
|
|
||||||
Accept.NoArguments()
|
|
||||||
.ForwardAs("/p:BuildProjectReferences=false")),
|
|
||||||
CommonOptions.NoRestoreOption(),
|
|
||||||
CommonOptions.VerbosityOption()
|
|
||||||
};
|
|
||||||
|
|
||||||
RestoreCommandParser.AddImplicitRestoreOptions(fullBuildOptions);
|
|
||||||
|
|
||||||
return fullBuildOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Pack.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Pack.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
|
@ -11,51 +12,36 @@ namespace Microsoft.DotNet.Cli
|
||||||
internal static class PackCommandParser
|
internal static class PackCommandParser
|
||||||
{
|
{
|
||||||
public static Command Pack() =>
|
public static Command Pack() =>
|
||||||
Create.Command(
|
CreateWithRestoreOptions.Command(
|
||||||
"pack",
|
"pack",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrMoreArguments(),
|
Accept.ZeroOrMoreArguments(),
|
||||||
FullPackOptions);
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option(
|
||||||
private static Option[] FullPackOptions
|
"-o|--output",
|
||||||
{
|
LocalizableStrings.CmdOutputDirDescription,
|
||||||
get
|
Accept.ExactlyOneArgument()
|
||||||
{
|
.With(name: LocalizableStrings.CmdOutputDir)
|
||||||
var fullPackOptions = new List<Option>
|
.ForwardAsSingle(o => $"/p:PackageOutputPath={o.Arguments.Single()}")),
|
||||||
{
|
Create.Option(
|
||||||
CommonOptions.HelpOption(),
|
"--no-build",
|
||||||
Create.Option(
|
LocalizableStrings.CmdNoBuildOptionDescription,
|
||||||
"-o|--output",
|
Accept.NoArguments().ForwardAs("/p:NoBuild=true")),
|
||||||
LocalizableStrings.CmdOutputDirDescription,
|
Create.Option(
|
||||||
Accept.ExactlyOneArgument()
|
"--include-symbols",
|
||||||
.With(name: LocalizableStrings.CmdOutputDir)
|
LocalizableStrings.CmdIncludeSymbolsDescription,
|
||||||
.ForwardAsSingle(o => $"/p:PackageOutputPath={o.Arguments.Single()}")),
|
Accept.NoArguments().ForwardAs("/p:IncludeSymbols=true")),
|
||||||
Create.Option(
|
Create.Option(
|
||||||
"--no-build",
|
"--include-source",
|
||||||
LocalizableStrings.CmdNoBuildOptionDescription,
|
LocalizableStrings.CmdIncludeSourceDescription,
|
||||||
Accept.NoArguments().ForwardAs("/p:NoBuild=true")),
|
Accept.NoArguments().ForwardAs("/p:IncludeSource=true")),
|
||||||
Create.Option(
|
CommonOptions.ConfigurationOption(),
|
||||||
"--include-symbols",
|
CommonOptions.VersionSuffixOption(),
|
||||||
LocalizableStrings.CmdIncludeSymbolsDescription,
|
Create.Option(
|
||||||
Accept.NoArguments().ForwardAs("/p:IncludeSymbols=true")),
|
"-s|--serviceable",
|
||||||
Create.Option(
|
LocalizableStrings.CmdServiceableDescription,
|
||||||
"--include-source",
|
Accept.NoArguments().ForwardAs("/p:Serviceable=true")),
|
||||||
LocalizableStrings.CmdIncludeSourceDescription,
|
CommonOptions.NoRestoreOption(),
|
||||||
Accept.NoArguments().ForwardAs("/p:IncludeSource=true")),
|
CommonOptions.VerbosityOption());
|
||||||
CommonOptions.ConfigurationOption(),
|
|
||||||
CommonOptions.VersionSuffixOption(),
|
|
||||||
Create.Option(
|
|
||||||
"-s|--serviceable",
|
|
||||||
LocalizableStrings.CmdServiceableDescription,
|
|
||||||
Accept.NoArguments().ForwardAs("/p:Serviceable=true")),
|
|
||||||
CommonOptions.NoRestoreOption(),
|
|
||||||
CommonOptions.VerbosityOption()
|
|
||||||
};
|
|
||||||
|
|
||||||
RestoreCommandParser.AddImplicitRestoreOptions(fullPackOptions);
|
|
||||||
|
|
||||||
return fullPackOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Publish.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Publish.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
|
@ -11,53 +12,38 @@ namespace Microsoft.DotNet.Cli
|
||||||
internal static class PublishCommandParser
|
internal static class PublishCommandParser
|
||||||
{
|
{
|
||||||
public static Command Publish() =>
|
public static Command Publish() =>
|
||||||
Create.Command(
|
CreateWithRestoreOptions.Command(
|
||||||
"publish",
|
"publish",
|
||||||
LocalizableStrings.AppDescription,
|
LocalizableStrings.AppDescription,
|
||||||
Accept.ZeroOrMoreArguments(),
|
Accept.ZeroOrMoreArguments(),
|
||||||
FullPublishOptions);
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option(
|
||||||
private static Option[] FullPublishOptions
|
"-o|--output",
|
||||||
{
|
LocalizableStrings.OutputOptionDescription,
|
||||||
get
|
Accept.ExactlyOneArgument()
|
||||||
{
|
.With(name: LocalizableStrings.OutputOption)
|
||||||
var fullPublishOptions = new List<Option>
|
.ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")),
|
||||||
{
|
CommonOptions.FrameworkOption(),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.RuntimeOption(),
|
||||||
Create.Option(
|
CommonOptions.ConfigurationOption(),
|
||||||
"-o|--output",
|
CommonOptions.VersionSuffixOption(),
|
||||||
LocalizableStrings.OutputOptionDescription,
|
Create.Option(
|
||||||
Accept.ExactlyOneArgument()
|
"--manifest",
|
||||||
.With(name: LocalizableStrings.OutputOption)
|
LocalizableStrings.ManifestOptionDescription,
|
||||||
.ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")),
|
Accept.OneOrMoreArguments()
|
||||||
CommonOptions.FrameworkOption(),
|
.With(name: LocalizableStrings.ManifestOption)
|
||||||
CommonOptions.RuntimeOption(),
|
.ForwardAsSingle(o => $"/p:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
|
||||||
CommonOptions.ConfigurationOption(),
|
Create.Option(
|
||||||
CommonOptions.VersionSuffixOption(),
|
"--self-contained",
|
||||||
Create.Option(
|
LocalizableStrings.SelfContainedOptionDescription,
|
||||||
"--manifest",
|
Accept.ZeroOrOneArgument()
|
||||||
LocalizableStrings.ManifestOptionDescription,
|
.WithSuggestionsFrom("true", "false")
|
||||||
Accept.OneOrMoreArguments()
|
.ForwardAsSingle(o =>
|
||||||
.With(name: LocalizableStrings.ManifestOption)
|
{
|
||||||
.ForwardAsSingle(o => $"/p:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
|
string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
|
||||||
Create.Option(
|
return $"/p:SelfContained={value}";
|
||||||
"--self-contained",
|
})),
|
||||||
LocalizableStrings.SelfContainedOptionDescription,
|
CommonOptions.NoRestoreOption(),
|
||||||
Accept.ZeroOrOneArgument()
|
CommonOptions.VerbosityOption());
|
||||||
.WithSuggestionsFrom("true", "false")
|
|
||||||
.ForwardAsSingle(o =>
|
|
||||||
{
|
|
||||||
string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
|
|
||||||
return $"/p:SelfContained={value}";
|
|
||||||
})),
|
|
||||||
CommonOptions.NoRestoreOption(),
|
|
||||||
CommonOptions.VerbosityOption()
|
|
||||||
};
|
|
||||||
|
|
||||||
RestoreCommandParser.AddImplicitRestoreOptions(fullPublishOptions);
|
|
||||||
|
|
||||||
return fullPublishOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,28 +15,27 @@ namespace Microsoft.DotNet.Cli
|
||||||
"restore",
|
"restore",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrMoreArguments(),
|
Accept.ZeroOrMoreArguments(),
|
||||||
FullRestoreOptions);
|
FullRestoreOptions());
|
||||||
|
|
||||||
private static Option[] FullRestoreOptions
|
private static Option[] FullRestoreOptions()
|
||||||
{
|
{
|
||||||
get
|
var fullRestoreOptions = AddImplicitRestoreOptions(new Option[] { CommonOptions.HelpOption() }, true, true);
|
||||||
{
|
|
||||||
var fullRestoreOptions = new List<Option>();
|
|
||||||
|
|
||||||
fullRestoreOptions.Add(CommonOptions.HelpOption());
|
return fullRestoreOptions.Concat(new Option[] { CommonOptions.VerbosityOption() }).ToArray();
|
||||||
AddImplicitRestoreOptions(fullRestoreOptions, true, true);
|
|
||||||
fullRestoreOptions.Add(CommonOptions.VerbosityOption());
|
|
||||||
|
|
||||||
return fullRestoreOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddImplicitRestoreOptions(
|
public static Option[] AddImplicitRestoreOptions(
|
||||||
List<Option> commandOptions,
|
IEnumerable<Option> commandOptions)
|
||||||
bool showHelp = false,
|
|
||||||
bool useShortOptions = false)
|
|
||||||
{
|
{
|
||||||
commandOptions.AddRange(ImplicitRestoreOptions(showHelp, useShortOptions)
|
return AddImplicitRestoreOptions(commandOptions, false, false).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<Option> AddImplicitRestoreOptions(
|
||||||
|
IEnumerable<Option> commandOptions,
|
||||||
|
bool showHelp,
|
||||||
|
bool useShortOptions)
|
||||||
|
{
|
||||||
|
return commandOptions.Concat(ImplicitRestoreOptions(showHelp, useShortOptions)
|
||||||
.Where(o => !commandOptions.Any(c => c.Name == o.Name)));
|
.Where(o => !commandOptions.Any(c => c.Name == o.Name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,11 +88,10 @@ namespace Microsoft.DotNet.Cli
|
||||||
Accept.NoArguments()
|
Accept.NoArguments()
|
||||||
.ForwardAs("/p:RestoreRecursive=false")),
|
.ForwardAs("/p:RestoreRecursive=false")),
|
||||||
Create.Option(
|
Create.Option(
|
||||||
"-f|--force",
|
useShortOptions ? "-f|--force" : "--force",
|
||||||
LocalizableStrings.CmdForceRestoreOptionDescription,
|
LocalizableStrings.CmdForceRestoreOptionDescription,
|
||||||
Accept.NoArguments()
|
Accept.NoArguments()
|
||||||
.ForwardAs("/p:RestoreForce=true")),
|
.ForwardAs("/p:RestoreForce=true"))
|
||||||
CommonOptions.VerbosityOption()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
using Microsoft.DotNet.Tools.Run;
|
using Microsoft.DotNet.Tools.Run;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Run.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Run.LocalizableStrings;
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
internal static class RunCommandParser
|
internal static class RunCommandParser
|
||||||
{
|
{
|
||||||
public static Command Run() =>
|
public static Command Run() =>
|
||||||
Create.Command(
|
CreateWithRestoreOptions.Command(
|
||||||
"run",
|
"run",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
treatUnmatchedTokensAsErrors: false,
|
treatUnmatchedTokensAsErrors: false,
|
||||||
|
@ -29,13 +30,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
restoreArgs: o.OptionValuesToBeForwarded(),
|
restoreArgs: o.OptionValuesToBeForwarded(),
|
||||||
args: o.Arguments
|
args: o.Arguments
|
||||||
)),
|
)),
|
||||||
options: FullRunOptions);
|
options: new[]
|
||||||
|
|
||||||
private static Option[] FullRunOptions
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var fullRunOptions = new List<Option>
|
|
||||||
{
|
{
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
CommonOptions.ConfigurationOption(),
|
CommonOptions.ConfigurationOption(),
|
||||||
|
@ -57,12 +52,6 @@ namespace Microsoft.DotNet.Cli
|
||||||
LocalizableStrings.CommandOptionNoBuildDescription,
|
LocalizableStrings.CommandOptionNoBuildDescription,
|
||||||
Accept.NoArguments()),
|
Accept.NoArguments()),
|
||||||
CommonOptions.NoRestoreOption()
|
CommonOptions.NoRestoreOption()
|
||||||
};
|
});
|
||||||
|
|
||||||
RestoreCommandParser.AddImplicitRestoreOptions(fullRunOptions);
|
|
||||||
|
|
||||||
return fullRunOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Test.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Test.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
|
@ -18,89 +19,74 @@ namespace Microsoft.DotNet.Cli
|
||||||
.With(name: LocalizableStrings.CmdArgProject,
|
.With(name: LocalizableStrings.CmdArgProject,
|
||||||
description: LocalizableStrings.CmdArgDescription),
|
description: LocalizableStrings.CmdArgDescription),
|
||||||
false,
|
false,
|
||||||
FullTestOptions);
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option(
|
||||||
|
"-s|--settings",
|
||||||
|
LocalizableStrings.CmdSettingsDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdSettingsFile)
|
||||||
|
.ForwardAsSingle(o => $"/p:VSTestSetting={o.Arguments.Single()}")),
|
||||||
|
Create.Option(
|
||||||
|
"-t|--list-tests",
|
||||||
|
LocalizableStrings.CmdListTestsDescription,
|
||||||
|
Accept.NoArguments()
|
||||||
|
.ForwardAsSingle(o => "/p:VSTestListTests=true")),
|
||||||
|
Create.Option(
|
||||||
|
"--filter",
|
||||||
|
LocalizableStrings.CmdTestCaseFilterDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdTestCaseFilterExpression)
|
||||||
|
.ForwardAsSingle(o => $"/p:VSTestTestCaseFilter={o.Arguments.Single()}")),
|
||||||
|
Create.Option(
|
||||||
|
"-a|--test-adapter-path",
|
||||||
|
LocalizableStrings.CmdTestAdapterPathDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdTestAdapterPath)
|
||||||
|
.ForwardAsSingle(o => $"/p:VSTestTestAdapterPath={o.Arguments.Single()}")),
|
||||||
|
Create.Option(
|
||||||
|
"-l|--logger",
|
||||||
|
LocalizableStrings.CmdLoggerDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdLoggerOption)
|
||||||
|
.ForwardAsSingle(o =>
|
||||||
|
{
|
||||||
|
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));
|
||||||
|
|
||||||
private static Option[] FullTestOptions
|
return $"/p:VSTestLogger={loggersString}";
|
||||||
{
|
})),
|
||||||
get
|
CommonOptions.ConfigurationOption(),
|
||||||
{
|
CommonOptions.FrameworkOption(),
|
||||||
var fullTestOptions = new List<Option>
|
Create.Option(
|
||||||
{
|
"-o|--output",
|
||||||
CommonOptions.HelpOption(),
|
LocalizableStrings.CmdOutputDescription,
|
||||||
Create.Option(
|
Accept.ExactlyOneArgument()
|
||||||
"-s|--settings",
|
.With(name: LocalizableStrings.CmdOutputDir)
|
||||||
LocalizableStrings.CmdSettingsDescription,
|
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
||||||
Accept.ExactlyOneArgument()
|
Create.Option(
|
||||||
.With(name: LocalizableStrings.CmdSettingsFile)
|
"-d|--diag",
|
||||||
.ForwardAsSingle(o => $"/p:VSTestSetting={o.Arguments.Single()}")),
|
LocalizableStrings.CmdPathTologFileDescription,
|
||||||
Create.Option(
|
Accept.ExactlyOneArgument()
|
||||||
"-t|--list-tests",
|
.With(name: LocalizableStrings.CmdPathToLogFile)
|
||||||
LocalizableStrings.CmdListTestsDescription,
|
.ForwardAsSingle(o => $"/p:VSTestDiag={o.Arguments.Single()}")),
|
||||||
Accept.NoArguments()
|
Create.Option(
|
||||||
.ForwardAsSingle(o => "/p:VSTestListTests=true")),
|
"--no-build",
|
||||||
Create.Option(
|
LocalizableStrings.CmdNoBuildDescription,
|
||||||
"--filter",
|
Accept.NoArguments()
|
||||||
LocalizableStrings.CmdTestCaseFilterDescription,
|
.ForwardAsSingle(o => "/p:VSTestNoBuild=true")),
|
||||||
Accept.ExactlyOneArgument()
|
Create.Option(
|
||||||
.With(name: LocalizableStrings.CmdTestCaseFilterExpression)
|
"-r|--results-directory",
|
||||||
.ForwardAsSingle(o => $"/p:VSTestTestCaseFilter={o.Arguments.Single()}")),
|
LocalizableStrings.CmdResultsDirectoryDescription,
|
||||||
Create.Option(
|
Accept.ExactlyOneArgument()
|
||||||
"-a|--test-adapter-path",
|
.With(name: LocalizableStrings.CmdPathToResultsDirectory)
|
||||||
LocalizableStrings.CmdTestAdapterPathDescription,
|
.ForwardAsSingle(o => $"/p:VSTestResultsDirectory={o.Arguments.Single()}")),
|
||||||
Accept.ExactlyOneArgument()
|
Create.Option(
|
||||||
.With(name: LocalizableStrings.CmdTestAdapterPath)
|
"--collect",
|
||||||
.ForwardAsSingle(o => $"/p:VSTestTestAdapterPath={o.Arguments.Single()}")),
|
LocalizableStrings.cmdCollectDescription,
|
||||||
Create.Option(
|
Accept.OneOrMoreArguments()
|
||||||
"-l|--logger",
|
.With(name: LocalizableStrings.cmdCollectFriendlyName)
|
||||||
LocalizableStrings.CmdLoggerDescription,
|
.ForwardAsSingle(o => $"/p:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
|
||||||
Accept.ExactlyOneArgument()
|
CommonOptions.NoRestoreOption(),
|
||||||
.With(name: LocalizableStrings.CmdLoggerOption)
|
CommonOptions.VerbosityOption());
|
||||||
.ForwardAsSingle(o =>
|
|
||||||
{
|
|
||||||
var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments));
|
|
||||||
|
|
||||||
return $"/p:VSTestLogger={loggersString}";
|
|
||||||
})),
|
|
||||||
CommonOptions.ConfigurationOption(),
|
|
||||||
CommonOptions.FrameworkOption(),
|
|
||||||
Create.Option(
|
|
||||||
"-o|--output",
|
|
||||||
LocalizableStrings.CmdOutputDescription,
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: LocalizableStrings.CmdOutputDir)
|
|
||||||
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
|
||||||
Create.Option(
|
|
||||||
"-d|--diag",
|
|
||||||
LocalizableStrings.CmdPathTologFileDescription,
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: LocalizableStrings.CmdPathToLogFile)
|
|
||||||
.ForwardAsSingle(o => $"/p:VSTestDiag={o.Arguments.Single()}")),
|
|
||||||
Create.Option(
|
|
||||||
"--no-build",
|
|
||||||
LocalizableStrings.CmdNoBuildDescription,
|
|
||||||
Accept.NoArguments()
|
|
||||||
.ForwardAsSingle(o => "/p:VSTestNoBuild=true")),
|
|
||||||
Create.Option(
|
|
||||||
"-r|--results-directory",
|
|
||||||
LocalizableStrings.CmdResultsDirectoryDescription,
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: LocalizableStrings.CmdPathToResultsDirectory)
|
|
||||||
.ForwardAsSingle(o => $"/p:VSTestResultsDirectory={o.Arguments.Single()}")),
|
|
||||||
Create.Option(
|
|
||||||
"--collect",
|
|
||||||
LocalizableStrings.cmdCollectDescription,
|
|
||||||
Accept.OneOrMoreArguments()
|
|
||||||
.With(name: LocalizableStrings.cmdCollectFriendlyName)
|
|
||||||
.ForwardAsSingle(o => $"/p:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
|
|
||||||
CommonOptions.NoRestoreOption(),
|
|
||||||
CommonOptions.VerbosityOption()
|
|
||||||
};
|
|
||||||
|
|
||||||
RestoreCommandParser.AddImplicitRestoreOptions(fullTestOptions);
|
|
||||||
|
|
||||||
return fullTestOptions.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetSemiColonEsacpedstring(string arg)
|
private static string GetSemiColonEsacpedstring(string arg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue