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">
|
||||
<value>Show help information.</value>
|
||||
</data>
|
||||
<data name="NoRestoreDescription" xml:space="preserve">
|
||||
<value>Does not do an implicit restore when executing the command.</value>
|
||||
</data>
|
||||
</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> 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 =>
|
||||
!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;
|
||||
restoreArguments = restoreArguments.Concat(new string[] { "/v:q" });
|
||||
}
|
||||
|
||||
return restoreArguments;
|
||||
}
|
||||
|
||||
private bool ShouldRunImplicitRestore => !NoRestore;
|
||||
|
@ -46,7 +43,7 @@ namespace Microsoft.DotNet.Tools
|
|||
{
|
||||
if (ShouldRunImplicitRestore)
|
||||
{
|
||||
int exitCode = RestoreCommand.Run(ArgsToForwardToRestore.ToArray());
|
||||
int exitCode = RestoreCommand.Run(ArgsToForwardToRestore().ToArray());
|
||||
if (exitCode != 0)
|
||||
{
|
||||
return exitCode;
|
||||
|
|
|
@ -12,49 +12,33 @@ namespace Microsoft.DotNet.Cli
|
|||
internal static class BuildCommandParser
|
||||
{
|
||||
public static Command Build() =>
|
||||
Create.Command(
|
||||
CreateWithRestoreOptions.Command(
|
||||
"build",
|
||||
LocalizableStrings.AppFullName,
|
||||
Accept.ZeroOrMoreArguments()
|
||||
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||
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."),
|
||||
FullBuildOptions
|
||||
);
|
||||
|
||||
private static Option[] FullBuildOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullBuildOptions = new List<Option>
|
||||
{
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.OutputOptionDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.OutputOptionName)
|
||||
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
||||
CommonOptions.FrameworkOption(),
|
||||
CommonOptions.RuntimeOption(),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
CommonOptions.VersionSuffixOption(),
|
||||
Create.Option(
|
||||
"--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();
|
||||
}
|
||||
}
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.OutputOptionDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.OutputOptionName)
|
||||
.ForwardAsSingle(o => $"/p:OutputPath={o.Arguments.Single()}")),
|
||||
CommonOptions.FrameworkOption(),
|
||||
CommonOptions.RuntimeOption(),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
CommonOptions.VersionSuffixOption(),
|
||||
Create.Option(
|
||||
"--no-incremental",
|
||||
LocalizableStrings.NoIncrementialOptionDescription),
|
||||
Create.Option(
|
||||
"--no-dependencies",
|
||||
LocalizableStrings.NoDependenciesOptionDescription,
|
||||
Accept.NoArguments()
|
||||
.ForwardAs("/p:BuildProjectReferences=false")),
|
||||
CommonOptions.NoRestoreOption(),
|
||||
CommonOptions.VerbosityOption());
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Tools;
|
||||
using LocalizableStrings = Microsoft.DotNet.Tools.Pack.LocalizableStrings;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
|
@ -11,51 +12,36 @@ namespace Microsoft.DotNet.Cli
|
|||
internal static class PackCommandParser
|
||||
{
|
||||
public static Command Pack() =>
|
||||
Create.Command(
|
||||
CreateWithRestoreOptions.Command(
|
||||
"pack",
|
||||
LocalizableStrings.AppFullName,
|
||||
Accept.ZeroOrMoreArguments(),
|
||||
FullPackOptions);
|
||||
|
||||
private static Option[] FullPackOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullPackOptions = new List<Option>
|
||||
{
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.CmdOutputDirDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.CmdOutputDir)
|
||||
.ForwardAsSingle(o => $"/p:PackageOutputPath={o.Arguments.Single()}")),
|
||||
Create.Option(
|
||||
"--no-build",
|
||||
LocalizableStrings.CmdNoBuildOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:NoBuild=true")),
|
||||
Create.Option(
|
||||
"--include-symbols",
|
||||
LocalizableStrings.CmdIncludeSymbolsDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:IncludeSymbols=true")),
|
||||
Create.Option(
|
||||
"--include-source",
|
||||
LocalizableStrings.CmdIncludeSourceDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:IncludeSource=true")),
|
||||
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();
|
||||
}
|
||||
}
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.CmdOutputDirDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.CmdOutputDir)
|
||||
.ForwardAsSingle(o => $"/p:PackageOutputPath={o.Arguments.Single()}")),
|
||||
Create.Option(
|
||||
"--no-build",
|
||||
LocalizableStrings.CmdNoBuildOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:NoBuild=true")),
|
||||
Create.Option(
|
||||
"--include-symbols",
|
||||
LocalizableStrings.CmdIncludeSymbolsDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:IncludeSymbols=true")),
|
||||
Create.Option(
|
||||
"--include-source",
|
||||
LocalizableStrings.CmdIncludeSourceDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:IncludeSource=true")),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
CommonOptions.VersionSuffixOption(),
|
||||
Create.Option(
|
||||
"-s|--serviceable",
|
||||
LocalizableStrings.CmdServiceableDescription,
|
||||
Accept.NoArguments().ForwardAs("/p:Serviceable=true")),
|
||||
CommonOptions.NoRestoreOption(),
|
||||
CommonOptions.VerbosityOption());
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Tools;
|
||||
using LocalizableStrings = Microsoft.DotNet.Tools.Publish.LocalizableStrings;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
|
@ -11,53 +12,38 @@ namespace Microsoft.DotNet.Cli
|
|||
internal static class PublishCommandParser
|
||||
{
|
||||
public static Command Publish() =>
|
||||
Create.Command(
|
||||
CreateWithRestoreOptions.Command(
|
||||
"publish",
|
||||
LocalizableStrings.AppDescription,
|
||||
Accept.ZeroOrMoreArguments(),
|
||||
FullPublishOptions);
|
||||
|
||||
private static Option[] FullPublishOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullPublishOptions = new List<Option>
|
||||
{
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.OutputOptionDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.OutputOption)
|
||||
.ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")),
|
||||
CommonOptions.FrameworkOption(),
|
||||
CommonOptions.RuntimeOption(),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
CommonOptions.VersionSuffixOption(),
|
||||
Create.Option(
|
||||
"--manifest",
|
||||
LocalizableStrings.ManifestOptionDescription,
|
||||
Accept.OneOrMoreArguments()
|
||||
.With(name: LocalizableStrings.ManifestOption)
|
||||
.ForwardAsSingle(o => $"/p:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
|
||||
Create.Option(
|
||||
"--self-contained",
|
||||
LocalizableStrings.SelfContainedOptionDescription,
|
||||
Accept.ZeroOrOneArgument()
|
||||
.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();
|
||||
}
|
||||
}
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-o|--output",
|
||||
LocalizableStrings.OutputOptionDescription,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.OutputOption)
|
||||
.ForwardAsSingle(o => $"/p:PublishDir={o.Arguments.Single()}")),
|
||||
CommonOptions.FrameworkOption(),
|
||||
CommonOptions.RuntimeOption(),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
CommonOptions.VersionSuffixOption(),
|
||||
Create.Option(
|
||||
"--manifest",
|
||||
LocalizableStrings.ManifestOptionDescription,
|
||||
Accept.OneOrMoreArguments()
|
||||
.With(name: LocalizableStrings.ManifestOption)
|
||||
.ForwardAsSingle(o => $"/p:TargetManifestFiles={string.Join("%3B", o.Arguments)}")),
|
||||
Create.Option(
|
||||
"--self-contained",
|
||||
LocalizableStrings.SelfContainedOptionDescription,
|
||||
Accept.ZeroOrOneArgument()
|
||||
.WithSuggestionsFrom("true", "false")
|
||||
.ForwardAsSingle(o =>
|
||||
{
|
||||
string value = o.Arguments.Any() ? o.Arguments.Single() : "true";
|
||||
return $"/p:SelfContained={value}";
|
||||
})),
|
||||
CommonOptions.NoRestoreOption(),
|
||||
CommonOptions.VerbosityOption());
|
||||
}
|
||||
}
|
|
@ -15,28 +15,27 @@ namespace Microsoft.DotNet.Cli
|
|||
"restore",
|
||||
LocalizableStrings.AppFullName,
|
||||
Accept.ZeroOrMoreArguments(),
|
||||
FullRestoreOptions);
|
||||
FullRestoreOptions());
|
||||
|
||||
private static Option[] FullRestoreOptions
|
||||
private static Option[] FullRestoreOptions()
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullRestoreOptions = new List<Option>();
|
||||
var fullRestoreOptions = AddImplicitRestoreOptions(new Option[] { CommonOptions.HelpOption() }, true, true);
|
||||
|
||||
fullRestoreOptions.Add(CommonOptions.HelpOption());
|
||||
AddImplicitRestoreOptions(fullRestoreOptions, true, true);
|
||||
fullRestoreOptions.Add(CommonOptions.VerbosityOption());
|
||||
|
||||
return fullRestoreOptions.ToArray();
|
||||
}
|
||||
return fullRestoreOptions.Concat(new Option[] { CommonOptions.VerbosityOption() }).ToArray();
|
||||
}
|
||||
|
||||
public static void AddImplicitRestoreOptions(
|
||||
List<Option> commandOptions,
|
||||
bool showHelp = false,
|
||||
bool useShortOptions = false)
|
||||
public static Option[] AddImplicitRestoreOptions(
|
||||
IEnumerable<Option> commandOptions)
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -89,11 +88,10 @@ namespace Microsoft.DotNet.Cli
|
|||
Accept.NoArguments()
|
||||
.ForwardAs("/p:RestoreRecursive=false")),
|
||||
Create.Option(
|
||||
"-f|--force",
|
||||
useShortOptions ? "-f|--force" : "--force",
|
||||
LocalizableStrings.CmdForceRestoreOptionDescription,
|
||||
Accept.NoArguments()
|
||||
.ForwardAs("/p:RestoreForce=true")),
|
||||
CommonOptions.VerbosityOption()
|
||||
.ForwardAs("/p:RestoreForce=true"))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Tools;
|
||||
using Microsoft.DotNet.Tools.Run;
|
||||
using LocalizableStrings = Microsoft.DotNet.Tools.Run.LocalizableStrings;
|
||||
|
||||
|
@ -12,7 +13,7 @@ namespace Microsoft.DotNet.Cli
|
|||
internal static class RunCommandParser
|
||||
{
|
||||
public static Command Run() =>
|
||||
Create.Command(
|
||||
CreateWithRestoreOptions.Command(
|
||||
"run",
|
||||
LocalizableStrings.AppFullName,
|
||||
treatUnmatchedTokensAsErrors: false,
|
||||
|
@ -29,13 +30,7 @@ namespace Microsoft.DotNet.Cli
|
|||
restoreArgs: o.OptionValuesToBeForwarded(),
|
||||
args: o.Arguments
|
||||
)),
|
||||
options: FullRunOptions);
|
||||
|
||||
private static Option[] FullRunOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullRunOptions = new List<Option>
|
||||
options: new[]
|
||||
{
|
||||
CommonOptions.HelpOption(),
|
||||
CommonOptions.ConfigurationOption(),
|
||||
|
@ -57,12 +52,6 @@ namespace Microsoft.DotNet.Cli
|
|||
LocalizableStrings.CommandOptionNoBuildDescription,
|
||||
Accept.NoArguments()),
|
||||
CommonOptions.NoRestoreOption()
|
||||
};
|
||||
|
||||
RestoreCommandParser.AddImplicitRestoreOptions(fullRunOptions);
|
||||
|
||||
return fullRunOptions.ToArray();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Tools;
|
||||
using LocalizableStrings = Microsoft.DotNet.Tools.Test.LocalizableStrings;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
|
@ -18,89 +19,74 @@ namespace Microsoft.DotNet.Cli
|
|||
.With(name: LocalizableStrings.CmdArgProject,
|
||||
description: LocalizableStrings.CmdArgDescription),
|
||||
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
|
||||
{
|
||||
get
|
||||
{
|
||||
var fullTestOptions = new List<Option>
|
||||
{
|
||||
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));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
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());
|
||||
|
||||
private static string GetSemiColonEsacpedstring(string arg)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue