Main Page

  Previous Section Next Section

11.3 Deploying Through Visual Studio .NET

If you are using Visual Studio .NET to create your web applications, you have some additional deployment options at your disposal. These options include simply using Visual Studio's Copy Project command to copy some or all project files to a new location and using a Web Setup project to create a Windows Installer package to install the web application, including creating the necessary IIS directories. These techniques are discussed in the following sections.

In addition to these options, Visual Studio .NET allows you to open a project directly from the Web, so you could theoretically create the project directly on the target server and edit it there. This is only recommended for development systems, since incorrect edits made using this technique on production systems could result in application errors or downtime. To open a project from the Web, simply open Visual Studio .NET and select File Open Project From Web....

11.3.1 Deploying Using Copy Project

The simplest option for deploying a project from Visual Studio is to use the Copy Project command. You can access Copy Project by either selecting Copy Project... from the Project menu or clicking the Copy Project button in the Solution Explorer toolbar, as shown in Figure 11-1.

Figure 11-1. Copy Project button in Solution Explorer

Either method will open the Copy Project dialog, shown in Figure 11-2.

Figure 11-2. Copy Project dialog

The Copy Project dialog gives you a number of options. The first is the destination folder for the project, which is expressed as a URL. You can either enter this URL manually or browse to the desired URL by clicking the ellipsis (...) button.

If you use the browse feature, however, you must select a resource that resolves to a valid URL, such as a web folder in My Network Places.

To copy the project files, you can use either file share access (for copying locally or to a network share) or FrontPage access. FrontPage access requires author permission on the destination web server. If you use FrontPage as the web access method, the destination project folder will be created automatically in IIS, while the File share method requires that you set up this folder manually.

Finally, you have three choices of which files to copy:

Only files needed to run this application

Copies only the Web Forms, web services, and associated assemblies, without copying any code-behind files to the destination server. This allows you to copy and run your project on another machine without exposing the source code. This option also copies images, style sheets, and other static content as well.

All project files

Copies all files associated with the project to the destination machine, including code-behind files. This option will not copy files contained in the project folder that are not associated with the project. To keep a file from being copied, you can right-click the file in the Solution Explorer window and select Exclude From Project.

All files in the source project folder

Copies all files from the project folder, whether they are associated with the project or not. This option is useful for moving a project from one development machine to another, particularly if you will need to continue developing the application on the target machine.

Note that regardless of the options you choose, you must build your project before deploying it, so that any code in code-behind modules is compiled into assemblies.

11.3.2 Deploying Using a Web Setup Project

Visual Studio .NET also adds a completely new project type that now makes it possible to create an installation package for installing (and uninstalling) a web application as easily as any other application. The new project type is called the Web Setup Project, and it is available in the Setup and Deployment Projects folder in the New Project dialog, as shown in Figure 11-3. You can create a Web Setup Project in a standalone solution or as part of the solution containing your web application project. This section provides an overview of this project type and of how you can use it to deploy your web application.

Figure 11-3. New Project dialog

To create a Web Setup Project, select File New Project.... Then select the Setup and Deployment Projects folder in the lefthand pane of the New Project dialog. Next, select Web Setup Project in the righthand pane. Then fill in the Name and Location boxes and click OK. If you want to add the new project to an existing solution, you should open that solution first and then click the Add to Solution radio button in the New Project dialog.

Once the project is created, you'll be presented with the File System window (see Figure 11-4), which allows you to add files to be deployed to the target system. In addition to the File System window, the Web Setup Project type offers windows for adding Registry entries and File Type associations, as well as for modifying the user interface that will be displayed by the installer. These windows can be viewed by right-clicking the project name in the Solution Explorer and selecting View <windowname>.

If you created your web setup project as part of the solution containing your web application, you can add all of the necessary files from the application to the setup project simply by right-clicking the Web Application Folder, selecting Add Project Output..., and then selecting both Primary Output and Content Files, as shown in Figure 11-5.

Figure 11-4. File System window
Figure 11-5. Add Project Output dialog

Now, if you build the setup project (note that you should create a fresh build of the web application project first), all necessary files for the web application will be included in the generated setup files.

These files will be located in either the Debug or Release subfolder of the project, depending on whether the Debug or Release configuration is selected in the solution's Configuration Manager.

If you created the web setup project in its own standalone solution, you'll need to add the files manually. Perhaps the easiest way to do this is to highlight the desired files in Windows Explorer and then drag and drop them from Windows Explorer onto the Web Application folder. This will add all selected files and folders to the web application. This step should work fine unless you need to mark any of the subfolders of the application as IIS applications.

In this case, you'll need to create separate folders for them by right-clicking the File System on Target Machine entry in the File System window, and then selecting Add Special Folder Web Custom Folder. By default, the folder's IsApplication property, which determines whether the folder will be configured as an IIS Application, is set to True. You can use the Property Browser to modify this setting, if desired.

In addition to setting the IsApplication property for Web Custom Folders, you can use the property browser to set a variety of other IIS-specific configuration options for the folders in your setup project. For example, you can specify whether a given folder will allow read or write access or directory browsing, as well as whether the folder should be indexed. This way, you can provide all of the application configuration automatically, allowing the person installing the application to simply double-click the setup file generated by the project and follow a few brief wizard steps to install the application.

Once you've configured the application folders, you will need to build the project to create the setup files. Then you can copy or transfer those files to another machine, run Setup.exe, and the application should install and run normally.

      Previous Section Next Section