One
of the new features in deploying Web applications is the Microsoft Web
Deployment Tool, also known as MSDeploy that is a command-line tool
included in the .NET Framework 4 and which can build advanced
deployment scripts. MSDeploy is an advanced tool in that it can
Publish Web applications and their settings.
Deploy SQL Server databases.
Direct advanced deployment to Internet Information Services web servers.
Publish GAC, COM, and Registry settings.
MSDeploy is a complex
tool, and writing the appropriate command lines can be annoying.
Fortunately Visual Studio 2010 allows publishing Web applications via
MSDeploy through the Publish Web dialog as demonstrated later. Before
getting into that, you need to know how Web applications are packaged
before deployment.
Understanding Packages
When you deploy a Web
application via MSDeploy, the application is first packaged into one
archive that makes deployment easier. The package contains all the
required information about the host Web server and files and settings
required by the application. You set package information in the
Package/Publish Web tab of My Project, as shown in Figure 1.
Here you can find default
settings for the local IIS, but you can place settings provided by the
system administrator of the target machine. To build the package,
simply right-click the project name in Solution Explorer and click Build Deployment Package. Basically the package contains the following elements:
The package containing the application and settings
The destination manifest, which contains information on how to reach the target server
The command line script that will be passed to MSDeploy
When you have your package, you are ready to deploy it with MSDeploy.
Deploy with MSDeploy
Visual Studio 2010
provides the opportunity to deploy Web applications with MSDeploy
through its instrumentation. Simply right-click the project name in
Solution Explorer and then click Publish. When the Publish Web dialog appears, select the MSDeploy Publish option from the Publish Method combo box. Figure 2 shows how the dialog appears.
You need to provide some
settings to deploy the Web application with MSDeploy, and most of them
are given to you by the Administrator of the target server. Table 1 summarizes required settings.
Table 1. Required Settings for MSDeploy Publish
Option | Description |
---|
Service URL | The URL of the MSDeploy service provided by the host or administrator. |
Site/Application | The name of the site and application on the target IIS. Here you can include subfolders. |
Mark as IIS application on destination | Will
mark the application as a root if you specify a subfolder in the
Site/Application option. The target server must support this. |
Do not delete extra files on destination | When
unchecked, MSDeploy deletes all files from the target folder before
publishing new files. The suggestion is keeping it unchecked only at
the first publishing. |
Allow Untrusted Certificate | Allows host and administrator to use self-signed certificates, according to the administrator instructions. |
Username/Password | Credentials required to access the target IIS, provided by the server administrator. |
When you provide all required settings, simply click Publish
to get your application deployed to the Web server with MSDeploy,
remembering that this tool provides the opportunity to deploy
additional requirements such as SQL Server databases and GAC settings.