Setup of new development environment is a very time consuming operation each time (no matter what the reason is: moving to new project, OS reinstall, hardware update). Tools are getting better and better each day, now having fast internet connection and package managers, like NuGet and NPM we waste less time on installing all the required dependencies. But today I want to dig into small, but very easy-to-automate part of development environment setup part – adding and configuring site on IIS.
You can think, that it’s a deal of 5 minutes to add a new site to IIS and to change a couple of required options. If you already did it before – of course. But what if you need to help 2-3 other developers or newcomers? What if someone from QA group will miss some options and you’ll not find it really quickly?
In such kind of situation I prefer to reduce the human factor as much as possible. And it’s the place, where console tools can help a lot.
To work with IIS configuration from console you should use appcmd tool. Unfortunately this tool is not well-documented in my opinion. Basic documentation is quite good, but there are a lot parameters, which can be used and not all of them described in the documentation.
To start working with the tool I recommend to use this command: %systemroot%\system32\inetsrv\appcmd – it will put you to the right place. Buy typing this command directly you should see something like on the screenshot below:
There dozen of objects as you can see and couple of commands (basically it’s verb like add or remove). But as far as we are talking about development environment setup you’ll most likely will require only add command and two objects:
To receive some guidelines you should use /? symbols (as usual). So it will look like this:
# This one for adding sites: %systemroot%\system32\inetsrv\appcmd add site /? # This one for adding application pools: %systemroot%\system32\inetsrv\appcmd add apppool /?
Unfortunately this command will not give you all required information, just a generic idea. But, if you’ll add value for required parameter you get the full list of available parameters (without values, which can be used, but anyway it’s already some starting point):
# This one for getting full list of parameters for adding site: %systemroot%\system32\inetsrv\appcmd add site /name:test /? # This one for getting full list of parameters for adding application pool: %systemroot%\system32\inetsrv\appcmd add apppool /name:test /?
Here is the couple of properties I’ve changed for the purposes of my project (these all options for Application Pools only):
- managedRuntimeVersion. Possible values:
- Leave blank (no managed code option);
- enable32BitAppOnWin64. Possible values:
- managedPipelineMode. Possible values:
- processModel.identityType. Possible values:
I didn’t find any way to get list of possible values from the application itself. If you’ll find – please, leave a comment, I’ll update this post to share this information.