public void It_returns_a_CommandSpec_with_CommandName_as_FileName_when_CommandName_exists_in_PATH() { var testCommandPath = CommandResolverTestUtils.CreateNonRunnableTestCommand( s_testDirectory, "pathtestcommand1", ".exe"); var staticPathEnvironmentMock = new Mock<IEnvironmentProvider>(); staticPathEnvironmentMock.Setup(e => e .GetCommandPath(It.IsAny<string>(), It.IsAny<string[]>())) .Returns(testCommandPath); var pathCommandResolver = SetupPlatformPathCommandResolver(staticPathEnvironmentMock.Object, forceGeneric: true); var commandResolverArguments = new CommandResolverArguments() { CommandName = Path.GetFileNameWithoutExtension(testCommandPath), CommandArguments = null }; var result = pathCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); var commandFile = Path.GetFileNameWithoutExtension(result.Path); commandFile.Should().Be(Path.GetFileNameWithoutExtension(testCommandPath)); }
private CommandSpec FindProjectDependencyCommands( string commandName, IEnumerable<string> commandArgs, string configuration, NuGetFramework framework, string outputPath, string buildBasePath, string projectDirectory) { var commandResolverArguments = new CommandResolverArguments { CommandName = commandName, CommandArguments = commandArgs, Framework = framework, Configuration = configuration, OutputPath = outputPath, BuildBasePath = buildBasePath, ProjectDirectory = projectDirectory }; var commandResolver = GetProjectDependenciesCommandResolver(); var commandSpec = commandResolver.Resolve(commandResolverArguments); if (commandSpec == null) { throw new CommandUnknownException(commandName); } return commandSpec; }
internal override string ResolveCommandPath(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.ProjectDirectory == null) { return null; } return _environment.GetCommandPathFromRootPath( commandResolverArguments.ProjectDirectory, commandResolverArguments.CommandName, commandResolverArguments.InferredExtensions.OrEmptyIfNull()); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null || commandResolverArguments.ProjectDirectory == null) { return null; } return ResolveFromProjectTools( commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandResolverArguments.ProjectDirectory); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null || commandResolverArguments.DepsJsonFile == null) { return null; } return ResolveFromDepsJsonFile( commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandResolverArguments.DepsJsonFile); }
public void It_returns_null_when_CommandName_is_null() { var pathCommandResolver = SetupPlatformPathCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = null, CommandArguments = null }; var result = pathCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_null_when_CommandName_is_null() { var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(forceGeneric: true); var commandResolverArguments = new CommandResolverArguments() { CommandName = null, CommandArguments = null }; var result = appBaseCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { foreach (var commandResolver in _orderedCommandResolvers) { var commandSpec = commandResolver.Resolve(commandResolverArguments); if (commandSpec != null) { return commandSpec; } } return null; }
public void It_returns_null_when_CommandName_does_not_exist_applocal() { var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(forceGeneric: true); var commandResolverArguments = new CommandResolverArguments() { CommandName = "nonexistent-command", CommandArguments = null }; var result = appBaseCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_null_when_CommandName_is_not_rooted() { var rootedCommandResolver = new RootedCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "some/relative/path", CommandArguments = null }; var result = rootedCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_null_when_CommandName_does_not_exist_in_ProjectDirectory() { var projectPathCommandResolver = SetupPlatformProjectPathCommandResolver(forceGeneric: true); var commandResolverArguments = new CommandResolverArguments() { CommandName = "nonexistent-command", CommandArguments = null, ProjectDirectory = s_testProjectDirectory }; var result = projectPathCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_null_when_CommandName_does_not_exist_in_ProjectTools() { var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "nonexistent-command", CommandArguments = null, ProjectDirectory = s_liveProjectDirectory }; var result = projectToolsCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_a_CommandSpec_with_CommandName_as_Path_when_CommandName_is_rooted() { var rootedCommandResolver = new RootedCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "/some/rooted/path", CommandArguments = null }; var result = rootedCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); result.Path.Should().Be(commandResolverArguments.CommandName); }
public void It_returns_null_when_CommandName_is_null() { var projectToolsCommandResolver = SetupProjectToolsCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = null, CommandArguments = new string[] {""}, ProjectDirectory = "/some/directory" }; var result = projectToolsCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_returns_null_when_ProjectDirectory_is_null() { var projectPathCommandResolver = SetupPlatformProjectPathCommandResolver(forceGeneric: true); var commandResolverArguments = new CommandResolverArguments() { CommandName = "command", CommandArguments = new string[] {""}, ProjectDirectory = null }; var result = projectPathCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public void It_escapes_CommandArguments_when_returning_a_CommandSpec() { var rootedCommandResolver = new RootedCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "/some/rooted/path", CommandArguments = new [] { "arg with space"} }; var result = rootedCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); result.Path.Should().Be(commandResolverArguments.CommandName); result.Args.Should().Be("\"arg with space\""); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null) { return null; } if (Path.IsPathRooted(commandResolverArguments.CommandName)) { var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart( commandResolverArguments.CommandArguments.OrEmptyIfNull()); return new CommandSpec(commandResolverArguments.CommandName, escapedArgs, CommandResolutionStrategy.RootedPath); } return null; }
public void It_returns_null_when_Framework_is_null() { var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "command", CommandArguments = new string[] {""}, ProjectDirectory = s_liveProjectDirectory, Configuration = "Debug", Framework = null }; var result = projectDependenciesCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public ICommand Create( string commandName, IEnumerable<string> args, NuGetFramework framework = null, string configuration = Constants.DefaultConfiguration) { var commandResolverArgs = new CommandResolverArguments() { CommandName = commandName, CommandArguments = args, DepsJsonFile = _depsJsonFile }; var commandSpec = _depsJsonCommandResolver.Resolve(commandResolverArgs); return Command.Create(commandSpec); }
public void It_returns_null_when_ProjectDirectory_is_null() { var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "command", CommandArguments = new string[] {""}, ProjectDirectory = null, Configuration = "Debug", Framework = FrameworkConstants.CommonFrameworks.NetStandardApp15 }; var result = projectDependenciesCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
public static CommandSpec TryResolveScriptCommandSpec( string commandName, IEnumerable<string> args, Project project, string[] inferredExtensionList) { var commandResolverArgs = new CommandResolverArguments { CommandName = commandName, CommandArguments = args, ProjectDirectory = project.ProjectDirectory, InferredExtensions = inferredExtensionList }; var scriptCommandResolver = ScriptCommandResolverPolicy.Create(); return scriptCommandResolver.Resolve(commandResolverArgs); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.Framework == null || commandResolverArguments.ProjectDirectory == null || commandResolverArguments.Configuration == null || commandResolverArguments.CommandName == null) { return null; } return ResolveFromProjectDependencies( commandResolverArguments.ProjectDirectory, commandResolverArguments.Framework, commandResolverArguments.Configuration, commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandResolverArguments.OutputPath); }
public void It_returns_null_when_CommandName_does_not_exist_in_PATH() { var emptyPathEnvironmentMock = new Mock<IEnvironmentProvider>(); emptyPathEnvironmentMock.Setup(e => e .GetCommandPath(It.IsAny<string>(), It.IsAny<string[]>())) .Returns((string)null); var pathCommandResolver = SetupPlatformPathCommandResolver(emptyPathEnvironmentMock.Object); var commandResolverArguments = new CommandResolverArguments() { CommandName = "nonexistent-command", CommandArguments = null }; var result = pathCommandResolver.Resolve(commandResolverArguments); result.Should().BeNull(); }
internal override string ResolveCommandPath(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.Framework == null || commandResolverArguments.ProjectDirectory == null || commandResolverArguments.Configuration == null || commandResolverArguments.CommandName == null) { return null; } return ResolveFromProjectOutput( commandResolverArguments.ProjectDirectory, commandResolverArguments.Framework, commandResolverArguments.Configuration, commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandResolverArguments.OutputPath, commandResolverArguments.BuildBasePath); }
public static CommandSpec TryResolveCommandSpec( string commandName, IEnumerable<string> args, NuGetFramework framework = null, string configuration=Constants.DefaultConfiguration, string outputPath=null) { var commandResolverArgs = new CommandResolverArguments { CommandName = commandName, CommandArguments = args, Framework = framework, ProjectDirectory = Directory.GetCurrentDirectory(), Configuration = configuration, OutputPath = outputPath }; var defaultCommandResolver = DefaultCommandResolverPolicy.Create(); return defaultCommandResolver.Resolve(commandResolverArgs); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null) { return null; } var commandPath = ResolveCommandPath(commandResolverArguments); if (commandPath == null) { return null; } return _commandSpecFactory.CreateCommandSpec( commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandPath, GetCommandResolutionStrategy(), _environment); }
public static CommandSpec TryResolveCommandSpec( string commandName, IEnumerable <string> args, NuGetFramework framework = null, string configuration = Constants.DefaultConfiguration, string outputPath = null) { var commandResolverArgs = new CommandResolverArguments { CommandName = commandName, CommandArguments = args, Framework = framework, ProjectDirectory = Directory.GetCurrentDirectory(), Configuration = configuration, OutputPath = outputPath }; var defaultCommandResolver = DefaultCommandResolverPolicy.Create(); return(defaultCommandResolver.Resolve(commandResolverArgs)); }
public void It_returns_a_CommandSpec_with_CommandName_as_FileName_when_CommandName_exists_applocal() { var environment = CommandResolverTestUtils.SetupEnvironmentProviderWhichFindsExtensions(".exe"); var appBaseCommandResolver = SetupPlatformAppBaseCommandResolver(environment, forceGeneric: true); CommandResolverTestUtils.CreateNonRunnableTestCommand(AppContext.BaseDirectory, "appbasetestcommand1", ".exe"); var commandResolverArguments = new CommandResolverArguments() { CommandName = "appbasetestcommand1", CommandArguments = null }; var result = appBaseCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); var commandFile = Path.GetFileNameWithoutExtension(result.Path); commandFile.Should().Be("appbasetestcommand1"); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null) { return(null); } var commandPath = ResolveCommandPath(commandResolverArguments); if (commandPath == null) { return(null); } return(_commandSpecFactory.CreateCommandSpec( commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandPath, GetCommandResolutionStrategy(), _environment)); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null) { return(null); } if (commandResolverArguments.CommandName.EndsWith(FileNameSuffixes.DotNet.DynamicLib)) { var localPath = Path.Combine(ApplicationEnvironment.ApplicationBasePath, commandResolverArguments.CommandName); if (File.Exists(localPath)) { var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart( new[] { localPath } .Concat(commandResolverArguments.CommandArguments.OrEmptyIfNull())); return(new CommandSpec( new Muxer().MuxerPath, escapedArgs)); } } return(null); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: attempting to resolve {commandResolverArguments.CommandName}"); if (commandResolverArguments.Framework == null || commandResolverArguments.ProjectDirectory == null || commandResolverArguments.Configuration == null || commandResolverArguments.CommandName == null) { Reporter.Verbose.WriteLine($"projectdependenciescommandresolver: invalid commandResolverArguments"); return(null); } return(ResolveFromProjectDependencies( commandResolverArguments.ProjectDirectory, commandResolverArguments.Framework, commandResolverArguments.Configuration, commandResolverArguments.CommandName, commandResolverArguments.CommandArguments.OrEmptyIfNull(), commandResolverArguments.OutputPath, commandResolverArguments.BuildBasePath)); }
public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { if (commandResolverArguments.CommandName == null) { return null; } if (commandResolverArguments.CommandName.EndsWith(FileNameSuffixes.DotNet.DynamicLib)) { var localPath = Path.Combine(ApplicationEnvironment.ApplicationBasePath, commandResolverArguments.CommandName); if (File.Exists(localPath)) { var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart( new[] { localPath } .Concat(commandResolverArguments.CommandArguments.OrEmptyIfNull())); return new CommandSpec( new Muxer().MuxerPath, escapedArgs, CommandResolutionStrategy.RootedPath); } } return null; }
public CommandSpec Resolve(CommandResolverArguments arguments) { if (string.IsNullOrEmpty(arguments.CommandName)) { return(null); } var packageId = new DirectoryInfo(Path.Combine(_dotnetToolPath, arguments.CommandName)); if (!packageId.Exists) { return(null); } var version = packageId.GetDirectories()[0]; var dll = version.GetDirectories("tools")[0] .GetDirectories()[0] // TFM .GetDirectories()[0] // RID .GetFiles($"{arguments.CommandName}.dll")[0]; return(CreatePackageCommandSpecUsingMuxer( dll.FullName, arguments.CommandArguments)); }
internal override string ResolveCommandPath(CommandResolverArguments commandResolverArguments) { return(_environment.GetCommandPathFromRootPath( PlatformServices.Default.Application.ApplicationBasePath, commandResolverArguments.CommandName)); }
public void It_returns_a_CommandSpec_with_CommandName_in_Args_when_returning_a_CommandSpec_and_CommandArguments_are_null() { var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "dotnet-hello", CommandArguments = null, ProjectDirectory = s_liveProjectDirectory, Configuration = "Debug", Framework = FrameworkConstants.CommonFrameworks.NetStandardApp15 }; var result = projectDependenciesCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); result.Args.Should().Contain("dotnet-hello"); }
public void It_passes_depsfile_arg_to_corehost_when_returning_a_commandspec() { var projectDependenciesCommandResolver = SetupProjectDependenciesCommandResolver(); var commandResolverArguments = new CommandResolverArguments() { CommandName = "dotnet-hello", CommandArguments = null, ProjectDirectory = s_liveProjectDirectory, Configuration = "Debug", Framework = FrameworkConstants.CommonFrameworks.NetStandardApp15 }; var result = projectDependenciesCommandResolver.Resolve(commandResolverArguments); result.Should().NotBeNull(); result.Args.Should().Contain("--depsfile"); }
internal override string ResolveCommandPath(CommandResolverArguments commandResolverArguments) { return(_environment.GetCommandPath(commandResolverArguments.CommandName)); }
internal abstract string ResolveCommandPath(CommandResolverArguments commandResolverArguments);
internal override string ResolveCommandPath(CommandResolverArguments commandResolverArguments) { return(_environment.GetCommandPathFromRootPath( ApplicationEnvironment.ApplicationBasePath, commandResolverArguments.CommandName)); }