예제 #1
0
        public void Restore(
            FilePath project,
            DirectoryPath assetJsonOutput,
            FilePath?nugetConfig = null,
            string source        = null,
            string verbosity     = null)
        {
            var argsToPassToRestore = new List <string>();

            argsToPassToRestore.Add(project.Value);
            if (nugetConfig != null)
            {
                argsToPassToRestore.Add("--configfile");
                argsToPassToRestore.Add(nugetConfig.Value.Value);
            }

            if (source != null)
            {
                argsToPassToRestore.Add("--source");
                argsToPassToRestore.Add(source);
            }

            argsToPassToRestore.AddRange(new List <string>
            {
                "--runtime",
                AnyRid,
                $"/p:BaseIntermediateOutputPath={assetJsonOutput.ToQuotedString()}"
            });

            argsToPassToRestore.Add($"/verbosity:{verbosity ?? "quiet"}");

            var command = new DotNetCommandFactory(alwaysRunOutOfProc: true)
                          .Create("restore", argsToPassToRestore);

            if (_reporter != null)
            {
                command = command
                          .OnOutputLine((line) => _reporter.WriteLine(line))
                          .OnErrorLine((line) => _reporter.WriteLine(line));
            }

            var result = command.Execute();

            if (result.ExitCode != 0)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }
        }
예제 #2
0
        public void Restore(FilePath project,
                            PackageLocation packageLocation,
                            string verbosity = null)
        {
            var argsToPassToRestore = new List <string>();

            argsToPassToRestore.Add(project.Value);
            if (packageLocation.NugetConfig != null)
            {
                argsToPassToRestore.Add("--configfile");
                argsToPassToRestore.Add(packageLocation.NugetConfig.Value.Value);
            }

            argsToPassToRestore.AddRange(new List <string>
            {
                "--runtime",
                Constants.AnyRid
            });

            argsToPassToRestore.Add($"--verbosity:{verbosity ?? GetDefaultVerbosity()}");

            if (_additionalRestoreArguments != null)
            {
                argsToPassToRestore.AddRange(_additionalRestoreArguments.Where(arg => !arg.StartsWith("-verbosity")));
            }

            var command = new DotNetCommandFactory(alwaysRunOutOfProc: true)
                          .Create("restore", argsToPassToRestore);

            if (verbosity == null || _forceOutputRedirection)
            {
                command = command
                          .OnOutputLine(line => WriteLine(_reporter, line, project))
                          .OnErrorLine(line => WriteLine(_errorReporter, line, project));
            }

            var result = command.Execute();

            if (result.ExitCode != 0)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }
        }
예제 #3
0
        public void Restore(FilePath project,
                            FilePath?nugetConfig = null,
                            string verbosity     = null)
        {
            var argsToPassToRestore = new List <string>();

            argsToPassToRestore.Add(project.Value);
            if (nugetConfig != null)
            {
                argsToPassToRestore.Add("--configfile");
                argsToPassToRestore.Add(nugetConfig.Value.Value);
            }

            argsToPassToRestore.AddRange(new List <string>
            {
                "--runtime",
                AnyRid
            });

            argsToPassToRestore.Add($"-verbosity:{verbosity ?? "quiet"}");

            var command = new DotNetCommandFactory(alwaysRunOutOfProc: true)
                          .Create("restore", argsToPassToRestore);

            if (verbosity == null || _forceOutputRedirection)
            {
                command = command
                          .OnOutputLine(line => WriteLine(_reporter, line, project))
                          .OnErrorLine(line => WriteLine(_errorReporter, line, project));
            }

            var result = command.Execute();

            if (result.ExitCode != 0)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }
        }