dotnet-installer/src/Microsoft.DotNet.Cli.Utils/CommandResolver.cs

68 lines
2.1 KiB
C#
Raw Normal View History

2016-01-06 10:27:16 +00:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Graph;
2016-02-03 18:57:25 +00:00
using Microsoft.Extensions.PlatformAbstractions;
using NuGet.Frameworks;
2016-01-06 10:27:16 +00:00
using NuGet.Packaging;
namespace Microsoft.DotNet.Cli.Utils
{
internal static class CommandResolver
{
private static DefaultCommandResolver _defaultCommandResolver;
private static ScriptCommandResolver _scriptCommandResolver;
2016-01-06 10:27:16 +00:00
public static CommandSpec TryResolveCommandSpec(
string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration=Constants.DefaultConfiguration,
string outputPath=null)
2016-01-06 10:27:16 +00:00
{
var commandResolverArgs = new CommandResolverArguments
2016-01-06 10:27:16 +00:00
{
CommandName = commandName,
CommandArguments = args,
Framework = framework,
ProjectDirectory = Directory.GetCurrentDirectory(),
Configuration = configuration,
OutputPath = outputPath
};
if (_defaultCommandResolver == null)
{
_defaultCommandResolver = DefaultCommandResolver.Create();
}
return _defaultCommandResolver.Resolve(commandResolverArgs);
}
public static CommandSpec TryResolveScriptCommandSpec(
string commandName,
IEnumerable<string> args,
Project project,
string[] inferredExtensionList)
{
var commandResolverArgs = new CommandResolverArguments
{
CommandName = commandName,
CommandArguments = args,
ProjectDirectory = project.ProjectDirectory,
InferredExtensions = inferredExtensionList
};
2016-01-22 11:59:04 +00:00
if (_scriptCommandResolver == null)
2016-01-22 11:59:04 +00:00
{
_scriptCommandResolver = ScriptCommandResolver.Create();
2016-01-22 11:59:04 +00:00
}
return _scriptCommandResolver.Resolve(commandResolverArgs);
}
2016-01-06 10:27:16 +00:00
}
}