Switching Between Multiple ASP.NET Projects
I'm currently working on several different web projects on my WinXP Pro development machine. Not all of these projects reside in virtual directories, so I have the need to change the home directory of the default web site a lot. Here's a batch file that will make all of the necessary changes in one step. It assumes that you have the IIS5 admin script 'adsutil.vbs' installed on disk somewhere (but not necessarily available via IIS for security reasons).
@echo off
if "%1" == "" goto usage
set webroot="C:\DoesNotExist"
REM *************************************
REM * Add one line for each web project *
REM *************************************
if /i %1 == project1 set webroot="C:\Development\Project1\Website\wwwroot"
if /i %1 == project2 set webroot="C:\Development\Project2\Website\wwwroot"
if exist %webroot% (goto begin) else (goto notag)
:begin
echo Changing IIS metabase settings...
C:\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/Root/Path %webroot% > nul
echo Deleting Visual Studio.NET web cache...
if exist "%USERPROFILE%\VSWebCache" rd /s /q "%USERPROFILE%\VSWebCache"
echo Restarting IIS...
iisreset /restart
goto end
:usage
echo.
echo This command modifies the home directory settings of your primary
echo web site and removes the contents of your Visual Studio.NET web
echo cache. It is used to automate the process a developer navigates
echo when developing multiple web sites on a single machine.
echo.
echo Usage: changeiis.cmd [website tag]
echo Example: changeiis.cmd project1
echo.
goto end
:notag
echo.
echo "%1" does not map to a valid directory.
echo.
:end