Checklist
What You Are Seeing?
When debugging the Chocolatey CLI locally (running chocolatey.console in Debug configuration, e.g. via Visual Studio), Chocolatey.PowerShell.dll is not present in the build output's helpers directory. As a result, any package script that calls a cmdlet implemented in Chocolatey.PowerShell (for example Get-EnvironmentVariable, Install-ChocolateyPath, Test-ProcessAdminRights, etc.) fails, because the assembly cannot be found at the expected helpers\Chocolatey.PowerShell.dll location.
What is Expected?
When building/debugging the CLI in Debug configuration, Chocolatey.PowerShell.dll (along with its .pdb and -help.xml companion files) should be copied into the helpers directory alongside the other helper scripts/binaries, so that packages exercising Chocolatey.PowerShell cmdlets work the same way when debugging locally as they do against an installed/official build.
How Did You Get This To Happen?
- Open the
choco solution and set chocolatey.console as the startup project, built in Debug configuration.
- Set the arguments for
chocolatey.console to be install firefox
- Build/debug the CLI (F5)
- Observe the command fails because
Chocolatey.PowerShell.dll is missing from the Debug output's helpers directory.
- Inspect the Debug output directory —
Chocolatey.PowerShell.dll is absent from both the build output root and helpers\.
User Story
As a Chocolatey contributor debugging the CLI locally, I want Chocolatey.PowerShell.dll to be available in the helpers directory of my Debug build, so that I can exercise and debug package scripts that call Chocolatey.PowerShell cmdlets without hitting missing-assembly failures.
System Details
- Operating System: Windows 11
- Windows PowerShell version: 5.1
- Chocolatey CLI Version: (built from local
choco source, Debug configuration)
- Chocolatey Licensed Extension version: N/A
- Chocolatey License type: N/A
- Terminal/Emulator: N/A
(Left blank intentionally — please fill in your actual environment details.)
Installed Packages
N/A — this occurs when debugging the CLI from source, not from an installed package set.
Output Log
Intentionally left blank. I do not currently have one, but one can be obtained
Additional Context
Likely root cause found while investigating: src/chocolatey.console/chocolatey.console.csproj has an AfterBuild target, conditioned on '$(Configuration)' == 'Debug', that copies Chocolatey.PowerShell.dll, .pdb, and -help.xml from $(TargetDir) into $(TargetDir)\helpers\:
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Debug'">
<ItemGroup>
<ChocolateyPowerShell Include="$(TargetDir)\Chocolatey.PowerShell.dll;$(TargetDir)\Chocolatey.PowerShell.pdb;$(TargetDir)\Chocolatey.PowerShell.dll-help.xml" />
</ItemGroup>
<Copy SourceFiles="@(ChocolateyPowerShell)" DestinationFolder="$(TargetDir)\helpers\" SkipUnchangedFiles="true" />
</Target>
However, chocolatey.console.csproj has no ProjectReference to src/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj (its only ProjectReferences are to chocolatey.resources and chocolatey). Since Chocolatey.PowerShell.dll is loaded dynamically at runtime rather than referenced at compile time (see ApplicationParameters.ChocolateyPowerShellAssemblyLocation in src/chocolatey/infrastructure.app/ApplicationParameters.cs), the DLL is never placed in $(TargetDir) in the first place — so the AfterBuild copy has nothing to copy, and helpers\Chocolatey.PowerShell.dll never appears in a Debug build.
A fix likely needs to either add a ProjectReference (with appropriate Private/copy-local settings) from chocolatey.console.csproj to Chocolatey.PowerShell.csproj, or have the AfterBuild/build process pull the built Chocolatey.PowerShell.dll output directly from its own project output directory instead of assuming it's already in $(TargetDir).
Acceptance Criteria
Related Issues
- Also present in Chocolatey Licensed Extension debugging, and can venture a guess that it will also be present in Chocolatey GUI. No issues for those repositories have been created yet.
Checklist
What You Are Seeing?
When debugging the Chocolatey CLI locally (running
chocolatey.consolein Debug configuration, e.g. via Visual Studio),Chocolatey.PowerShell.dllis not present in the build output'shelpersdirectory. As a result, any package script that calls a cmdlet implemented inChocolatey.PowerShell(for exampleGet-EnvironmentVariable,Install-ChocolateyPath,Test-ProcessAdminRights, etc.) fails, because the assembly cannot be found at the expectedhelpers\Chocolatey.PowerShell.dlllocation.What is Expected?
When building/debugging the CLI in Debug configuration,
Chocolatey.PowerShell.dll(along with its.pdband-help.xmlcompanion files) should be copied into thehelpersdirectory alongside the other helper scripts/binaries, so that packages exercisingChocolatey.PowerShellcmdlets work the same way when debugging locally as they do against an installed/official build.How Did You Get This To Happen?
chocosolution and setchocolatey.consoleas the startup project, built in Debug configuration.chocolatey.consoleto beinstall firefoxChocolatey.PowerShell.dllis missing from the Debug output'shelpersdirectory.Chocolatey.PowerShell.dllis absent from both the build output root andhelpers\.User Story
As a Chocolatey contributor debugging the CLI locally, I want
Chocolatey.PowerShell.dllto be available in thehelpersdirectory of my Debug build, so that I can exercise and debug package scripts that callChocolatey.PowerShellcmdlets without hitting missing-assembly failures.System Details
chocosource, Debug configuration)(Left blank intentionally — please fill in your actual environment details.)
Installed Packages
N/A — this occurs when debugging the CLI from source, not from an installed package set.
Output Log
Intentionally left blank. I do not currently have one, but one can be obtained
Additional Context
Likely root cause found while investigating:
src/chocolatey.console/chocolatey.console.csprojhas anAfterBuildtarget, conditioned on'$(Configuration)' == 'Debug', that copiesChocolatey.PowerShell.dll,.pdb, and-help.xmlfrom$(TargetDir)into$(TargetDir)\helpers\:However,
chocolatey.console.csprojhas noProjectReferencetosrc/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj(its onlyProjectReferences are tochocolatey.resourcesandchocolatey). SinceChocolatey.PowerShell.dllis loaded dynamically at runtime rather than referenced at compile time (seeApplicationParameters.ChocolateyPowerShellAssemblyLocationinsrc/chocolatey/infrastructure.app/ApplicationParameters.cs), the DLL is never placed in$(TargetDir)in the first place — so theAfterBuildcopy has nothing to copy, andhelpers\Chocolatey.PowerShell.dllnever appears in a Debug build.A fix likely needs to either add a
ProjectReference(with appropriatePrivate/copy-local settings) fromchocolatey.console.csprojtoChocolatey.PowerShell.csproj, or have theAfterBuild/build process pull the builtChocolatey.PowerShell.dlloutput directly from its own project output directory instead of assuming it's already in$(TargetDir).Acceptance Criteria
chocolatey.consolein Debug configuration producesChocolatey.PowerShell.dll(and its.pdb/-help.xml) in thehelpersdirectory of the build output.Chocolatey.PowerShellcmdlet (e.g.Get-EnvironmentVariable,Install-ChocolateyPath) succeeds when run against a local Debug build.Chocolatey.PowerShell.dllalready ends up in the correct location.Related Issues