I have an Web Setup Project Installer and I would like to default the site and the Application Pool that is selected during the install process. Also I would like to have the name of the product 开发者_C百科append the current version number during the build process of the installer.
Any help would be greatly appreciated! Thank you
The Visual Studio Web Setup Project is quite a simple (and not too flexible) tool. You have some options, though (assuming you are not ready to switch to using something more flexible such as WiX or a commercial installation packaging product).
Modify the MSI After Building
One way to do what you want is to modify the MSI file after it has been built.
You can add properties such as the following:
Add a property named
TARGETSITE
and set it to the metabase path of the site you need to be the default. For example,/LM/W3SVC/2
.Add a property named
TARGETAPPPOOL
and set it to the name of the application pool you need to be the default. For example,MyAppPool
.You can also set the product name by editing the existing
ProductName
property.
Making changes to MSI files can be achieved manually with tools such as InstEdit or ORCA (which is part of the Windows SDK).
Alternatively, you can create/find MSBuild tasks to get and set properties in MSI files. This gives you a nice way to automatically make the desired changes during automated builds.
Invoke with Commandline Arguments
More simply, you can invoke the installation from the command-line using msiexec.exe and specifying values for the TARGETSITE
and TARGETAPPPOOL
properties, for example:
msiexec /i MySetup.msi TARGETSITE=/LM/W3SVC/2 TARGETAPPPOOL=Pool2
You can't mess about with the ProductName
this way, though.
Open the MSI in Orca. Go to Property, right click and right click to add Row.
Property: TARGETAPPPOOL value: ASP.NET v4.0
You can do the same using this VBS script:
Dim oDatabase 'As WindowsInstaller.Database
Const msiOpenDatabaseModeTransact = 1
Dim oInstaller 'As WindowsInstaller.Installer
Dim sFilePath 'As String
sFilePath = "C:\Test\MySetup.msi"
Set oInstaller = CreateObject("WindowsInstaller.Installer")
Set oDatabase = oInstaller.OpenDatabase(sFilePath, msiOpenDatabaseModeTransact)
sql = "INSERT INTO Property (Property, Value) VALUES ('TARGETAPPPOOL', 'ASP.NET v4.0')"
Dim oView 'As WindowsInstaller.View
Set oView = oDatabase.OpenView(sql)
oView.Execute
oView.Close
oDatabase.Commit
MsgBox ("Done!")
精彩评论