I'm just looking for some advice/best practice for this situation:

We have a solution with a couple of web sites in it (one is a web site project, the other is a web application project). We have both of these sites set up to use our installed IIS (v7), as we have other projects that we need to access these via localhost whilst debugging.

We've just moved to TFS (from GIT) - when we switch branches, I have to go and 'repoint' my virtual directories under IIS to point at the new branch, which is a bit of a nuisance. Does anybody have any advice/guidance as to what is the best way to approach this? I would note that I don't think that switching to using Cassini will suit our situation.

5 Answers 5


IIS Express might be an option. This article is about IIS Express with SSL but also can give you some idea's on how to configure for your problem.

Remember that IIS Express is really IIS. It's just "local personal not-a-service" IIS. That means that IISExpress puts its config files in C:\Users\YOU\Documents\IISExpress\config rather than in some machine-wide location.

My project is called "MvcApplication18" so I can open up my ApplicationHost.config and look for "MvcApplication18." You can too. There's my site, right there, in IISExpress's applicationHost.config:

<site name="MvcApplication18" id="39">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="c:\users\scottha\documents\visual studio 2010\Projects\MvcApplication18\MvcApplication18" />
        <binding protocol="http" bindingInformation="*:15408:localhost" />

An other option might be to script the repointing of the virtual directories and call it where you think is appropriate (pre build step, separate script) MSBuild extensions could get you started in that direction.

Hope this helps.


I solve this by having multiple web applications defined in IIS and then save the new URL in the branched project (as most of IIS's configuration is in the web.config there is little else to do).

This also has the benefit of being able to operate with both in parallel (eg. comparing last checkpoint/release to current side by side).


One of my colleagues had the bright idea of specifying the path in IIS using an environment variable - we then have a simple script to run when we switch branches to update that variable and 'tada' all our sites are pointing to the right place...


Actually switching to Cassini or IIS Express is a solution. IIS has no knowledge about TFS or branches so you must reconfigure it each time you do the switch (either manually or by manual execution of some script).


One method might be to use in place branch switching. Instead of mapping each branch to a seperate folder, instead remap your second branch into the same folder as the previous when switching. A good blog post on this approach is from Richard Banks at http://www.richard-banks.org/2011/03/how-to-in-place-branch-switching-with.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.