Skip to content

Commit

Permalink
(maint) Add ability for Agent debugging
Browse files Browse the repository at this point in the history
Chocolatey Agent adds `--run-actual` on every Chocolatey CLI command
run. When we're in debug mode and `--run-actual` is passed to Chocolatey
CLI, we should not pause execution as the end as we're likely in agent
and cannot acknowledge the pause.

This also adds a change to the cake recipe to add `--run-actual` on the
`unpackself` step as when we're building a debug version we don't want
to pause for the user to press a key.
  • Loading branch information
corbob authored and gep13 committed Apr 5, 2024
1 parent 8d024e8 commit 7eac698
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Task("Prepare-Chocolatey-Packages")
// Run Chocolatey Unpackself
CopyFile(BuildParameters.Paths.Directories.PublishedApplications + "/choco_merged/choco.exe", BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe");
StartProcess(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe", new ProcessSettings{ Arguments = "unpackself -f -y --allow-unofficial-build" });
StartProcess(BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/choco.exe", new ProcessSettings{ Arguments = "unpackself -f -y --allow-unofficial-build --run-actual" });
// Tidy up logs and config folder which are not required
var logsDirectory = BuildParameters.Paths.Directories.ChocolateyNuspecDirectory + "/tools/chocolateyInstall/logs";
Expand Down
7 changes: 6 additions & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ private static void Main(string[] args)
#if DEBUG
"chocolatey".Log().Info(() => "Exiting with {0}".FormatWith(Environment.ExitCode));
#endif
PauseIfDebug();
// Chocolatey Agent runs Chocolatey CLI with --run-actual. If that's the case we don't want to pause on debug.
if (!args.Any(a => a.IsEqualTo("--run-actual")))
{
PauseIfDebug();
}

Bootstrap.Shutdown();
Environment.Exit(Environment.ExitCode);
}
Expand Down

0 comments on commit 7eac698

Please sign in to comment.