How do I read the msi output folder in a custom boostrapper/installer?
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 creat开发者_如何学Pythones 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?
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:
ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2"); ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_SoftwareElement WHERE SoftwareElementID='{YOUR WEB CONFIG GUID}'"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); ManagementObjectCollection queryCol = searcher.Get(); foreach(ManagementObject m in queryCol) { Console.Out.WriteLine("Path to web.config: {0}", m["Path"]); }
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.
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?
The usual approach is writing it in the registry:
- in your Visual Studio setup project go to Registry editor
- select "Software[Manufacturer]" key under HKEY_LOCAL_MACHINE or under HKEY_CURRENT_USER
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.
精彩评论