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 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 void GivenAnExecutablePathWithoutExistingSameNameShimItShouldNotThrow() { var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); var shellShimMaker = new ShellShimMaker(_pathToPlaceShim); Action a = () => shellShimMaker.EnsureCommandNameUniqueness(shellCommandName); a.ShouldNotThrow(); }
public void GivenAnExecutablePathWithExistingSameNameShimItThrows() { var shellCommandName = nameof(ShellShimMakerTests) + Path.GetRandomFileName(); MakeNameConflictingCommand(_pathToPlaceShim, shellCommandName); var shellShimMaker = new ShellShimMaker(_pathToPlaceShim); Action a = () => shellShimMaker.EnsureCommandNameUniqueness(shellCommandName); a.ShouldThrow <GracefulException>() .And.Message .Should().Contain( $"Failed to install tool {shellCommandName}. A command with the same name already exists."); }
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); }