You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, it may be desirable to set the installation directory manually in an install script. This can be done by setting $env:ChocolateyPackageInstallLocation, however, it would be good to have a helper that abstracts the functionality. It should not set the variable if it is already set, unless force is passed.
My thoughts around this is to introduce two new cmdlets with a similar name to the Get-AppInstallLocation that is already implemented.
Add the cmdlet Set-AppInstallLocation, which should have the responsibilities of:
Should have the parameters -LiteralPath and -Force. Literal Path should be mandatory (could potentially have -Path as an alternative that allows globbing, but not sure how useful that is)
It should verify whether the environment variable is already set or not, and only override the environment variable if it isn't set (both null, and an empty value) unless -Force is also used.
It should verify that the path specified exists, if it doesn't exist, it should throw an exception.
It should have an output value of the path that was set.
Add the cmdlet Update-AppInstallLocation, which should have the responsibilities of:
Should have the parameters -AppNamePattern and -Force where AppNamePattern is mandatory.
It should call Get-AppInstallLocation to get the correct install location.
It should throw an exception if the installation path could not be found.
It should verify whether the environment variable is already set or not, and only override the environment variable if it isn't set (both null, and an empty value) unless -Force is also used.
It should have an output value of the path that was set.
Alternatively to the second cmdlet, we could also just have the first one but make LiteralPath/Path and AppNamePattern be mandatory in different sets.
Sometimes, it may be desirable to set the installation directory manually in an install script. This can be done by setting
$env:ChocolateyPackageInstallLocation
, however, it would be good to have a helper that abstracts the functionality. It should not set the variable if it is already set, unlessforce
is passed.This is so the install directory can be set for installers that do not set an explicit install directory in the registry, and for packages that have a complex install script that requires manual install directory setting. See https://github.com/orgs/chocolatey-community/discussions/2254
The text was updated successfully, but these errors were encountered: