dotnet-installer/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/Publish3Command.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2016-09-23 16:11:44 +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;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public sealed class Publish3Command : TestCommand
{
private string _framework;
private string _runtime;
2016-09-23 16:11:44 +00:00
public Publish3Command()
: base("dotnet")
{
}
public Publish3Command WithFramework(string framework)
{
_framework = framework;
return this;
}
public Publish3Command WithRuntime(string runtime)
{
_runtime = runtime;
return this;
}
2016-09-23 16:11:44 +00:00
public override CommandResult Execute(string args = "")
{
args = $"publish3 {args} {BuildArgs()}";
2016-09-23 16:11:44 +00:00
return base.Execute(args);
}
public override CommandResult ExecuteWithCapturedOutput(string args = "")
{
args = $"publish3 {args} {BuildArgs()}";
2016-09-23 16:11:44 +00:00
return base.ExecuteWithCapturedOutput(args);
}
private string BuildArgs()
{
return string.Join(" ",
FrameworkOption,
RuntimeOption);
}
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
private string RuntimeOption => string.IsNullOrEmpty(_runtime) ? "" : $"-r {_runtime}";
2016-09-23 16:11:44 +00:00
}
}