I'm looking for some guidance on how I should be packaging my TopShelf hosted Windows service for distribution via Chocolatey. Currently the .nuspec puts the .exe and all .dlls into the \tools
folder, which means they end up installed to ProgramData\chocolatey\lib\our-service\tools
. That just doesn't seem right. In fact it was not a problem until I noticed that the uninstall logs all sorts of errors. Which are all related to Chocolatey trying to back up the files but can't because they are in use because the service is running. The chocolateyuninstall.ps1 stops the service but it doesn't run till after the backup attempt.
The application itself uses ProgramData\MyCompany\MyApp
for all data and logging. Should I be putting the binaries there as well? Or is Program Files
more appropriate? If one of these locations is correct, is chocolateyinstall.ps1 the logical place to put the code to xcopy the binaries? Or (and i hope you say no) is this not even a valid use of Chocolatey? Meaning like, should I suck it up and create an MSI for Chocolatey to operate on?
Thanks
Currently the .nuspec puts the .exe and all .dlls into the
\tools
folder, which means they end up installed toProgramData\chocolatey\lib\our-service\tools
. That just doesn't seem right. In fact it was not a problem until I noticed that the uninstall logs all sorts of errors. Which are all related to Chocolatey trying to back up the files but can't because they are in use because the service is running. The chocolateyuninstall.ps1 stops the service but it doesn't run till after the backup attempt.
We are adding a chocolateyBeforeModify.ps1 script that will be run before upgrade/uninstall - https://github.com/chocolatey/choco/issues/268. That should be in 0.9.10 and will help make the workflow smoother.
Currently you must stop the service outside of Chocolatey prior to attempting to upgrade or uninstall.
Another thing to consider is that Chocolatey takes advantage of XDT (Xml Document Transformations), which means if you include an *.install.xdt
file for an xml config, choco won't simply overwrite an existing file. That allows you to upgrade in a package folder without overwriting any user configuration. However, if you are copying the files off somewhere else, you need to figure this aspect out on your own.
The application itself uses
ProgramData\MyCompany\MyApp
for all data and logging. Should I be putting the binaries there as well? Or isProgram Files
more appropriate?
We don't yet have a recommended way of installing a service or setting up a website / web application. Both of these things we will be creating helpers for in the future, at which time we will recommend those avenues and have better recommendations about where things should go.
Update 20170324: We now have Install-ChocolateyWindowsService
and other service related functions in the business edition of Chocolatey.
If one of these locations is correct, is chocolateyinstall.ps1 the logical place to put the code to xcopy the binaries?
The automation scripts are the logical place to perform any actions you need to take after the package bits are added.
Or (and i hope you say no) is this not even a valid use of Chocolatey? Meaning like, should I suck it up and create an MSI for Chocolatey to operate on?
Creating services and websites is definitely a valid use of Chocolatey. I recommend not to create an MSI unless you need to. It's quite an involved process and in most cases (like for internal applications), it feels like overkill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With