Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1 #1436

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

flcdrg
Copy link
Member

@flcdrg flcdrg commented Oct 29, 2017

  • Add a ScriptBlock parameter to Install-ChocolateyPackage.ps1 that if present, is called after download but before install.

Closes #1060

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

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

I like it

@Mistuke
Copy link

Mistuke commented Dec 21, 2017

Would it also be possible to have a BeforeUninstall? I have a package that I haven't been able to upload to Chocolatey before of the way it performs uninstalls. It seems to first move a package and then run the uninstall script. But the move would obviously fail if a file is locked, such as a service running.

A BeforeUninstall would allow me to stop and unregister the service properly before chocolatey does it's thing.

@ferventcoder
Copy link
Member

@Mistuke that already exists, and for exactly that purpose - it's called the chocolateyBeforeModify.ps1. It needs to be in the already installed package to be called. It is run before upgrade and before uninstall. Run choco new test from the latest version of Chocolatey (v0.10.8 as of this message) and take a look at the output.

By the way, Chocolatey is actually quite good at handling locked files in the package directory, we even have tests on this. You may see some warnings and error messages but it does successfully perform upgrades with locked package files.

@Mistuke
Copy link

Mistuke commented Dec 21, 2017

@ferventcoder Thanks! I didn't know this was added, I should update my chocolatey. Last time I tried it with locked files it seems to just hang on the file move. But this was a while ago. I'll try it again.

@flcdrg flcdrg force-pushed the BeforeInstallScriptBlock branch from 222372e to b1de6ec Compare January 18, 2019 04:12
@CLAassistant
Copy link

CLAassistant commented Jun 8, 2020

CLA assistant check
All committers have signed the CLA.

@gep13 gep13 force-pushed the BeforeInstallScriptBlock branch from b1de6ec to 8be88e0 Compare April 16, 2021 15:36
@gep13 gep13 changed the base branch from master to stable April 16, 2021 15:36
…Package.ps1

- Add a ScriptBlock parameter `BeforeInstall` to Install-ChocolateyPackage.ps1. If supplied, the script block is called after download but before install.
@gep13 gep13 force-pushed the BeforeInstallScriptBlock branch from 8be88e0 to 4c3cf9c Compare April 16, 2021 15:40
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

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

LGTM!

@gep13
Copy link
Member

gep13 commented Apr 16, 2021

@flcdrg thank you very much for taking the time to make this addition. This looks good to me, and once the CI builds are complete, I will get this merged in.

@gep13 gep13 merged commit deda8fe into chocolatey:stable Apr 16, 2021

Use this for starting an auxilary process such as AutoHotkey, so that any timeouts are not
affected by the time to download.

Copy link
Member

Choose a reason for hiding this comment

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

Just a note for consistency - we put parameter docs in the order they appear. This should later be moved ABOVE IgnoredArguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants