2015-12-31 01:02:59 +00: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.
|
|
|
|
|
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-04-05 00:51:36 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2015-12-31 01:02:59 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Test.Utilities
|
|
|
|
|
{
|
|
|
|
|
public sealed class RunCommand : TestCommand
|
|
|
|
|
{
|
|
|
|
|
private string _projectPath;
|
|
|
|
|
private string _framework;
|
|
|
|
|
private string _configuration;
|
|
|
|
|
private bool _preserveTemporary;
|
|
|
|
|
private string _appArgs;
|
|
|
|
|
|
|
|
|
|
private string ProjectPathOption
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _projectPath == string.Empty ?
|
|
|
|
|
"" :
|
2016-01-22 22:05:02 +00:00
|
|
|
|
$"-p \"{_projectPath}\"";
|
2015-12-31 01:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string FrameworkOption
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _framework == string.Empty ?
|
|
|
|
|
"" :
|
|
|
|
|
$"-f {_framework}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string ConfigurationOption
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _configuration == string.Empty ?
|
|
|
|
|
"" :
|
|
|
|
|
$"-c {_configuration}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string PreserveTemporaryOption
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _preserveTemporary ?
|
2016-01-22 22:05:02 +00:00
|
|
|
|
$"-t \"{_projectPath}\"" :
|
2015-12-31 01:02:59 +00:00
|
|
|
|
"";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string AppArgsArgument
|
|
|
|
|
{
|
|
|
|
|
get { return _appArgs; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RunCommand(
|
|
|
|
|
string projectPath,
|
2016-04-05 00:51:36 +00:00
|
|
|
|
string framework = "",
|
|
|
|
|
string configuration = "",
|
|
|
|
|
bool preserveTemporary = false,
|
|
|
|
|
string appArgs = "")
|
2015-12-31 01:02:59 +00:00
|
|
|
|
: base("dotnet")
|
|
|
|
|
{
|
|
|
|
|
_projectPath = projectPath;
|
|
|
|
|
_framework = framework;
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
_preserveTemporary = preserveTemporary;
|
|
|
|
|
_appArgs = appArgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult Execute(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"run {BuildArgs()} {args}";
|
|
|
|
|
return base.Execute(args);
|
|
|
|
|
}
|
2016-04-05 00:51:36 +00:00
|
|
|
|
|
2016-03-31 16:00:25 +00:00
|
|
|
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"run {BuildArgs()} {args}";
|
|
|
|
|
return base.ExecuteWithCapturedOutput(args);
|
|
|
|
|
}
|
2015-12-31 01:02:59 +00:00
|
|
|
|
|
2016-04-05 00:51:36 +00:00
|
|
|
|
public override Task<CommandResult> ExecuteAsync(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"run {BuildArgs()} {args}";
|
|
|
|
|
return base.ExecuteAsync(args);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-31 01:02:59 +00:00
|
|
|
|
private string BuildArgs()
|
|
|
|
|
{
|
|
|
|
|
return $"{ProjectPathOption} {FrameworkOption} {ConfigurationOption} {PreserveTemporaryOption} {AppArgsArgument}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|