2016-01-04 12:36:46 -08:00
|
|
|
// 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.
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
using System.Collections.Generic;
|
2016-04-19 22:51:32 -05:00
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
2016-01-04 12:36:46 -08:00
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-10-27 18:46:43 -07:00
|
|
|
using Microsoft.DotNet.Tools.MSBuild;
|
2017-02-22 11:43:03 -08:00
|
|
|
using Microsoft.DotNet.Cli;
|
2017-03-06 20:53:26 -08:00
|
|
|
using Parser = Microsoft.DotNet.Cli.Parser;
|
2016-01-04 12:36:46 -08:00
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Restore
|
|
|
|
{
|
2017-02-23 11:31:48 -08:00
|
|
|
public class RestoreCommand : MSBuildForwardingApp
|
2016-01-04 12:36:46 -08:00
|
|
|
{
|
2017-02-22 11:43:03 -08:00
|
|
|
public RestoreCommand(IEnumerable<string> msbuildArgs, string msbuildPath = null)
|
2017-02-23 11:31:48 -08:00
|
|
|
: base(msbuildArgs, msbuildPath)
|
2017-02-22 11:43:03 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RestoreCommand FromArgs(string[] args, string msbuildPath = null)
|
2016-01-04 12:36:46 -08:00
|
|
|
{
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
2017-03-06 20:53:26 -08:00
|
|
|
var parser = Parser.DotnetCommand["restore"];
|
2016-10-27 18:46:43 -07:00
|
|
|
|
2017-03-06 20:53:26 -08:00
|
|
|
var result = parser.Parse(args);
|
2016-10-27 18:46:43 -07:00
|
|
|
|
2017-03-06 20:53:26 -08:00
|
|
|
var restore = result["restore"];
|
2016-10-27 18:46:43 -07:00
|
|
|
|
2017-03-06 20:53:26 -08:00
|
|
|
var msbuildArgs = new List<string>
|
2016-10-27 18:46:43 -07:00
|
|
|
{
|
2017-03-06 20:53:26 -08:00
|
|
|
"/NoLogo",
|
|
|
|
"/t:Restore",
|
|
|
|
"/ConsoleLoggerParameters:Verbosity=Minimal"
|
|
|
|
};
|
2016-10-27 18:46:43 -07:00
|
|
|
|
2017-03-06 20:53:26 -08:00
|
|
|
msbuildArgs.AddRange(restore.ArgsToBeForwarded());
|
|
|
|
msbuildArgs.AddRange(restore.Arguments);
|
2017-02-22 11:43:03 -08:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2016-01-04 12:36:46 -08:00
|
|
|
}
|
2017-03-06 20:53:26 -08:00
|
|
|
}
|