public override int Execute() { var executablePackagePath = new DirectoryPath(new CliFolderPathCalculator().ExecutablePackagesPath); var toolConfigurationAndExecutableDirectory = ObtainPackage(executablePackagePath); DirectoryPath executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithSubDirectories( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); var shellShimMaker = new ShellShimMaker(executablePackagePath.Value); var commandName = toolConfigurationAndExecutableDirectory.Configuration.CommandName; shellShimMaker.EnsureCommandNameUniqueness(commandName); shellShimMaker.CreateShim( executable.Value, commandName); EnvironmentPathFactory .CreateEnvironmentPathInstruction() .PrintAddPathInstructionIfPathDoesNotExist(); Reporter.Output.WriteLine( string.Format(LocalizableStrings.InstallationSucceeded, commandName)); return(0); }
public override int Execute() { if (!_global) { throw new GracefulException(LocalizableStrings.InstallToolCommandOnlySupportGlobal); } var cliFolderPathCalculator = new CliFolderPathCalculator(); var executablePackagePath = new DirectoryPath(cliFolderPathCalculator.ExecutablePackagesPath); var offlineFeedPath = new DirectoryPath(cliFolderPathCalculator.CliFallbackFolderPath); var toolConfigurationAndExecutablePath = ObtainPackage(executablePackagePath, offlineFeedPath); var shellShimMaker = new ShellShimMaker(executablePackagePath.Value); var commandName = toolConfigurationAndExecutablePath.Configuration.CommandName; shellShimMaker.EnsureCommandNameUniqueness(commandName); shellShimMaker.CreateShim( toolConfigurationAndExecutablePath.Executable.Value, commandName); EnvironmentPathFactory .CreateEnvironmentPathInstruction() .PrintAddPathInstructionIfPathDoesNotExist(); Reporter.Output.WriteLine( string.Format(LocalizableStrings.InstallationSucceeded, commandName)); return(0); }
public void GivenAnExecutablePathDirectoryThatDoesNotExistItCanGenerateShimFile() { var outputDll = MakeHelloWorldExecutableDll(); var extraNonExistDirectory = Path.GetRandomFileName(); var shellShimMaker = new ShellShimMaker(Path.Combine(TempRoot.Root, extraNonExistDirectory)); var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); Action a = () => shellShimMaker.CreateShim(outputDll, shellCommandName); a.ShouldNotThrow <DirectoryNotFoundException>(); }
public void GivenAnExecutablePathItCanGenerateShimFile() { var outputDll = MakeHelloWorldExecutableDll(); var cleanFolderUnderTempRoot = GetNewCleanFolderUnderTempRoot(); var shellShimMaker = new ShellShimMaker(cleanFolderUnderTempRoot); var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); shellShimMaker.CreateShim(outputDll, shellCommandName); var stdOut = ExecuteInShell(shellCommandName, cleanFolderUnderTempRoot); stdOut.Should().Contain("Hello World"); }
public void GivenAnExecutablePathItCanGenerateShimFile() { var outputDll = MakeHelloWorldExecutableDll(); var shellShimMaker = new ShellShimMaker(_pathToPlaceShim); var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); shellShimMaker.CreateShim( outputDll.FullName, shellCommandName); var stdOut = ExecuteInShell(shellCommandName); stdOut.Should().Contain("Hello World"); }
public void GivenAShimItPassesThroughArguments(string arguments, string[] expectedPassThru) { var outputDll = MakeHelloWorldExecutableDll(); var cleanFolderUnderTempRoot = GetNewCleanFolderUnderTempRoot(); var shellShimMaker = new ShellShimMaker(cleanFolderUnderTempRoot); var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); shellShimMaker.CreateShim(outputDll, shellCommandName); var stdOut = ExecuteInShell(shellCommandName, cleanFolderUnderTempRoot, arguments); for (int i = 0; i < expectedPassThru.Length; i++) { stdOut.Should().Contain($"{i} = {expectedPassThru[i]}"); } }
public override int Execute() { FilePath?configFile = null; if (_configFilePath != null) { configFile = new FilePath(_configFilePath); } var executablePackagePath = new DirectoryPath(new CliFolderPathCalculator().ExecutablePackagesPath); var toolConfigurationAndExecutableDirectory = ObtainPackage( _packageId, _packageVersion, configFile, _framework, executablePackagePath); DirectoryPath executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithSubDirectories( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); var shellShimMaker = new ShellShimMaker(executablePackagePath.Value); var commandName = toolConfigurationAndExecutableDirectory.Configuration.CommandName; shellShimMaker.EnsureCommandNameUniqueness(commandName); shellShimMaker.CreateShim( executable.Value, commandName); EnvironmentPathFactory .CreateEnvironmentPathInstruction() .PrintAddPathInstructionIfPathDoesNotExist(); Reporter.Output.WriteLine( $"{Environment.NewLine}The installation succeeded. If there is no other instruction. You can type the following command in shell directly to invoke: {commandName}"); return(0); }