Add dotnet-add command
This commit is contained in:
parent
c6bd3eeec6
commit
e4ccc0ff9b
3 changed files with 71 additions and 0 deletions
|
@ -24,6 +24,7 @@ using Microsoft.DotNet.Tools.Run;
|
|||
using Microsoft.DotNet.Tools.Test;
|
||||
using Microsoft.DotNet.Tools.VSTest;
|
||||
using NuGet.Frameworks;
|
||||
using Microsoft.DotNet.Tools.Add;
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
{
|
||||
|
@ -45,6 +46,7 @@ namespace Microsoft.DotNet.Cli
|
|||
["run"] = RunCommand.Run,
|
||||
["test"] = TestCommand.Run,
|
||||
["vstest"] = VSTestCommand.Run,
|
||||
["add"] = AddCommand.Run,
|
||||
};
|
||||
|
||||
public static int Main(string[] args)
|
||||
|
|
68
src/dotnet/commands/dotnet-add/Program.cs
Normal file
68
src/dotnet/commands/dotnet-add/Program.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// 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 System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Build.Construction;
|
||||
using Microsoft.DotNet.ProjectJsonMigration;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Add
|
||||
{
|
||||
public class AddCommand
|
||||
{
|
||||
public const string CommandName = "dotnet-add";
|
||||
public const string UsageText = @"Usage: dotnet add [command] [arguments]
|
||||
|
||||
Arguments:
|
||||
[command] The command to execute
|
||||
[arguments] Arguments to pass to the command
|
||||
|
||||
Commands:
|
||||
p2p Add project to project (p2p) reference to a project";
|
||||
|
||||
private static Dictionary<string, Func<string[], int>> s_builtIns = new Dictionary<string, Func<string[], int>>
|
||||
{
|
||||
["p2p"] = null,
|
||||
};
|
||||
|
||||
public static int Run(string[] args)
|
||||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
if (args.Length == 0 || args[0] == "--help" || args[0] == "-h")
|
||||
{
|
||||
Reporter.Output.WriteLine(UsageText);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args[0].StartsWith("-"))
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unknown option: {args[0]}");
|
||||
Reporter.Output.WriteLine(UsageText);
|
||||
return 1;
|
||||
}
|
||||
|
||||
string command = args[0];
|
||||
Func<string[], int> builtIn;
|
||||
args = args.Skip(1).ToArray();
|
||||
if (s_builtIns.TryGetValue(command, out builtIn))
|
||||
{
|
||||
return builtIn(args);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandResult result = Command.Create(
|
||||
$"{CommandName}-{command}",
|
||||
args,
|
||||
FrameworkConstants.CommonFrameworks.NetStandardApp15)
|
||||
.Execute();
|
||||
return result.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,6 +36,7 @@ Commands:
|
|||
migrate Migrates a project.json based project to a msbuild based project
|
||||
|
||||
Advanced Commands:
|
||||
add Group of commands - run `dotnet add --help` for more information
|
||||
nuget Provides additional NuGet commands
|
||||
msbuild msbuilds a project and all of its dependencies
|
||||
vstest Runs tests from the specified files";
|
||||
|
|
Loading…
Reference in a new issue