[WIP] Removes *3 verbs, making msbuild the driver (#4456)
Removes *3 verbs, making msbuild the driver
This commit is contained in:
parent
55c59d621e
commit
6fcbefa4f7
746 changed files with 4256 additions and 32434 deletions
|
@ -1,21 +1,124 @@
|
|||
// 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.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.DotNet.Tools.MSBuild;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Restore
|
||||
{
|
||||
public partial class RestoreCommand
|
||||
public class RestoreCommand
|
||||
{
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
return NuGet3.Restore(args);
|
||||
CommandLineApplication cmd = new CommandLineApplication(throwOnUnexpectedArg: false)
|
||||
{
|
||||
Name = "restore",
|
||||
FullName = "restore",
|
||||
Description = "restore for msbuild",
|
||||
AllowArgumentSeparator = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
};
|
||||
|
||||
cmd.HelpOption("-h|--help");
|
||||
|
||||
var argRoot = cmd.Argument(
|
||||
"[root]",
|
||||
"Optional path to a project file or MSBuild arguments.",
|
||||
multipleValues: true);
|
||||
|
||||
var sourceOption = cmd.Option(
|
||||
"-s|--source <source>",
|
||||
"Specifies a NuGet package source to use during the restore.",
|
||||
CommandOptionType.MultipleValue);
|
||||
|
||||
var packagesOption = cmd.Option(
|
||||
"--packages <packagesDirectory>",
|
||||
"Directory to install packages in.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var disableParallelOption = cmd.Option(
|
||||
"--disable-parallel",
|
||||
"Disables restoring multiple projects in parallel.",
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
var configFileOption = cmd.Option(
|
||||
"--configfile <file>",
|
||||
"The NuGet configuration file to use.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var noCacheOption = cmd.Option(
|
||||
"--no-cache",
|
||||
"Do not cache packages and http requests.",
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
var ignoreFailedSourcesOption = cmd.Option(
|
||||
"--ignore-failed-sources",
|
||||
"Treat package source failures as warnings.",
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
var noDependenciesOption = cmd.Option(
|
||||
"--no-dependencies",
|
||||
"Set this flag to ignore project to project references and only restore the root project",
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
cmd.OnExecute(() =>
|
||||
{
|
||||
var msbuildArgs = new List<string>()
|
||||
{
|
||||
"/NoLogo",
|
||||
"/t:Restore",
|
||||
"/ConsoleLoggerParameters:Verbosity=Minimal"
|
||||
};
|
||||
|
||||
if (sourceOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreSources={string.Join("%3B", sourceOption.Values)}");
|
||||
}
|
||||
|
||||
if (packagesOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestorePackagesPath={packagesOption.Value()}");
|
||||
}
|
||||
|
||||
if (disableParallelOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreDisableParallel=true");
|
||||
}
|
||||
|
||||
if (configFileOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreConfigFile={configFileOption.Value()}");
|
||||
}
|
||||
|
||||
if (noCacheOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreNoCache=true");
|
||||
}
|
||||
|
||||
if (ignoreFailedSourcesOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreIgnoreFailedSources=true");
|
||||
}
|
||||
|
||||
if (noDependenciesOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:RestoreRecursive=false");
|
||||
}
|
||||
|
||||
// Add in arguments
|
||||
msbuildArgs.AddRange(argRoot.Values);
|
||||
|
||||
// Add remaining arguments that the parser did not understand
|
||||
msbuildArgs.AddRange(cmd.RemainingArguments);
|
||||
|
||||
return new MSBuildForwardingApp(msbuildArgs).Execute();
|
||||
});
|
||||
|
||||
return cmd.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue