2017-02-14 01:56:25 +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;
|
|
|
|
|
using NuGet.Frameworks;
|
2017-03-07 06:57:40 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-02-14 01:56:25 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Test.Utilities
|
|
|
|
|
{
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public sealed class StoreCommand : DotnetCommand
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
2017-03-07 06:57:40 +00:00
|
|
|
|
private List<string> _profileProject = new List<string>();
|
2017-02-14 01:56:25 +00:00
|
|
|
|
private string _framework;
|
|
|
|
|
private string _output;
|
|
|
|
|
private string _runtime;
|
|
|
|
|
private string _frameworkVersion;
|
|
|
|
|
private string _intermediateWorkingDirectory;
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithManifest(string profileProject)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
2017-04-07 19:15:38 +00:00
|
|
|
|
_profileProject.Add($"--manifest {profileProject}");
|
2017-03-07 06:57:40 +00:00
|
|
|
|
|
2017-02-14 01:56:25 +00:00
|
|
|
|
return this;
|
|
|
|
|
}
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithFramework(string framework)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
_framework = framework;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithFramework(NuGetFramework framework)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
return WithFramework(framework.GetShortFolderName());
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithOutput(string output)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
_output = output;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithRuntime(string runtime)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
_runtime = runtime;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithRuntimeFrameworkVersion(string frameworkVersion)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
_frameworkVersion = frameworkVersion;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 19:15:38 +00:00
|
|
|
|
public StoreCommand WithIntermediateWorkingDirectory(string intermediateWorkingDirectory)
|
2017-02-14 01:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
_intermediateWorkingDirectory = intermediateWorkingDirectory;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult Execute(string args = "")
|
|
|
|
|
{
|
2017-04-07 19:15:38 +00:00
|
|
|
|
args = $"store {BuildArgs()} {args}";
|
2017-02-14 01:56:25 +00:00
|
|
|
|
return base.Execute(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
|
|
|
|
{
|
2017-04-07 19:15:38 +00:00
|
|
|
|
args = $"store {BuildArgs()} {args}";
|
2017-02-14 01:56:25 +00:00
|
|
|
|
return base.ExecuteWithCapturedOutput(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string BuildArgs()
|
|
|
|
|
{
|
|
|
|
|
return string.Join(" ",
|
|
|
|
|
ProfileProjectOption,
|
|
|
|
|
FrameworkOption,
|
|
|
|
|
OutputOption,
|
|
|
|
|
IntermediateWorkingDirectoryOption,
|
|
|
|
|
RuntimeOption,
|
|
|
|
|
FrameworkVersionOption);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 06:57:40 +00:00
|
|
|
|
private string ProfileProjectOption => string.Join(" ", _profileProject) ;
|
2017-02-14 01:56:25 +00:00
|
|
|
|
|
|
|
|
|
private string FrameworkOption => string.IsNullOrEmpty(_framework) ? "" : $"-f {_framework}";
|
|
|
|
|
|
|
|
|
|
private string OutputOption => string.IsNullOrEmpty(_output) ? "" : $"-o {_output}";
|
|
|
|
|
|
|
|
|
|
private string RuntimeOption => string.IsNullOrEmpty(_runtime) ? "" : $"-r {_runtime}";
|
|
|
|
|
|
|
|
|
|
private string FrameworkVersionOption => string.IsNullOrEmpty(_frameworkVersion) ? "" : $" --framework-version {_frameworkVersion}";
|
|
|
|
|
|
|
|
|
|
private string IntermediateWorkingDirectoryOption => string.IsNullOrEmpty(_intermediateWorkingDirectory)? "" : $" -w {_intermediateWorkingDirectory}";
|
|
|
|
|
}
|
|
|
|
|
}
|