Reputation: 22213
I have a question about using Chocolatey to package plugins for other applications. Say I have a primary application sample-app
, and a plugin that can be installed for this sample-app-plugin
.
Technically sample-app-plugin
depends on sample-app
as it can't run with out it and must be installed after it. At first I would think I would want to add sample-app
to the list of dependencies in sample-app-plugin
. For example, this is how the plugin packages for keepass are created.
However, sometimes the parent application is a "major installation". The installer may be hundreds of MB if not a few GB. When users attempt to install a small plug-in they won't be expecting this to trigger a major installation or update of other software on their machine.
So, in this case I would much rather the installation of sample-app-plugin
simply fail if sample-app
is not installed. Is there a way to continue to use the built in dependencies feature of Chocolatey/Nuget, but only use this to check if required dependencies are installed but not attempt to actually install them? There's the --ignoredependencies
option, but as far as I can tell this just ignores the dependencies entirely. Alternatively it would also work if the user is first warned that sample-app
is about to be installed with an option to cancel.
If there is not a way to do this with actual package dependencies what is the best way to check for existing choco packages in the chocolateyInstall.ps1 file? The first thing that comes to mind is to just check the version in the nuspec file in the expected installation location:
$PackageName = "sample-app"
([xml]$xml = Get-Content $env:ChocolateyInstall\lib\$PackageName\$PackageName.nuspec).package.metadata.version
Upvotes: 0
Views: 63
Reputation: 787
If you add sample-app
as a dependency of sample-app-plugin
then it will only be installed if it's not already installed. If you don't add the installer for sample-app
to the sample-app
package, but instead download it from somewhere internal as package of the package installation, then you're only downloading the package itself which will be around 5k.
The other way to do this is adding a check inside the sample-app-plugin
package that throw
's an error if sample-app
is not installed.
You can't do this simply with dependencies yet.
(I'm the maintainer of the keepass
packages).
Upvotes: 1