Exemplo n.º 1
0
        public async Task Invoke(FileInfo file, NuGetSources sources)
        {
            _logger.Normal($"Nuget restore on {file.DirectoryName} {file.Name}");

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                _logger.Normal("Cannot run NuGet.exe file restore as OS Platform is not Windows");
                return;
            }

            var nuget = NuGetPath.FindExecutable();

            if (string.IsNullOrWhiteSpace(nuget))
            {
                _logger.Normal("Cannot find NuGet exe for solution restore");
                return;
            }

            var sourcesCommandLine = sources.CommandLine("-Source");

            var arguments = $"restore {file.Name} {sourcesCommandLine}";

            _logger.Detailed($"{nuget} {arguments}");

            var processOutput = await _externalProcess.Run(file.DirectoryName, nuget, arguments, ensureSuccess : false);

            if (processOutput.Success)
            {
                _logger.Detailed($"Nuget restore on {file.Name} complete");
            }
            else
            {
                _logger.Detailed($"Nuget restore failed on {file.DirectoryName} {file.Name}:\n{processOutput.Output}\n{processOutput.ErrorOutput}");
            }
        }
        public async Task Invoke(PackageInProject currentPackage,
                                 NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                _logger.Info("Cannot run NuGet.exe package update as OS Platform is not Windows");
                return;
            }

            var dirName = currentPackage.Path.Info.DirectoryName;

            var nuget = NuGetPath.FindExecutable();

            if (string.IsNullOrWhiteSpace(nuget))
            {
                _logger.Info("Cannot find NuGet exe for package update");
                return;
            }

            var sources   = allSources.CommandLine("-Source");
            var arguments = $"update packages.config -Id {currentPackage.Id} -Version {newVersion} {sources}";

            _logger.Verbose(arguments);

            await _externalProcess.Run(dirName, nuget, arguments, true);
        }