This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cli/src/dotnet/commands/dotnet-restore/Program.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 lines (52 sloc)
1.9 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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.Collections.Generic; | |
| using System.Linq; | |
| 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<string> msbuildArgs, string msbuildPath = null) | |
| : base(msbuildArgs, msbuildPath) | |
| { | |
| } | |
| public static RestoreCommand FromArgs(string[] args, string msbuildPath = null) | |
| { | |
| DebugHelper.HandleDebugSwitch(ref args); | |
| Reporter.Output.WriteLine(string.Join(" ", args)); | |
| var parser = Parser.Instance; | |
| var result = parser.ParseFrom("dotnet restore", args); | |
| result.ShowHelpOrErrorIfAppropriate(); | |
| var parsedRestore = result["dotnet"]["restore"]; | |
| var msbuildArgs = new List<string> | |
| { | |
| "/NoLogo", | |
| "/t:Restore", | |
| "/ConsoleLoggerParameters:Verbosity=Minimal" | |
| }; | |
| msbuildArgs.AddRange(parsedRestore.OptionValuesToBeForwarded()); | |
| msbuildArgs.AddRange(parsedRestore.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(); | |
| } | |
| } | |
| } |