Skip to content

(Debugging) Chocolatey.PowerShell.dll Not Copied To Helpers Directory When Debugging CLI #3929

Description

@corbob

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?

  1. Open the choco solution and set chocolatey.console as the startup project, built in Debug configuration.
  2. Set the arguments for chocolatey.console to be install firefox
  3. Build/debug the CLI (F5)
  4. Observe the command fails because Chocolatey.PowerShell.dll is missing from the Debug output's helpers directory.
  5. 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

  • Building/debugging chocolatey.console in Debug configuration produces Chocolatey.PowerShell.dll (and its .pdb/-help.xml) in the helpers directory of the build output.
  • A package script calling a Chocolatey.PowerShell cmdlet (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.dll already 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0 - BacklogIssue is accepted, but is not ready to be worked on or not in current sprint.Build AutomationIssues for changes to the build system, without functional changes needed to the project.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions