Understanding the Visual Studio .NET Deployment Utility


For ATL Server projects in Visual Studio .NET, there is a small deployment utility that automates the tasks described in the previous section for you (on the local machine). The tasks required to deploy a Web application are as follows :

  1. Use the ISM tool to create a virtual directory corresponding to a real directory on your machine.

  2. Copy the files for your Web application to this virtual directory.

  3. Configure the virtual directory (application mappings, protection level, and so on).

  4. Restart IIS.

  5. Modify the files, recopy them, and restart IIS if appropriate (repeatedly throughout development cycle).

These tasks can become repetitive. Although you need to configure your vroot only once, you do have to keep copying files to the appropriate directory, reset IIS if appropriate, and then launch your application, find any bugs , modify the appropriate files, and repeat this cycle. To simplify this task, the ATL Server team created a deployment utility that s exposed via the Properties page for a given project. To access this utility, right-click the project, select Properties, and look for the Web Deployment option at the bottom of the window.

The underlying command-line utility for this deployment system is the vcdeploy.exe tool located in the VC7\bin directory of your installation. This utility uses an XML configuration file to determine what files to deploy and what settings to enable (on the vroot) for this vroot.

The vcdeploy tool is capable of registering file extensions (to a given file) for a given vroot, copying files to a given vroot, and then stopping and restarting the w3svc service. In addition, it can perform many other common setup functions for deploying Web applications and configuring vroots.

Although the underlying XML schema for this utility may change, we provide examples of configuration scripts here so that you may better understand the working of the utility, perhaps customize it for your own use, or at the very least be more capable of creating functional deployment utilities yourself. Although the utility is limited to localhost through the IDE, there s no reason why it shouldn t work to deploy to a remote machine ( assuming the user has a valid account with appropriate security permissions on the remote machine ”usually as an administrator) if you change the machine from localhost to the name of the remote machine.

The first example schema in Listing 7-1 shows the creation of the vroot Postershop at the path d:\inetpub\ wwwroot \mantaweb\postershop. The APPISOLATION setting allows the user to specify the application protection for the application (0=Low, 1=Medium, and 2=High). The APPFILEGROUP setting allows the developer to specify which source files to copy to which destination (relative to the vroot).

Listing 7.1: Example Vcdeploy XML Configuration File
start example
 <?xml version="1.0" encoding="Windows-1252"?>  <ATLSINSTSETTINGS>    <WEBHOSTNAME>localhost</WEBHOSTNAME>    <VIRTDIRNAME>Postershop</VIRTDIRNAME>    <VIRTDIRFSPATH>d:\inetpub\wwwroot\MantaWeb\Postershop</VIRTDIRFSPATH>    <APPISOLATION>0</APPISOLATION>    <APPFILEGROUP>      <APPFILENAME>        <SRC>d:\projects\demo\Postershop\Postershop.srf</SRC>        <DEST>Postershop.srf</DEST>      </APPFILENAME>      <APPFILENAME>        <SRC>d:\projects\demo\Postershop\Debug\Postershop.dll</SRC>        <DEST>Postershop.dll</DEST>      </APPFILENAME>    </APPFILEGROUP>  </ATLSINSTSETTINGS> 
end example
 

The second example in Listing 7-2 shows the deployment of the same application, but this time you re sending an ISAPI DLL (instead of the application DLL). This means you use the APPMAPPING tag to map the file extensions .srf and .dll to the ISAPI DLL that you re deploying. You also indicate which verbs you want to enable for these mappings (all other verbs will be disabled). By using the type="extension" parameter on the APPFILENAME tag, you ensure that the w3svc service will be stopped and then restarted after this file has been copied . Again, the destination directory is given relative to the root directory of the vroot.

Listing 7.2: Vcdeploy Configuration File for Sending an ISAPI DLL and Registering Against It
start example
 <?xml version="1.0" encoding="Windows-1252"?>  <ATLSINSTSETTINGS>    <WEBHOSTNAME>localhost</WEBHOSTNAME>    <VIRTDIRNAME>Postershop</VIRTDIRNAME>    <VIRTDIRFSPATH>d:\inetpub\wwwroot\MantaWeb\Postershop</VIRTDIRFSPATH>    <UNLOADBEFORECOPY>true</UNLOADBEFORECOPY>    <APPISOLATION>0</APPISOLATION>    <APPMAPPING fileext=".srf">      <VERB>GET</VERB>      <VERB>HEAD</VERB>      <VERB>POST</VERB>      <VERB>DEBUG</VERB>    </APPMAPPING>    <APPMAPPING fileext=".dll">      <VERB>GET</VERB>      <VERB>HEAD</VERB>      <VERB>POST</VERB>      <VERB>DEBUG</VERB>    </APPMAPPING>    <APPFILEGROUP>      <APPFILENAME type="extension">        <SRC>d:\projects\demo\PostershopIsapi\Debug\PostershopIsapi.dll</SRC>        <DEST>PostershopIsapi.dll</DEST>      </APPFILENAME>    </APPFILEGROUP>  </ATLSINSTSETTINGS> 
end example
 

In addition to trying out deployment to remote machines, you could also use this configuration file to try automating deployment to multiple machines by offering multiple WEBHOSTNAME s.

To invoke the vcdeploy utility with a given configuration file (e.g., d:\config.xml) you would run this:

 vcdeploy d:\config.xml 

To silently run the utility (e.g., as part of a batch build) you would use the nologo option:

 vcdeploy /nologo d:\config.xml 

Of course, if your configuration file is in the directory that you re running the command from, there s no reason to give a path to the configuration file.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net