Ejemplo n.º 1
0
        public ToolInstallCommand(
            AppliedOption appliedCommand,
            ParseResult parseResult,
            CreateToolPackageStoreAndInstaller createToolPackageStoreAndInstaller = null,
            CreateShellShimRepository createShellShimRepository    = null,
            IEnvironmentPathInstruction environmentPathInstruction = null,
            IReporter reporter = null)
            : base(parseResult)
        {
            if (appliedCommand == null)
            {
                throw new ArgumentNullException(nameof(appliedCommand));
            }

            _packageId      = new PackageId(appliedCommand.Arguments.Single());
            _packageVersion = appliedCommand.ValueOrDefault <string>("version");
            _configFilePath = appliedCommand.ValueOrDefault <string>("configfile");
            _framework      = appliedCommand.ValueOrDefault <string>("framework");
            _source         = appliedCommand.ValueOrDefault <string[]>("add-source");
            _global         = appliedCommand.ValueOrDefault <bool>("global");
            _verbosity      = appliedCommand.SingleArgumentOrDefault("verbosity");
            _toolPath       = appliedCommand.SingleArgumentOrDefault("tool-path");

            _createToolPackageStoreAndInstaller = createToolPackageStoreAndInstaller ?? ToolPackageFactory.CreateToolPackageStoreAndInstaller;

            _environmentPathInstruction = environmentPathInstruction
                                          ?? EnvironmentPathFactory.CreateEnvironmentPathInstruction();
            _createShellShimRepository = createShellShimRepository ?? ShellShimRepositoryFactory.CreateShellShimRepository;

            _reporter      = (reporter ?? Reporter.Output);
            _errorReporter = (reporter ?? Reporter.Error);
        }
Ejemplo n.º 2
0
        public ToolInstallCommandTests()
        {
            _reporter                  = new BufferedReporter();
            _fileSystem                = new FileSystemMockBuilder().UseCurrentSystemTemporaryDirectory().Build();
            _temporaryDirectory        = _fileSystem.Directory.CreateTemporaryDirectory().DirectoryPath;
            _pathToPlaceShim           = Path.Combine(_temporaryDirectory, "pathToPlace");
            _pathToPlacePackages       = _pathToPlaceShim + "Packages";
            _toolPackageStore          = new ToolPackageStoreMock(new DirectoryPath(_pathToPlacePackages), _fileSystem);
            _createShellShimRepository =
                (nonGlobalLocation) => new ShellShimRepository(
                    new DirectoryPath(_pathToPlaceShim),
                    fileSystem: _fileSystem,
                    appHostShellShimMaker: new AppHostShellShimMakerMock(_fileSystem),
                    filePermissionSetter: new NoOpFilePermissionSetter());
            _environmentPathInstructionMock =
                new EnvironmentPathInstructionMock(_reporter, _pathToPlaceShim);
            _createToolPackageStoreAndInstaller = (_) => (_toolPackageStore, CreateToolPackageInstaller());

            ParseResult result = Parser.Instance.Parse($"dotnet tool install -g {PackageId}");

            _appliedCommand = result["dotnet"]["tool"]["install"];
            var parser = Parser.Instance;

            _parseResult = parser.ParseFrom("dotnet tool", new[] { "install", "-g", PackageId });
        }
Ejemplo n.º 3
0
        public InstallToolCommandTests()
        {
            _reporter                  = new BufferedReporter();
            _fileSystem                = new FileSystemMockBuilder().Build();
            _toolPackageStore          = new ToolPackageStoreMock(new DirectoryPath(PathToPlacePackages), _fileSystem);
            _createShellShimRepository =
                (nonGlobalLocation) => new ShellShimRepositoryMock(new DirectoryPath(PathToPlaceShim), _fileSystem);
            _environmentPathInstructionMock =
                new EnvironmentPathInstructionMock(_reporter, PathToPlaceShim);
            _createToolPackageStoreAndInstaller = (_) => (_toolPackageStore, CreateToolPackageInstaller());

            ParseResult result = Parser.Instance.Parse($"dotnet install tool -g {PackageId}");

            _appliedCommand = result["dotnet"]["install"]["tool"];
            var parser = Parser.Instance;

            _parseResult = parser.ParseFrom("dotnet install", new[] { "tool", PackageId });
        }