Introduction
The ASP.NET IIS Chameleon is a tool to set one specific IIS Virtual Directory for a lot versions of the same web project.
Background
Some web projects in our company, have at least two versions:
- "internal" - An internal beta version, where the team builds new features.
- "launched" - All the already launched versions of the same project.
Our developers team need to code/correct both versions, depending on the necessity. Therefore, we need to switch faster between all these versions. Now, we're working with both versions: VS2003 (.NET Framework 1.1) and VS2005 (.NET Framework 2.0). We have designed a structure for our development machines, that makes it easy to apply changes and manage our source code, linked with specific virtual directories. Take a look at the structure design:
Challenge
Each developer needs to map, as soon as possible, a specific version of a project (this one could be a random physical directory) to its IIS Web Shared Directory, so our team can start the maintenance or new implementations.
Older Solution
Well, for each "version change process", a developer needs to check in all files, get the specific/target version, then run aspnet_regiis.exe* for the specific metabase path and for the specific .NET Framework version. Another solution is running the Internet Information Services (inetmgr.exe), and then change the physical directory for a specific virtual directory, and the ASP.NET version too.
Newer Solution
Basically, we build a Windows Forms application tool named IISChameleon to join and automate some aspnet_regiis.exe and inetmgr.exe tasks. This tool was built with VS2005 and runs over .NET Framework 2.0. Our team has Windows XP Professional and Internet Information Services 5.1.
How To Use
This tool will load a list of all the virtual directories in your machine; just select the entry, change all values you want, and click the Update button, and hands on.
How IISChameleon Works
We take advantages of the System.DirectoryServices.DirectoryEntry
class from System.DirectoryServices.dll and the process aspnet_regiis.exe.
DirectoryEntry* Class
Before manipulating entries on IIS with the DirectoryEntry
class, we need to know the basic ideas about how IIS manages these entries. Each IIS entry (web site, web virtual directory, FTP virtual directory, ...) has a schema name and a collection of properties. All entries follow a hierarchy, with parent entries and children entries. These hierarchies are defined by a metabase path, which means that every entry, similar to physical directories, has a path. A sample of this hierarchy can be viewed in the following picture (a shot of the Metabase Editor* tool):
To instantiate a DirectoryEntry
, we basically need its metabase path.
DirectoryEntry directoryEntry =
new DirectoryEntry("IIS://localhost/w3svc/1/root");
The most of its properties should be accessed by indexers.
Console.Write( directoryEntry.Properties["Path"].Value.ToString() );
ASP.NET IIS Registration Tool (aspnet_regiis.exe)
This is used to discover all ASP.NET versions in the current machine, and to register a version of ASP.NET for a specific virtual directory.
Definitions File
The definitions.xml is used to store information about all the runtimes installed. So, maybe you will edit this one.
<runtimeVersions>
<version alias="1.1" baseDir="v1.1.4322" full="1.1.4322.2032"/>
<version alias="2.0" baseDir="v2.0.50727" full="2.0.50727.0"/>
</runtimeVersions>
IISChameleon User Interface
To build the user interface, we use some native controls coming from .NET Framework 2.0 and a simple JPGrid*.
Conclusion
IISChameleon, when combined with a standard structure of directories and versions, could be usual for developer teams, and support teams too.
References