英文:
Creating chocolatey packages for plug-ins of "large" applications
问题
我有一个关于使用Chocolatey为其他应用程序打包插件的问题。假设我有一个主应用程序sample-app
,以及一个可以为该sample-app
安装的插件sample-app-plugin
。
从技术上讲,sample-app-plugin
依赖于sample-app
,因为它不能在没有sample-app
的情况下运行,并且必须在其之后安装。起初,我认为我应该将sample-app
添加到sample-app-plugin
的依赖列表中。例如,这就是keepass的插件包是如何创建的。
然而,有时父应用程序是一个"主要安装"。安装程序可能是几百兆字节甚至几个千兆字节。当用户尝试安装一个小插件时,他们不会期望这会触发对其计算机上其他软件的主要安装或更新。
因此,在这种情况下,如果未安装sample-app
,我更希望sample-app-plugin
的安装失败。是否有一种方法可以继续使用Chocolatey/Nuget的内置依赖功能,但只检查所需的依赖项是否已安装,而不尝试实际安装它们?有--ignoredependencies
选项,但据我所知,这只是完全忽略依赖项。或者,如果用户首先被警告即将安装sample-app
并提供取消选项,那也可以。
如果实际的软件包依赖关系无法实现这一点,那么在chocolateyInstall.ps1文件中检查现有的choco软件包的最佳方法是什么?首先想到的是只需检查预期安装位置中nuspec文件中的版本:
$PackageName = "sample-app"
([xml]$xml = Get-Content $env:ChocolateyInstall\lib$PackageName$PackageName.nuspec).package.metadata.version
英文:
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
答案1
得分: 1
如果将sample-app
作为sample-app-plugin
的依赖项添加,那么只有在它尚未安装时才会安装它。如果您不将sample-app
的安装程序添加到sample-app
软件包中,而是从某个内部位置下载它作为软件包安装的一部分,那么您只是下载软件包本身,大小约为5k。
另一种方法是在sample-app-plugin
软件包中添加一个检查,如果sample-app
未安装,则会抛出错误。
目前,您无法仅通过依赖项来实现这一点。
(我是keepass
软件包的维护者)。
英文:
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).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论