Yesterday I blogged about detecting IIS version from MSBuild, or more accurately, OS version. Detecting whether my MSBuild script was running on XP allowed me to skip the application pool creation that would otherwise error out the build script.
What I didn't expect was that the website creation task would actually succeed in creating a secondary website in IIS 5.1. I vaguely remember from other blog posts how its possible to programmatically create secondary websites in IIS 5.1, but didn't realize it was so easy. Just for the record the following snippet also works against IIS 6 and 7. The following build script does exactly that.
That takes care of new site creation, only optionally creating the site if it doesn't already exist, but always modifying it to ensure consistent settings. The final piece we need is to stop running "Default Web Site" and start the new site. IIS 5.1 can only run one site at a time so this is why we stop the default site and explicitly start the new site.
Once the script finishes we can check in inetmgr to see the new IIS 5.1 site right along side the default web site.
Are you wondering why I would go to all this trouble of monkeying around with IIS for development? Well you should be. The reason is that the Visual Studio web server does not support ISAPI filters, and since I'm doing URL rewriting at the ISAPI level, running under IIS is the only option.
Powered by: newtelligence dasBlog 2.1.8102.813
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Shawn Neal
E-mail