Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / operating-systems / Windows

Post-build event to select the default app pool for a web project

4.50/5 (2 votes)
28 Aug 2011CPOL1 min read 18.4K  
Lets you predefine the app pool

Introduction


I recently needed to modify an installation MSI for a website deployment. The "Installation Address" dialog box for a website install doesn't allow customization except for the bitmap, which isn't particularly useful. I needed to modify the default app pool to prevent installation problems.


Background


There are several ways to do this. You can use Orca to open the MSI file and add the property. You can use msiexec.exe from the command line and specify what property you want set. What I wanted was to create a standalone MSI file that did this automatically when the MSI was run.


Using the code


The solution I came up with is to add a post-build event to the setup project. To do this, you'll use Cscript and WiRunSQL.vbs.


The first step is to find Cscript.exe, which for me was located in :


C:\Windows\SysWOW64\Cscript.exe

The second step is to find WiRunSQL.vbs which I put in C:\ for simplicity:


c:\WiRunSQL.vbs

To construct the MSI, use the following code to get the correct output. It adds the filename by itself so it's really the path + filename. No need to specify the name of the MSI file.


$(BuiltOuputPath)

The last part you'll need is the insert command itself. All the punctuation marks are required. Also keep in mind that the only part you'll need to change is the underlined part:


SQL
"INSERT INTO `Property` (`Property`,`Value`) VALUES ('TARGETAPPPOOL','TheAppPoolName you want to use')"

Points of Interest


The final step then is to string these four items together into one command, which will look like:


C:\Windows\SysWOW64\Cscript.exe c:\WiRunSQL.vbs $(BuiltOuputPath) "INSERT INTO `Property` (`Property`,`Value`) VALUES ('TARGETAPPPOOL','TheAppPoolName you want to use')"

Pretty simple once you know how to do it, but it's the learning part that's hard. I hope that you find this useful!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)