diff --git a/aeqw89.tools.Publish/.gitignore b/aeqw89.tools.Publish/.gitignore index e69de29..6dd29b7 100644 --- a/aeqw89.tools.Publish/.gitignore +++ b/aeqw89.tools.Publish/.gitignore @@ -0,0 +1 @@ +bin/ \ No newline at end of file diff --git a/aeqw89.tools.Publish/Program.cs b/aeqw89.tools.Publish/Program.cs index 9a30d17..6dec9d3 100644 --- a/aeqw89.tools.Publish/Program.cs +++ b/aeqw89.tools.Publish/Program.cs @@ -250,9 +250,9 @@ public static class Program { }; string processError = ""; - var exitCode = AnsiConsole.Status() + var exitCode = await AnsiConsole.Status() .Spinner(Spinner.Known.Dots) - .Start("Creating package with 'dotnet pack' ", ctx => { + .StartAsync("Creating package with 'dotnet pack' ", async ctx => { var p = Process.Start(new ProcessStartInfo() { FileName = "dotnet", Arguments = $"pack -o {outDir}", @@ -261,7 +261,17 @@ public static class Program { RedirectStandardOutput = !Verbose, RedirectStandardError = !Verbose }); - p?.WaitForExit(); + + CancellationTokenSource cts = new CancellationTokenSource(); + p?.ErrorDataReceived += (sender, eventArgs) => { + cts.Cancel(); + }; + p?.OutputDataReceived += (sender, eventArgs) => { + if (eventArgs.Data?.ToLower().Contains("press any key") == true) + cts.Cancel(); + }; + + await (p?.WaitForExitAsync(cts.Token) ?? Task.CompletedTask); processError = p?.StandardError?.ReadToEnd() ?? ""; return p?.ExitCode ?? -1; }); @@ -416,17 +426,26 @@ public static class Program { RedirectStandardError = !Verbose }); + var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + p?.ErrorDataReceived += (sender, eventArgs) => { + cts.Cancel(); + }; + p?.OutputDataReceived += (sender, eventArgs) => { + if (eventArgs.Data?.ToLower().Contains("press any key") == true) + cts.Cancel(); + }; + if (p == null) { ShowError(Exceptions.generic_error.EscapeMarkup()); } task.Increment(size / 2); if (p != null) - await p.WaitForExitAsync(ct); + await p.WaitForExitAsync(cts.Token); processError += p?.StandardError?.ReadToEnd() ?? ""; if (p?.ExitCode != 0) { ShowError(processError.EscapeMarkup()); - ShowError(Exceptions.dotnet_nuget_push_failure, p.ExitCode); + ShowError(Exceptions.dotnet_nuget_push_failure, p?.ExitCode ?? -1); } task.Increment(size / 2); } diff --git a/aeqw89.tools.Publish/aeqw89.tools.Publish.csproj b/aeqw89.tools.Publish/aeqw89.tools.Publish.csproj index b777737..d31429e 100644 --- a/aeqw89.tools.Publish/aeqw89.tools.Publish.csproj +++ b/aeqw89.tools.Publish/aeqw89.tools.Publish.csproj @@ -5,6 +5,7 @@ net9.0 enable enable + preview