dotnet-installer/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs
2017-03-02 21:04:03 -08:00

56 lines
1.9 KiB
C#

// 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 System.IO;
using NuGet.Frameworks;
namespace Microsoft.DotNet.Cli.Utils
{
internal class CommandResolver
{
public static CommandSpec TryResolveCommandSpec(
string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration = Constants.DefaultConfiguration,
string outputPath = null,
string applicationName = null)
{
return TryResolveCommandSpec(
new DefaultCommandResolverPolicy(),
commandName,
args,
framework,
configuration,
outputPath,
applicationName);
}
public static CommandSpec TryResolveCommandSpec(
ICommandResolverPolicy commandResolverPolicy,
string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration = Constants.DefaultConfiguration,
string outputPath = null,
string applicationName = null)
{
var commandResolverArgs = new CommandResolverArguments
{
CommandName = commandName,
CommandArguments = args,
Framework = framework,
ProjectDirectory = Directory.GetCurrentDirectory(),
Configuration = configuration,
OutputPath = outputPath,
ApplicationName = applicationName
};
var defaultCommandResolver = commandResolverPolicy.CreateCommandResolver();
return defaultCommandResolver.Resolve(commandResolverArgs);
}
}
}