如何读取自定义 boostrapper/安装程序中的 msi 输出文件夹?
我启动了一个 Windows 窗体项目,本质上它将下载几个 Zip 文件,解压缩它们并运行安装程序 .msi
,而且它必须能够要求在 Web 中替换 SQL 连接值在安装程序之一中创建的站点
例如:
- 从
http://domain.com/apps/site.zip
下载 Web Proeject 安装程序并安装 - 下载 MS Charts从
http://domain.com/apps/mscharts.zip
并安装它 - 询问服务器、数据库、用户名和密码并替换
web.config
这就是我的尝试这样做,我知道我可以使用 DotNetInstaller 甚至 Wix 为此,但这两个项目都很大并且学习曲线很高,所以我创建了自己的安装程序。
我的问题是,在我运行 Process
来安装 Web 安装程序(Visual Studio 创建的 msi
)后,如何获得完整的用户选择安装站点的路径?
需要查找 web.config
文件的位置,以便正确附加新的 SQL Server 连接值。
site.msi
仅使用 int returnCode = process.ExitCode;
返回一个整数值,而不是输出路径..
只是大声思考
我可能可以在 site.msi
上创建一个自定义函数,将一些值写入注册表,然后我可以安全地读取我的自定义安装程序...这是一个可行的选择吗?
在这样的环境下我能做什么?
I started a Windows Forms project that in essence it will download several Zip files, un-compress them and run the installer .msi
plus it had to be able to ask SQL connection values to be replaced in the Web Site that creates in one of the installer
For example:
- Download a Web Proeject installer from
http://domain.com/apps/site.zip
and install it - Download MS Charts from
http://domain.com/apps/mscharts.zip
and install it - Ask Server, Database, Username and Password and replace the
web.config
This is what I'm trying to do, I know I can use DotNetInstaller or even Wix for this, but both projects are huge and the learning curve is high, so I created my own Installer.
My question is, after I run the Process
to install the web setup (a msi
that Visual Studio created), how can I get the Full Path of where the user choose to install the site?
This is needed to find out where is the web.config
file in order to correctly append the new SQL Server connection values.
The site.msi
only returns an integer value using int returnCode = process.ExitCode;
never the output path ..
Just thinking out loud
I probably can create a Custom Function on the site.msi
to write some value into to Registry and then I can safely read on my custom installer ... is this a viable option?
What can I do in such environment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 WMI 搜索设置的 MSI 安装程序 web.config 组件:
首先,您必须识别 web.config 组件的组件 GUID。使用 Microsoft Orca 工具打开 MSI 安装程序包(您将找到
Windows 7 SDK 中的 Orca 工具)。
导航到文件表。在中搜索 web.config
文件名列。记住 Component_ 列中 web.config 组件的 ID。
然后导航到组件表。使用文件表中找到的 ID 搜索您的组件。
复制 ComponentId 列中找到的 GUID。这是您的组件 GUID
web.config 文件。
现在,在以下代码中使用确定的组件 GUID:
同样,创建自定义安装程序操作以将安装路径写入注册表
也是个好主意!
希望这有帮助。
You could use WMI to search for the MSI installer web.config component of your setup:
First you have to identify the component GUID for your web.config component. Open your MSI installer package by using the Microsoft Orca tool (you will find the
Orca tool in the Windows 7 SDK).
Navigate to the File table. Search for web.config in
the FileName column. Remember the ID for the web.config component in the Component_ column.
Then navigate to the Component table. Search for your component with the ID found in the file's table.
Copy the GUID found in the ComponentId column. This is the component GUID for your
web.config file.
Now, use the determined Component GUID in the following code:
By the same token, creating a custom installer action to write the install path to the registry
is also a good idea!
Hope, this helps.
通常的方法是将其写入注册表:
在 [Manufacturer] 下添加一个新项并命名
[ProductName]
在此新键中添加一个具有以下值的字符串条目:
[TARGETDIR]
这样,您的 MSI 就会在该注册表值中写入安装路径。然后,您的安装程序可以从注册表中读取路径。
The usual approach is writing it in the registry:
add a new key under [Manufacturer] and name it
[ProductName]
in this new key add a string entry with this value:
[TARGETDIR]
This way you MSI will write the installation path in that registry value. Your installer can then read the path from registry.