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;
|
2016-02-11 00:13:30 +00:00
|
|
|
|
using NuGet.Frameworks;
|
2016-01-06 10:27:16 +00:00
|
|
|
|
using NuGet.Packaging;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Utils
|
|
|
|
|
{
|
|
|
|
|
internal static class CommandResolver
|
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
private static DefaultCommandResolver _defaultCommandResolver;
|
|
|
|
|
private static ScriptCommandResolver _scriptCommandResolver;
|
2016-01-06 10:27:16 +00:00
|
|
|
|
|
2016-02-25 00:05:55 +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
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
var commandResolverArgs = new CommandResolverArguments
|
2016-01-06 10:27:16 +00:00
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
CommandName = commandName,
|
|
|
|
|
CommandArguments = args,
|
|
|
|
|
Framework = framework,
|
|
|
|
|
ProjectDirectory = Directory.GetCurrentDirectory(),
|
2016-03-03 23:31:04 +00:00
|
|
|
|
Configuration = configuration,
|
|
|
|
|
OutputPath = outputPath
|
2016-02-25 00:05:55 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (_defaultCommandResolver == null)
|
2016-01-11 22:54:02 +00:00
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
_defaultCommandResolver = DefaultCommandResolver.Create();
|
2016-01-22 22:03:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-25 00:05:55 +00:00
|
|
|
|
return _defaultCommandResolver.Resolve(commandResolverArgs);
|
2016-01-22 22:03:40 +00:00
|
|
|
|
}
|
2016-02-25 00:05:55 +00:00
|
|
|
|
|
|
|
|
|
public static CommandSpec TryResolveScriptCommandSpec(
|
|
|
|
|
string commandName,
|
|
|
|
|
IEnumerable<string> args,
|
|
|
|
|
Project project,
|
|
|
|
|
string[] inferredExtensionList)
|
2016-01-22 22:03:40 +00:00
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
var commandResolverArgs = new CommandResolverArguments
|
2016-01-22 22:03:40 +00:00
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
CommandName = commandName,
|
|
|
|
|
CommandArguments = args,
|
|
|
|
|
ProjectDirectory = project.ProjectDirectory,
|
|
|
|
|
InferredExtensions = inferredExtensionList
|
|
|
|
|
};
|
2016-01-22 11:59:04 +00:00
|
|
|
|
|
2016-02-25 00:05:55 +00:00
|
|
|
|
if (_scriptCommandResolver == null)
|
2016-01-22 11:59:04 +00:00
|
|
|
|
{
|
2016-02-25 00:05:55 +00:00
|
|
|
|
_scriptCommandResolver = ScriptCommandResolver.Create();
|
2016-01-22 11:59:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-25 00:05:55 +00:00
|
|
|
|
return _scriptCommandResolver.Resolve(commandResolverArgs);
|
2016-01-11 22:54:02 +00:00
|
|
|
|
}
|
2016-01-06 10:27:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-22 22:03:40 +00:00
|
|
|
|
|