Skip to content

Conversation

@steviecoaster
Copy link
Contributor

@steviecoaster steviecoaster commented Nov 11, 2022

Description Of Changes

Adds a new $env:ChocolateyPackageId environment variable to the PowerShell host when installing/upgrading/uninstalling a Chocolatey package.

Motivation and Context

The nuspec references a package by id, making $env:ChocolateyPackageName less idiomatic than $env:ChocolateyPackageId. The $env:ChocolateyPackageName variable is still available for use, to prevent existing packages from breaking, but moving forward this new env variable is more inline with the nuspec definition of id.

Testing

  1. Run Pester tests, as a new assertion is included to test for presence of environment variable.

Change Types Made

  • Bug fix (non-breaking change)
  • Feature / Enhancement (non-breaking change)
  • Breaking change (fix or feature that could cause existing functionality to change)
  • PowerShell code changes.

Related Issue

Fixes #2781

Change Checklist

  • Requires a change to the documentation
  • Documentation has been updated
  • Tests to cover my changes, have been added
  • All new and existing tests passed.
  • PowerShell v2 compatibility checked.

@steviecoaster steviecoaster requested a review from gep13 November 11, 2022 16:55
@gep13 gep13 force-pushed the gh2781 branch 2 times, most recently from d1008d1 to 5a545ae Compare June 12, 2025 07:12
@gep13 gep13 requested review from AdmiringWorm and pauby June 12, 2025 07:15
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a single recommendation, otherwise this looks good to me

@gep13
Copy link
Member

gep13 commented Jun 13, 2025

@AdmiringWorm that is a good idea! I have got that updated just now.

Previously the only env variable to reference a Chocolatey package id
was $env:ChocolateyPackageName. This is inconsistent with the nusepec
file where it is referenced as id.

This commit adds ChocolateyPackageId to the available environment
variables inside the PowerShell host allowing a package maintainer to
reference the id of a package with the more idiomatic
$env:ChocolateyPackageId.
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AdmiringWorm AdmiringWorm merged commit 030ab42 into chocolatey:develop Jun 13, 2025
4 of 5 checks passed
@AdmiringWorm
Copy link
Member

thanks for adding this @steviecoaster and @gep13. Great work 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add $env:ChocolateyPackageId environment variable to represent the id from the nuspec file for a package

4 participants