示例#1
0
        private async Task <int> CreatePackage(NuspecFile nuspecFile, CancellationToken cancellationToken)
        {
            var packageStopwatch = Stopwatch.StartNew();

            await UpdateNuspec(nuspecFile, cancellationToken);

            var commandLine = _roboNuGetFile.NuGet.Commands["pack"].Format(new
            {
                NuspecFileName      = nuspecFile.FileName,
                OutputDirectoryName = _roboNuGetFile.NuGet.OutputDirectoryName,
            });

            var result = await Task.Run(() => _processExecutor.NoWindowExecuteAsync("nuget", commandLine), cancellationToken);

            lock (_consoleSyncLock)
            {
                //Logger.ConsoleMessageLine(m => m.text($"Executed: {result.Arguments}"));
                Logger.ConsoleMessageLine(m => m.text(result.Output.Trim()));

                if (result.ExitCode != ExitCode.Success)
                {
                    Logger.ConsoleError(result.Error.Trim());
                    Logger.ConsoleMessageLine(p => p.Indent().text($"Could not create package: {nuspecFile.Id}").color(ConsoleColor.Red));
                }

                //Logger.ConsoleMessageLine(p => p.text($"Elapsed: {packageStopwatch.Elapsed.TotalSeconds:F1} sec [{Thread.CurrentThread.ManagedThreadId}] ({nuspecFile.Id})"));
                Logger.ConsoleMessageLine(p => p.text($"Elapsed: {packageStopwatch.Elapsed.TotalSeconds:F1} sec"));
                //Logger.ConsoleMessageLine(p => p.text($"-"));
                Logger.ConsoleMessageLine(_ => _);
            }

            return(result.ExitCode);
        }
示例#2
0
文件: Push.cs 项目: he-dev/RoboNuGet
        public override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            //this.ValidateWith(ParameterValidator).ThrowIfNotValid();

            var solutionFileName = _fileSearch.FindSolutionFile();
            var nuspecFiles      = _fileSearch.FindNuspecFiles();

            var pushStopwatch = Stopwatch.StartNew();

            var success = new Dictionary <bool, int>
            {
                [true]  = 0,
                [false] = 0
            };

            // We're not pushing packages in parallel.
            foreach (var nuspecFile in nuspecFiles)
            {
                var packageStopwatch = Stopwatch.StartNew();

                var commandLine = _roboNuGetFile.NuGet.Commands["push"].Format(new
                {
                    NupkgFileName   = Path.Combine(_roboNuGetFile.NuGet.OutputDirectoryName, $"{nuspecFile.Id}.{nuspecFile.Version}.nupkg"),
                    NuGetConfigName = _roboNuGetFile.NuGet.NuGetConfigName,
                });

                var result = await _processExecutor.NoWindowExecuteAsync("nuget", commandLine);

                success[result.ExitCode == ExitCode.Success]++;

                Logger.ConsoleMessageLine(m => m.text(result.Output.Trim()));
                Logger.ConsoleMessageLine(m => m.text(result.Error.Trim()));
                Logger.ConsoleMessageLine(p => p.text($"Elapsed: {packageStopwatch.Elapsed.TotalSeconds:F1} seconds"));
            }

            Logger.ConsoleMessageLine(p => p.text($"Uploaded: {success[true]} package(s)."));
            Logger.ConsoleMessageLine(p => p.text($"Failed: {success[false]} package(s)."));
            Logger.ConsoleMessageLine(p => p.text($"Elapsed: {pushStopwatch.Elapsed.TotalSeconds:F1} seconds"));
        }