将PostgreSQL安装程序添加到我自己的应用程序安装程序中

问题描述:

我创建了一个Visual Studio 2010安装程序项目,并向其中添加了 postgresql-9.2.401-windows.exe 文件.在提交"自定义操作中,我添加了该文件,删除了所有参数,并将 InstallerClass 设置为 False .

I created a Visual Studio 2010 installer project and added the postgresql-9.2.401-windows.exe file to it. In the "Commit" custom action, I added that file, removed any arguments and set InstallerClass to False.

现在,当我运行应用程序的安装程序时,PostgreSQL安装程序将启动,显示其初始屏幕,然后跳至100%CPU使用率,并开始长时间(可能超过几分钟)泄漏内存.摆脱困境.在该计算机上运行 .exe 正常.

Now, when I run my application's installer, the PostgreSQL setup starts up, shows its splash screen and then jumps to 100% CPU usage and starts leaking memory for a long time (certainly longer than a few minutes), after which it bails out. Running the .exe on that computer works just fine.

我应该如何在安装程序中打包PostgreSQL?

How should I package PostgreSQL in my installer?

我个人不喜欢静默安装Windows的标准PostgreSQL的程序.收到那些问这是PostgreSQL的东西是什么,为什么它要使用88兆兆兆字节的RAM,我没有要求,现在就删除它!"的人发来的邮件列表帖子感到非常烦人.

Personally I don't like programs that silently install the standard PostgreSQL for Windows. It's deeply annoying to get mailing list posts from people who're asking "What's this PostgreSQL thing and why is it using 88 bajillion megabytes of RAM, I didn't ask for it, remove it now!".

(是的,我主要是在谈论一个烦人的赌博卡计数程序,其名字的首字母为PT,我不会直接提及.)

(Yes, I'm mostly talking about a certain annoying gambling card-counting program with the initials PT whose name I will not mention directly).

如果您要捆绑PostgreSQL,那么可以使用非默认端口和非默认数据目录就很好了.如果您安装了要自动启动的服务,请不要使用默认的服务名称 postgresql- [version] ,而是使用 myapp-database myapp-postgres .

If you're going to bundle PostgreSQL it'd be great if you could use a non-default port and non-default data directory. If you install a service to auto-start it, don't use the default service name postgresql-[version] but something like myapp-database or myapp-postgres.

如果仅将PostgreSQL二进制文件捆绑在安装程序中,然后使用安装程序工具或通过 sc.exe 自己创建服务,则所有操作都将更加容易.您可以选择从程序中简单地 pg_ctl 启动/停止服务器,尽管这需要考虑对数据目录的访问权限.

This is all done much more easily if you just bundle the PostgreSQL binaries in your installer then create the service yourself with your installer tools or via sc.exe. You may choose to simply pg_ctl start/stop the server from within your program, though this requires some thought about access permissions to the data directory.

缺点是,当有PostgreSQL更新时,您需要更新安装程序.另一方面,您可能不会想要人们独立于软件更新来升级PostgreSQL.

The downside is that when there are PostgreSQL updates you need to update your installer. On the other hand, you probably don't want people upgrading PostgreSQL independently of your software updates.

我建议使用此处中的.zip二进制文件并将其捆绑到您的直接安装.

I suggest using the .zip binaries from here and bundling them into your installer directly.

如果您确实必须使用可执行安装程序该文档包含有关静默安装的说明.

If you really must use the executable installer the documentation contains instructions on silent installation.