parent
42cc39252e
commit
b813e2b849
14 changed files with 163 additions and 635 deletions
|
@ -15,6 +15,6 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"tools": {
|
"tools": {
|
||||||
"dotnet-hello": { "version": "1.0.0", "target": "package" }
|
"dotnet-hello": { "version": "2.0.0", "target": "package" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,11 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Command Create(CommandSpec commandSpec)
|
||||||
|
{
|
||||||
|
return new Command(commandSpec);
|
||||||
|
}
|
||||||
|
|
||||||
public static Command CreateForScript(
|
public static Command CreateForScript(
|
||||||
string commandName,
|
string commandName,
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
|
||||||
public NuGetFramework Framework { get; set; }
|
public NuGetFramework Framework { get; set; }
|
||||||
|
|
||||||
|
public string OutputPath { get; set; }
|
||||||
|
|
||||||
public string ProjectDirectory { get; set; }
|
public string ProjectDirectory { get; set; }
|
||||||
|
|
||||||
public string Configuration { get; set; }
|
public string Configuration { get; set; }
|
||||||
|
|
|
@ -37,7 +37,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
IPlatformCommandSpecFactory platformCommandSpecFactory) : base()
|
IPlatformCommandSpecFactory platformCommandSpecFactory) : base()
|
||||||
{
|
{
|
||||||
AddCommandResolver(new RootedCommandResolver());
|
AddCommandResolver(new RootedCommandResolver());
|
||||||
AddCommandResolver(new ProjectDependenciesCommandResolver(environment, packagedCommandSpecFactory));
|
|
||||||
AddCommandResolver(new ProjectToolsCommandResolver(packagedCommandSpecFactory));
|
AddCommandResolver(new ProjectToolsCommandResolver(packagedCommandSpecFactory));
|
||||||
AddCommandResolver(new AppBaseCommandResolver(environment, platformCommandSpecFactory));
|
AddCommandResolver(new AppBaseCommandResolver(environment, platformCommandSpecFactory));
|
||||||
AddCommandResolver(new PathCommandResolver(environment, platformCommandSpecFactory));
|
AddCommandResolver(new PathCommandResolver(environment, platformCommandSpecFactory));
|
||||||
|
|
|
@ -52,7 +52,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
commandResolverArguments.Framework,
|
commandResolverArguments.Framework,
|
||||||
commandResolverArguments.Configuration,
|
commandResolverArguments.Configuration,
|
||||||
commandResolverArguments.CommandName,
|
commandResolverArguments.CommandName,
|
||||||
commandResolverArguments.CommandArguments);
|
commandResolverArguments.CommandArguments,
|
||||||
|
commandResolverArguments.OutputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandSpec ResolveFromProjectDependencies(
|
private CommandSpec ResolveFromProjectDependencies(
|
||||||
|
@ -60,7 +61,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
NuGetFramework framework,
|
NuGetFramework framework,
|
||||||
string configuration,
|
string configuration,
|
||||||
string commandName,
|
string commandName,
|
||||||
IEnumerable<string> commandArguments)
|
IEnumerable<string> commandArguments,
|
||||||
|
string outputPath)
|
||||||
{
|
{
|
||||||
var allowedExtensions = GetAllowedCommandExtensionsFromEnvironment(_environment);
|
var allowedExtensions = GetAllowedCommandExtensionsFromEnvironment(_environment);
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var depsFilePath = projectContext.GetOutputPaths(configuration).RuntimeFiles.Deps;
|
var depsFilePath = projectContext.GetOutputPaths(configuration, outputPath: outputPath).RuntimeFiles.Deps;
|
||||||
|
|
||||||
var dependencyLibraries = GetAllDependencyLibraries(projectContext);
|
var dependencyLibraries = GetAllDependencyLibraries(projectContext);
|
||||||
|
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
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;
|
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
using NuGet.Frameworks;
|
|
||||||
using NuGet.Packaging;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
|
||||||
{
|
|
||||||
public class ProjectToolsCommandResolver : ICommandResolver
|
|
||||||
{
|
|
||||||
private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.DnxCore50;
|
|
||||||
private static readonly CommandResolutionStrategy s_commandResolutionStrategy =
|
|
||||||
CommandResolutionStrategy.ProjectToolsPackage;
|
|
||||||
|
|
||||||
private List<string> _allowedCommandExtensions;
|
|
||||||
private IPackagedCommandSpecFactory _packagedCommandSpecFactory;
|
|
||||||
|
|
||||||
public ProjectToolsCommandResolver(IPackagedCommandSpecFactory packagedCommandSpecFactory)
|
|
||||||
{
|
|
||||||
_packagedCommandSpecFactory = packagedCommandSpecFactory;
|
|
||||||
|
|
||||||
_allowedCommandExtensions = new List<string>()
|
|
||||||
{
|
|
||||||
FileNameSuffixes.DotNet.DynamicLib
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments)
|
|
||||||
{
|
|
||||||
return ResolveFromProjectTools(
|
|
||||||
commandResolverArguments.CommandName,
|
|
||||||
commandResolverArguments.CommandArguments,
|
|
||||||
commandResolverArguments.ProjectDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandSpec ResolveFromProjectTools(
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
string projectDirectory)
|
|
||||||
{
|
|
||||||
var projectContext = GetProjectContextFromDirectory(projectDirectory, s_toolPackageFramework);
|
|
||||||
|
|
||||||
if (projectContext == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var toolsLibraries = projectContext.ProjectFile.Tools.EmptyIfNull();
|
|
||||||
|
|
||||||
return ResolveCommandSpecFromAllToolLibraries(
|
|
||||||
toolsLibraries,
|
|
||||||
commandName,
|
|
||||||
args,
|
|
||||||
projectContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandSpec ResolveCommandSpecFromAllToolLibraries(
|
|
||||||
IEnumerable<LibraryRange> toolsLibraries,
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
ProjectContext projectContext)
|
|
||||||
{
|
|
||||||
foreach (var toolLibrary in toolsLibraries)
|
|
||||||
{
|
|
||||||
var commandSpec = ResolveCommandSpecFromToolLibrary(toolLibrary, commandName, args, projectContext);
|
|
||||||
|
|
||||||
if (commandSpec != null)
|
|
||||||
{
|
|
||||||
return commandSpec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandSpec ResolveCommandSpecFromToolLibrary(
|
|
||||||
LibraryRange toolLibrary,
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
ProjectContext projectContext)
|
|
||||||
{
|
|
||||||
//todo: change this for new resolution strategy
|
|
||||||
var lockFilePath = Path.Combine(
|
|
||||||
projectContext.ProjectDirectory,
|
|
||||||
"artifacts", "Tools", toolLibrary.Name,
|
|
||||||
"project.lock.json");
|
|
||||||
|
|
||||||
if (!File.Exists(lockFilePath))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var lockFile = LockFileReader.Read(lockFilePath);
|
|
||||||
|
|
||||||
var lockFilePackageLibrary = lockFile.PackageLibraries.FirstOrDefault(l => l.Name == toolLibrary.Name);
|
|
||||||
|
|
||||||
var nugetPackagesRoot = projectContext.PackagesDirectory;
|
|
||||||
|
|
||||||
return _packagedCommandSpecFactory.CreateCommandSpecFromLibrary(
|
|
||||||
lockFilePackageLibrary,
|
|
||||||
commandName,
|
|
||||||
args,
|
|
||||||
_allowedCommandExtensions,
|
|
||||||
projectContext.PackagesDirectory,
|
|
||||||
s_commandResolutionStrategy,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProjectContext GetProjectContextFromDirectory(string directory, NuGetFramework framework)
|
|
||||||
{
|
|
||||||
if (directory == null || framework == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var projectRootPath = directory;
|
|
||||||
|
|
||||||
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var projectContext = ProjectContext.Create(
|
|
||||||
projectRootPath,
|
|
||||||
framework,
|
|
||||||
PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
|
|
||||||
|
|
||||||
if (projectContext.RuntimeIdentifier == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectContext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,128 +13,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
{
|
{
|
||||||
internal static class CommandResolver
|
internal static class CommandResolver
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
public static CommandSpec TryResolveCommandSpec(
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
NuGetFramework framework = null,
|
|
||||||
string configuration = Constants.DefaultConfiguration,
|
|
||||||
string outputPath = null)
|
|
||||||
{
|
|
||||||
return ResolveFromRootedCommand(commandName, args) ??
|
|
||||||
ResolveFromProjectDependencies(commandName, args, framework, configuration, outputPath) ??
|
|
||||||
ResolveFromProjectTools(commandName, args) ??
|
|
||||||
ResolveFromAppBase(commandName, args) ??
|
|
||||||
ResolveFromPath(commandName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandSpec TryResolveScriptCommandSpec(string commandName, IEnumerable<string> args, Project project, string[] inferredExtensionList)
|
|
||||||
{
|
|
||||||
return ResolveFromRootedCommand(commandName, args) ??
|
|
||||||
ResolveFromProjectPath(commandName, args, project, inferredExtensionList) ??
|
|
||||||
ResolveFromAppBase(commandName, args) ??
|
|
||||||
ResolveFromPath(commandName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static CommandSpec ResolveFromPath(string commandName, IEnumerable<string> args)
|
|
||||||
{
|
|
||||||
var commandPath = Env.GetCommandPath(commandName);
|
|
||||||
return commandPath == null
|
|
||||||
? null
|
|
||||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.Path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CommandSpec ResolveFromAppBase(string commandName, IEnumerable<string> args)
|
|
||||||
{
|
|
||||||
var commandPath = Env.GetCommandPathFromRootPath(PlatformServices.Default.Application.ApplicationBasePath, commandName);
|
|
||||||
return commandPath == null
|
|
||||||
? null
|
|
||||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CommandSpec ResolveFromProjectPath(string commandName, IEnumerable<string> args, Project project, string[] inferredExtensionList)
|
|
||||||
{
|
|
||||||
var commandPath = Env.GetCommandPathFromRootPath(project.ProjectDirectory, commandName, inferredExtensionList);
|
|
||||||
return commandPath == null
|
|
||||||
? null
|
|
||||||
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.ProjectLocal);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CommandSpec ResolveFromRootedCommand(string commandName, IEnumerable<string> args)
|
|
||||||
{
|
|
||||||
if (Path.IsPathRooted(commandName))
|
|
||||||
{
|
|
||||||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
|
||||||
return new CommandSpec(commandName, escapedArgs, CommandResolutionStrategy.Path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandSpec ResolveFromProjectDependencies(
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
NuGetFramework framework,
|
|
||||||
string configuration,
|
|
||||||
string outputPath)
|
|
||||||
{
|
|
||||||
if (framework == null) return null;
|
|
||||||
|
|
||||||
var projectContext = GetProjectContext(framework);
|
|
||||||
|
|
||||||
if (projectContext == null) return null;
|
|
||||||
|
|
||||||
var commandPackage = GetCommandPackage(projectContext, commandName);
|
|
||||||
|
|
||||||
if (commandPackage == null) return null;
|
|
||||||
|
|
||||||
var depsPath = projectContext.GetOutputPaths(configuration, outputPath: outputPath).RuntimeFiles.Deps;
|
|
||||||
|
|
||||||
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ProjectContext GetProjectContext(NuGetFramework framework)
|
|
||||||
{
|
|
||||||
var projectRootPath = Directory.GetCurrentDirectory();
|
|
||||||
|
|
||||||
if (!File.Exists(Path.Combine(projectRootPath, Project.FileName)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var projectContext = ProjectContext.Create(projectRootPath, framework, PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers());
|
|
||||||
return projectContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PackageDescription GetCommandPackage(ProjectContext projectContext, string commandName)
|
|
||||||
{
|
|
||||||
return projectContext.LibraryManager.GetLibraries()
|
|
||||||
.Where(l => l.GetType() == typeof(PackageDescription))
|
|
||||||
.Select(l => l as PackageDescription)
|
|
||||||
.FirstOrDefault(p => p.Library.Files
|
|
||||||
.Select(Path.GetFileName)
|
|
||||||
.Where(f => Path.GetFileNameWithoutExtension(f) == commandName)
|
|
||||||
.Select(Path.GetExtension)
|
|
||||||
.Any(e => Env.ExecutableExtensions.Contains(e) ||
|
|
||||||
e == FileNameSuffixes.DotNet.DynamicLib));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandSpec ResolveFromProjectTools(string commandName, IEnumerable<string> args)
|
|
||||||
{
|
|
||||||
var context = GetProjectContext(FrameworkConstants.CommonFrameworks.NetStandardApp15);
|
|
||||||
|
|
||||||
if (context == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var commandLibrary = context.ProjectFile.Tools
|
|
||||||
.FirstOrDefault(l => l.Name == commandName);
|
|
||||||
=======
|
|
||||||
private static DefaultCommandResolver _defaultCommandResolver;
|
private static DefaultCommandResolver _defaultCommandResolver;
|
||||||
private static ScriptCommandResolver _scriptCommandResolver;
|
private static ScriptCommandResolver _scriptCommandResolver;
|
||||||
>>>>>>> 9c4329a... Refactor CommandResolver into individual CommandResolver Implementation
|
|
||||||
|
|
||||||
public static CommandSpec TryResolveCommandSpec(
|
public static CommandSpec TryResolveCommandSpec(
|
||||||
string commandName,
|
string commandName,
|
||||||
|
@ -149,7 +29,8 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
CommandArguments = args,
|
CommandArguments = args,
|
||||||
Framework = framework,
|
Framework = framework,
|
||||||
ProjectDirectory = Directory.GetCurrentDirectory(),
|
ProjectDirectory = Directory.GetCurrentDirectory(),
|
||||||
Configuration = configuration
|
Configuration = configuration,
|
||||||
|
OutputPath = outputPath
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_defaultCommandResolver == null)
|
if (_defaultCommandResolver == null)
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
// 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 System.Collections.Generic;
|
|
||||||
using NuGet.Frameworks;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Utils
|
|
||||||
{
|
|
||||||
public class FixedPathCommandFactory : ICommandFactory
|
|
||||||
{
|
|
||||||
private readonly NuGetFramework _nugetFramework;
|
|
||||||
private readonly string _configuration;
|
|
||||||
private readonly string _outputPath;
|
|
||||||
|
|
||||||
public FixedPathCommandFactory(NuGetFramework nugetFramework, string configuration, string outputPath)
|
|
||||||
{
|
|
||||||
_nugetFramework = nugetFramework;
|
|
||||||
_configuration = configuration;
|
|
||||||
_outputPath = outputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommand Create(
|
|
||||||
string commandName,
|
|
||||||
IEnumerable<string> args,
|
|
||||||
NuGetFramework framework = null,
|
|
||||||
string configuration = Constants.DefaultConfiguration)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(configuration))
|
|
||||||
{
|
|
||||||
configuration = _configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (framework == null)
|
|
||||||
{
|
|
||||||
framework = _nugetFramework;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Command.Create(commandName, args, framework, configuration, _outputPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
// 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 System.Collections.Generic;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
{
|
||||||
|
public class ProjectDependenciesCommandFactory : ICommandFactory
|
||||||
|
{
|
||||||
|
private readonly NuGetFramework _nugetFramework;
|
||||||
|
private readonly string _configuration;
|
||||||
|
private readonly string _outputPath;
|
||||||
|
private readonly string _projectDirectory;
|
||||||
|
|
||||||
|
public ProjectDependenciesCommandFactory(
|
||||||
|
NuGetFramework nugetFramework,
|
||||||
|
string configuration,
|
||||||
|
string outputPath,
|
||||||
|
string projectDirectory)
|
||||||
|
{
|
||||||
|
_nugetFramework = nugetFramework;
|
||||||
|
_configuration = configuration;
|
||||||
|
_outputPath = outputPath;
|
||||||
|
_projectDirectory = projectDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand Create(
|
||||||
|
string commandName,
|
||||||
|
IEnumerable<string> args,
|
||||||
|
NuGetFramework framework = null,
|
||||||
|
string configuration = Constants.DefaultConfiguration)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(configuration))
|
||||||
|
{
|
||||||
|
configuration = _configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (framework == null)
|
||||||
|
{
|
||||||
|
framework = _nugetFramework;
|
||||||
|
}
|
||||||
|
|
||||||
|
var commandSpec = FindProjectDependencyCommands(
|
||||||
|
commandName,
|
||||||
|
args,
|
||||||
|
configuration,
|
||||||
|
framework,
|
||||||
|
_outputPath,
|
||||||
|
_projectDirectory);
|
||||||
|
|
||||||
|
return Command.Create(commandSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandSpec FindProjectDependencyCommands(
|
||||||
|
string commandName,
|
||||||
|
IEnumerable<string> commandArgs,
|
||||||
|
string configuration,
|
||||||
|
NuGetFramework framework,
|
||||||
|
string outputPath,
|
||||||
|
string projectDirectory)
|
||||||
|
{
|
||||||
|
var commandResolverArguments = new CommandResolverArguments
|
||||||
|
{
|
||||||
|
CommandName = commandName,
|
||||||
|
CommandArguments = commandArgs,
|
||||||
|
Framework = framework,
|
||||||
|
Configuration = configuration,
|
||||||
|
OutputPath = outputPath,
|
||||||
|
ProjectDirectory = projectDirectory
|
||||||
|
};
|
||||||
|
|
||||||
|
var commandResolver = GetProjectDependenciesCommandResolver();
|
||||||
|
|
||||||
|
var commandSpec = commandResolver.Resolve(commandResolverArguments);
|
||||||
|
if (commandSpec == null)
|
||||||
|
{
|
||||||
|
throw new CommandUnknownException(commandName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return commandSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICommandResolver GetProjectDependenciesCommandResolver()
|
||||||
|
{
|
||||||
|
var environment = new EnvironmentProvider();
|
||||||
|
var packagedCommandSpecFactory = new PackagedCommandSpecFactory();
|
||||||
|
|
||||||
|
return new ProjectDependenciesCommandResolver(environment, packagedCommandSpecFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -102,12 +102,19 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
var commandArgs = new List<string> { GetAssemblyUnderTest(projectContext, configuration, outputPath) };
|
var commandArgs = new List<string> { GetAssemblyUnderTest(projectContext, configuration, outputPath) };
|
||||||
commandArgs.AddRange(app.RemainingArguments);
|
commandArgs.AddRange(app.RemainingArguments);
|
||||||
|
|
||||||
return Command.Create(
|
var commandFactory =
|
||||||
|
new ProjectDependenciesCommandFactory(
|
||||||
|
projectContext.TargetFramework,
|
||||||
|
configuration,
|
||||||
|
outputPath,
|
||||||
|
projectContext.ProjectDirectory);
|
||||||
|
|
||||||
|
|
||||||
|
return commandFactory.Create(
|
||||||
$"dotnet-{GetCommandName(testRunner)}",
|
$"dotnet-{GetCommandName(testRunner)}",
|
||||||
commandArgs,
|
commandArgs,
|
||||||
projectContext.TargetFramework,
|
projectContext.TargetFramework,
|
||||||
configuration: configuration,
|
configuration)
|
||||||
outputPath: outputPath)
|
|
||||||
.ForwardStdErr()
|
.ForwardStdErr()
|
||||||
.ForwardStdOut()
|
.ForwardStdOut()
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -159,8 +166,13 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
var messages = new TestMessagesCollection();
|
var messages = new TestMessagesCollection();
|
||||||
using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
|
using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
|
||||||
{
|
{
|
||||||
var commandFactory =
|
var commandFactory =
|
||||||
new FixedPathCommandFactory(projectContext.TargetFramework, configuration, outputPath);
|
new ProjectDependenciesCommandFactory(
|
||||||
|
projectContext.TargetFramework,
|
||||||
|
configuration,
|
||||||
|
outputPath,
|
||||||
|
projectContext.ProjectDirectory);
|
||||||
|
|
||||||
var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);
|
var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);
|
||||||
|
|
||||||
dotnetTest
|
dotnetTest
|
||||||
|
|
|
@ -28,179 +28,17 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
|
|
||||||
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
var resolvers = defaultCommandResolver.OrderedCommandResolvers;
|
||||||
|
|
||||||
resolvers.Should().HaveCount(5);
|
resolvers.Should().HaveCount(4);
|
||||||
|
|
||||||
resolvers.Select(r => r.GetType())
|
resolvers.Select(r => r.GetType())
|
||||||
.Should()
|
.Should()
|
||||||
.ContainInOrder(
|
.ContainInOrder(
|
||||||
new []{
|
new []{
|
||||||
typeof(RootedCommandResolver),
|
typeof(RootedCommandResolver),
|
||||||
typeof(ProjectDependenciesCommandResolver),
|
|
||||||
typeof(ProjectToolsCommandResolver),
|
typeof(ProjectToolsCommandResolver),
|
||||||
typeof(AppBaseCommandResolver),
|
typeof(AppBaseCommandResolver),
|
||||||
typeof(PathCommandResolver)
|
typeof(PathCommandResolver)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_Rooted_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory, "rooteddir");
|
|
||||||
// Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".dll", "rootedcommand");
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandPath,
|
|
||||||
// CommandArguments = new string[] {}
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.RootedPath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_AppBase_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var testCommandPath = CreateTestCommandFile(AppContext.BaseDirectory, ".exe", "appbasecommand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.BaseDirectory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_PATH_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory, "pathdir");
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".dll", "pathcommmand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// Mock<IEnvironmentProvider> mockEnvironment = new Mock<IEnvironmentProvider>();
|
|
||||||
// mockEnvironment.Setup(c => c
|
|
||||||
// .GetCommandPath(It.IsAny<string>(), It.IsAny<string[]>()))
|
|
||||||
// .Returns(testCommandPath);
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// Environment = mockEnvironment.Object
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.Path);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_Project_Tools_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var testAppPath = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "TestAssets/TestProjects/AppWithToolDependency");
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = "dotnet-hello",
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = testAppPath,
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().NotBeNull();
|
|
||||||
// commandSpec.Args.Should().NotContain("--depsfile");
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.NugetPackage);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_Project_Dependencies_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var testAppPath = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "TestAssets/TestProjects/AppWithDirectDependency");
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = "dotnet-hello",
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = testAppPath,
|
|
||||||
// Environment = new EnvironmentProvider(),
|
|
||||||
// Framework = FrameworkConstants.CommonFrameworks.DnxCore50,
|
|
||||||
// Configuration = "Debug"
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().NotBeNull();
|
|
||||||
// commandSpec.Args.Should().Contain("--depsfile");
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.NugetPackage);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_does_not_resolve_ProjectLocal_commands()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "testdir");
|
|
||||||
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".exe", "projectlocalcommand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// var defaultCommandResolver = new DefaultCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = path,
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = defaultCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
|
|
||||||
// commandSpec.Should().Be(null);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public string CreateTestCommandFile(string path, string extension, string name = "testcommand")
|
|
||||||
// {
|
|
||||||
// Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
// var filename = name + extension;
|
|
||||||
// var filepath = Path.Combine(path, filename);
|
|
||||||
|
|
||||||
// File.WriteAllText(filepath, "hello world");
|
|
||||||
|
|
||||||
// return filepath;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,160 +40,5 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
|
||||||
typeof(PathCommandResolver)
|
typeof(PathCommandResolver)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_Rooted_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory, "rooteddir");
|
|
||||||
// Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".dll", "scriptrootedcommand");
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandPath,
|
|
||||||
// CommandArguments = new string[] {}
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.RootedPath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_AppBase_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var testCommandPath = CreateTestCommandFile(AppContext.BaseDirectory, ".exe", "scriptappbasecommand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.BaseDirectory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_Resolves_PATH_Commands_Correctly()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory, "pathdir");
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".dll", "scriptpathcommmand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// Mock<IEnvironmentProvider> mockEnvironment = new Mock<IEnvironmentProvider>();
|
|
||||||
// mockEnvironment.Setup(c => c
|
|
||||||
// .GetCommandPath(It.IsAny<string>(), It.IsAny<string[]>()))
|
|
||||||
// .Returns(testCommandPath);
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// Environment = mockEnvironment.Object
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.Path);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_does_NOT_Resolve_Project_Tools_Commands()
|
|
||||||
// {
|
|
||||||
// var testAppPath = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "TestAssets/TestProjects/AppWithToolDependency");
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = "dotnet-hello",
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = testAppPath,
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().BeNull();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_does_NOT_Resolve_Project_Dependencies_Commands()
|
|
||||||
// {
|
|
||||||
// var testAppPath = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "TestAssets/TestProjects/AppWithDirectDependency");
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = "dotnet-hello",
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = testAppPath,
|
|
||||||
// Environment = new EnvironmentProvider(),
|
|
||||||
// Framework = FrameworkConstants.CommonFrameworks.DnxCore50,
|
|
||||||
// Configuration = "Debug"
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
// commandSpec.Should().BeNull();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
|
||||||
// public void It_resolves_ProjectLocal_commands_correctly()
|
|
||||||
// {
|
|
||||||
// var path = Path.Combine(AppContext.BaseDirectory,
|
|
||||||
// "testdir");
|
|
||||||
|
|
||||||
// var testCommandPath = CreateTestCommandFile(path, ".exe", "scriptprojectlocalcommand");
|
|
||||||
// var testCommandName = Path.GetFileNameWithoutExtension(testCommandPath);
|
|
||||||
|
|
||||||
// var scriptCommandResolver = new ScriptCommandResolver();
|
|
||||||
|
|
||||||
// var commandResolverArgs = new CommandResolverArguments
|
|
||||||
// {
|
|
||||||
// CommandName = testCommandName,
|
|
||||||
// CommandArguments = new string[] {},
|
|
||||||
// ProjectDirectory = path,
|
|
||||||
// Environment = new EnvironmentProvider()
|
|
||||||
// };
|
|
||||||
|
|
||||||
// var commandSpec = scriptCommandResolver.Resolve(commandResolverArgs);
|
|
||||||
|
|
||||||
// commandSpec.Should().NotBeNull();
|
|
||||||
// commandSpec.Path.Should().Be(testCommandPath);
|
|
||||||
// commandSpec.ResolutionStrategy.Should().Be(CommandResolutionStrategy.ProjectLocal);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public string CreateTestCommandFile(string path, string extension, string name = "testcommand")
|
|
||||||
// {
|
|
||||||
// Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
// var filename = name + extension;
|
|
||||||
// var filepath = Path.Combine(path, filename);
|
|
||||||
|
|
||||||
// File.WriteAllText(filepath, "hello world");
|
|
||||||
|
|
||||||
// return filepath;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
return new AndConstraint<CommandResultAssertions>(this);
|
return new AndConstraint<CommandResultAssertions>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AndConstraint<CommandResultAssertions> NotPass()
|
||||||
|
{
|
||||||
|
Execute.Assertion.ForCondition(_commandResult.ExitCode != 0)
|
||||||
|
.FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not."));
|
||||||
|
return new AndConstraint<CommandResultAssertions>(this);
|
||||||
|
}
|
||||||
|
|
||||||
public AndConstraint<CommandResultAssertions> Fail()
|
public AndConstraint<CommandResultAssertions> Fail()
|
||||||
{
|
{
|
||||||
Execute.Assertion.ForCondition(_commandResult.ExitCode != 0)
|
Execute.Assertion.ForCondition(_commandResult.ExitCode != 0)
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using FluentAssertions;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tests
|
namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
|
@ -20,11 +21,10 @@ namespace Microsoft.DotNet.Tests
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("AppWithDirectAndToolDependency")]
|
[InlineData("AppWithDirectAndToolDependency")]
|
||||||
[InlineData("AppWithDirectDependency")]
|
|
||||||
[InlineData("AppWithToolDependency")]
|
[InlineData("AppWithToolDependency")]
|
||||||
public void TestPackagedCommandDependency(string appName)
|
public void TestProjectToolIsAvailableThroughDriver(string appName)
|
||||||
{
|
{
|
||||||
string appDirectory = Path.Combine(_testProjectsRoot, appName);
|
var appDirectory = Path.Combine(_testProjectsRoot, appName);
|
||||||
|
|
||||||
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
.Execute()
|
.Execute()
|
||||||
|
@ -38,7 +38,7 @@ namespace Microsoft.DotNet.Tests
|
||||||
{
|
{
|
||||||
CommandResult result = new HelloCommand().ExecuteWithCapturedOutput();
|
CommandResult result = new HelloCommand().ExecuteWithCapturedOutput();
|
||||||
|
|
||||||
result.Should().HaveStdOut("Hello" + Environment.NewLine);
|
result.Should().HaveStdOut("Hello World!" + Environment.NewLine);
|
||||||
result.Should().NotHaveStdErr();
|
result.Should().NotHaveStdErr();
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,33 @@ namespace Microsoft.DotNet.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestProjectDependencyIsNotAvailableThroughDriver()
|
||||||
|
{
|
||||||
|
var appName = "AppWithDirectDependency";
|
||||||
|
var appDirectory = Path.Combine(_testProjectsRoot, appName);
|
||||||
|
|
||||||
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
|
var currentDirectory = Directory.GetCurrentDirectory();
|
||||||
|
Directory.SetCurrentDirectory(appDirectory);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CommandResult result = new HelloCommand().ExecuteWithCapturedOutput();
|
||||||
|
|
||||||
|
result.StdOut.Should().Contain("No executable found matching command");
|
||||||
|
result.Should().NotPass();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Directory.SetCurrentDirectory(currentDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class HelloCommand : TestCommand
|
class HelloCommand : TestCommand
|
||||||
{
|
{
|
||||||
public HelloCommand()
|
public HelloCommand()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue