(Debugging) Chocolatey.PowerShell.dll Not Copied To Helpers Directory When Debugging CLI
- Dominant language
- C#
- Stars
- 11.5k
- Forks
- 960
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [x] I confirm there are no unresolved issues reported on the Chocolatey Status page.
- [x] I have verified this is the correct repository for opening this issue.
- [x] I have verified no other issues exist related to my problem.
- [x] I have verified this is not an issue for a specific package.
- [x] I have verified this issue is not security related.
- [x] 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.
6. 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\`:
```xml
```
However, `chocolatey.console.csproj` has no `ProjectReference` to `src/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj` (its only `ProjectReference`s 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`](choco/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.
Contributor guide
Research direction
Start with src/chocolatey.console/chocolatey.console.csproj and its Debug AfterBuild target, then inspect src/Chocolatey.PowerShell/Chocolatey.PowerShell.csproj and ApplicationParameters.ChocolateyPowerShellAssemblyLocation in src/chocolatey/infrastructure.app/ApplicationParameters.cs. Build chocolatey.console in Debug and run the stated install firefox scenario. Done means the DLL, PDB, and help XML appear under helpers, a package cmdlet works, and Release builds remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- build-system, cli, developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 74/100