// 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 Microsoft.DotNet.Cli.CommandLine; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.MSBuild; using Microsoft.DotNet.Cli; using Parser = Microsoft.DotNet.Cli.Parser; namespace Microsoft.DotNet.Tools.Restore { public class RestoreCommand : MSBuildForwardingApp { public RestoreCommand(IEnumerable msbuildArgs, string msbuildPath = null) : base(msbuildArgs, msbuildPath) { } public static RestoreCommand FromArgs(string[] args, string msbuildPath = null) { DebugHelper.HandleDebugSwitch(ref args); var parser = Parser.DotnetCommand["restore"]; var result = parser.Parse(args); var restore = result["restore"]; var msbuildArgs = new List { "/NoLogo", "/t:Restore", "/ConsoleLoggerParameters:Verbosity=Minimal" }; msbuildArgs.AddRange(restore.ArgsToBeForwarded()); msbuildArgs.AddRange(restore.Arguments); return new RestoreCommand(msbuildArgs, msbuildPath); } public static int Run(string[] args) { DebugHelper.HandleDebugSwitch(ref args); RestoreCommand cmd; try { cmd = FromArgs(args); } catch (CommandCreationException e) { return e.ExitCode; } return cmd.Execute(); } } }