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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Linq;
|
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;
|
2015-12-18 16:39:43 -08:00
|
|
|
using Microsoft.Extensions.PlatformAbstractions;
|
2016-01-04 12:36:46 -08:00
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Restore
|
|
|
|
{
|
2016-01-30 21:47:50 -08:00
|
|
|
public partial class RestoreCommand
|
2016-01-04 12:36:46 -08:00
|
|
|
{
|
2015-12-18 16:39:43 -08:00
|
|
|
private static readonly string DefaultRid = PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier();
|
|
|
|
|
2016-01-30 21:47:50 -08:00
|
|
|
public static int Run(string[] args)
|
2016-01-04 12:36:46 -08:00
|
|
|
{
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
|
|
|
var app = new CommandLineApplication(false)
|
|
|
|
{
|
|
|
|
Name = "dotnet restore",
|
|
|
|
FullName = ".NET project dependency restorer",
|
|
|
|
Description = "Restores dependencies listed in project.json"
|
|
|
|
};
|
2016-01-12 16:36:31 -08:00
|
|
|
|
|
|
|
// Parse --quiet, because we have to handle that specially since NuGet3 has a different
|
|
|
|
// "--verbosity" switch that goes BEFORE the command
|
|
|
|
var quiet = args.Any(s => s.Equals("--quiet", StringComparison.OrdinalIgnoreCase));
|
|
|
|
args = args.Where(s => !s.Equals("--quiet", StringComparison.OrdinalIgnoreCase)).ToArray();
|
2016-03-30 16:01:23 -07:00
|
|
|
|
2016-01-04 12:36:46 -08:00
|
|
|
app.OnExecute(() =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-03-17 11:44:18 -07:00
|
|
|
return NuGet3.Restore(args, quiet);
|
2016-01-04 12:36:46 -08:00
|
|
|
}
|
|
|
|
catch (InvalidOperationException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return app.Execute(args);
|
|
|
|
}
|
|
|
|
}
|
2016-01-12 16:36:31 -08:00
|
|
|
}
|