2016-02-09 16:35:43 -08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2016-04-14 23:33:41 -05:00
|
|
|
|
using System;
|
2016-02-09 16:35:43 -08:00
|
|
|
|
using System.Collections.Generic;
|
2016-04-14 23:33:41 -05:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-02-09 16:35:43 -08:00
|
|
|
|
using NuGet.Frameworks;
|
|
|
|
|
|
2016-04-14 23:33:41 -05:00
|
|
|
|
namespace Microsoft.DotNet.Cli
|
2016-02-09 16:35:43 -08:00
|
|
|
|
{
|
|
|
|
|
public class DotNetCommandFactory : ICommandFactory
|
|
|
|
|
{
|
2016-11-28 00:46:26 -08:00
|
|
|
|
private bool _alwaysRunOutOfProc;
|
|
|
|
|
|
|
|
|
|
public DotNetCommandFactory(bool alwaysRunOutOfProc = false)
|
|
|
|
|
{
|
|
|
|
|
_alwaysRunOutOfProc = alwaysRunOutOfProc;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-05 18:55:15 -08:00
|
|
|
|
public ICommand Create(
|
|
|
|
|
string commandName,
|
|
|
|
|
IEnumerable<string> args,
|
|
|
|
|
NuGetFramework framework = null,
|
|
|
|
|
string configuration = Constants.DefaultConfiguration)
|
2016-02-09 16:35:43 -08:00
|
|
|
|
{
|
2016-04-14 23:33:41 -05:00
|
|
|
|
Func<string[], int> builtInCommand;
|
2016-11-28 00:46:26 -08:00
|
|
|
|
if (!_alwaysRunOutOfProc && Program.TryGetBuiltInCommand(commandName, out builtInCommand))
|
2016-04-14 23:33:41 -05:00
|
|
|
|
{
|
|
|
|
|
Debug.Assert(framework == null, "BuiltInCommand doesn't support the 'framework' argument.");
|
|
|
|
|
Debug.Assert(configuration == Constants.DefaultConfiguration, "BuiltInCommand doesn't support the 'configuration' argument.");
|
|
|
|
|
|
|
|
|
|
return new BuiltInCommand(commandName, args, builtInCommand);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-05 18:55:15 -08:00
|
|
|
|
return Command.CreateDotNet(commandName, args, framework, configuration);
|
2016-02-09 16:35:43 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|