ASP.NET IIS Chameleon Tool (ASP.NET IIS 变色龙工具)






4.47/5 (8投票s)
2005年12月20日
3分钟阅读

73441

457
A tool to set one specific IIS Virtual Directory for a lot versions of the same web project. (一个为同一个 Web 项目的多个版本设置特定 IIS 虚拟目录的工具。)
引言
The ASP.NET IIS Chameleon is a tool to set one specific IIS Virtual Directory for a lot versions of the same web project. (ASP.NET IIS 变色龙是一个为同一个 Web 项目的多个版本设置特定 IIS 虚拟目录的工具。)
背景
Some web projects in our company, have at least two versions (我们公司的一些 Web 项目,至少有两个版本)
- "internal" - An internal beta version, where the team builds new features. ("internal" - 一个内部测试版本,团队在其中构建新功能。)
- "launched" - All the already launched versions of the same project. ("launched" - 同一个项目的所有已发布版本。)
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 (我们的开发团队需要根据需要编写/更正这两个版本。 因此,我们需要在所有这些版本之间更快地切换。 现在,我们正在使用两个版本:VS2003 (.NET Framework 1.1) 和 VS2005 (.NET Framework 2.0)。 我们为我们的开发机器设计了一种结构,可以轻松应用更改和管理我们的源代码,并链接到特定的虚拟目录。 查看结构设计)
挑战
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. (每个开发人员需要尽快将项目的特定版本(这可能是一个随机物理目录)映射到其 IIS Web 共享目录,以便我们的团队可以开始维护或新的实现。)
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. (嗯,对于每个“版本更改过程”,开发人员需要检入所有文件,获取特定/目标版本,然后为特定元数据库路径和特定 .NET Framework 版本运行 aspnet_regiis.exe* 。 另一个解决方案是运行 Internet Information Services (inetmgr.exe),然后更改特定虚拟目录的物理目录,以及 ASP.NET 版本。)
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. (基本上,我们构建了一个名为 IISChameleon 的 Windows Forms 应用程序工具,用于加入和自动化一些 aspnet_regiis.exe 和 inetmgr.exe 任务。 此工具使用 VS2005 构建,并在 .NET Framework 2.0 上运行。 我们的团队拥有 Windows XP Professional 和 Internet Information Services 5.1。)
如何使用
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 (IISChameleon 的工作原理)
We take advantages of the System.DirectoryServices.DirectoryEntry
class from System.DirectoryServices.dll and the process aspnet_regiis.exe. (我们利用了 System.DirectoryServices.dll 中的 System.DirectoryServices.DirectoryEntry
类和进程 aspnet_regiis.exe。)
DirectoryEntry* Class (DirectoryEntry* 类)
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) (在使用 DirectoryEntry
类在 IIS 上操作条目之前,我们需要了解 IIS 如何管理这些条目的基本概念。 每个 IIS 条目(网站、Web 虚拟目录、FTP 虚拟目录等)都有一个模式名称和一组属性。 所有条目都遵循一个层次结构,具有父条目和子条目。 这些层次结构由元数据库路径定义,这意味着每个条目都类似于物理目录,都有一个路径。 可以在下图(元数据库编辑器*工具的截图)中查看此层次结构的示例)
To instantiate a DirectoryEntry
, we basically need its metabase path. (要实例化一个 DirectoryEntry
,我们基本上需要它的元数据库路径。)
DirectoryEntry directoryEntry =
new DirectoryEntry("IIS:///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) (ASP.NET IIS 注册工具 (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. (这用于发现当前机器中的所有 ASP.NET 版本,并为特定虚拟目录注册一个 ASP.NET 版本。)
Definitions File (定义文件)
The definitions.xml is used to store information about all the runtimes installed. So, maybe you will edit this one. (definitions.xml 用于存储有关所有已安装的运行时的信息。 所以,也许你会编辑这个。)
<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 (IISChameleon 用户界面)
To build the user interface, we use some native controls coming from .NET Framework 2.0 and a simple JPGrid*. (为了构建用户界面,我们使用来自 .NET Framework 2.0 的一些本机控件和一个简单的 JPGrid*。)
结论
IISChameleon, when combined with a standard structure of directories and versions, could be usual for developer teams, and support teams too. (IISChameleon,当与目录和版本的标准结构相结合时,对于开发团队和支持团队来说可能很常用。)
参考文献
- DirectoryEntry
- ASP.NET IIS Registration Tool (aspnet_regiis.exe) (ASP.NET IIS 注册工具 (aspnet_regiis.exe))
- Metabase Editor Tool (元数据库编辑器工具)
- JPGrid is just a fast, simple, and objective Windows Forms custom grid control. (JPGrid 只是一个快速、简单且客观的 Windows Forms 自定义网格控件。)