(Debugging) Chocolatey.PowerShell.dll Not Copied To Helpers Directory When Debugging CLI
Checklist
- I confirm there are no unresolved issues reported on the Chocolatey Status page.
- I have verified this is the correct repository for opening this issue.
- I have verified no other issues exist related to my problem.
- I have verified this is not an issue for a specific package.
- I have verified this issue is not security related.
- I confirm I am using official, and not unofficial, or modified, Chocolatey products.
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
chocosolution and setchocolatey.consoleas the startup project, built in Debug configuration. - Set the arguments for
chocolatey.consoleto beinstall firefox - Build/debug the CLI (F5)
- Observe the command fails because
Chocolatey.PowerShell.dllis missing from the Debug output'shelpersdirectory. - Inspect the Debug output directory —
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.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
chocosource, 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
- Building/debugging
chocolatey.consolein Debug configuration producesChocolatey.PowerShell.dll(and its.pdb/-help.xml) in thehelpersdirectory of the build output. - A package script calling a
Chocolatey.PowerShellcmdlet (e.g.Get-EnvironmentVariable,Install-ChocolateyPath) succeeds when run against a local Debug build. - No regression to the Release/ReleaseOfficial build/packaging process, where
Chocolatey.PowerShell.dllalready ends up in the correct location.
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.
Source: chocolatey/choco