15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

simple Deployment options ❘ 411<br />

Xcopy <strong>and</strong> Web applications<br />

Xcopy deployment can also work with web applications with the exception of the folder structure. You must<br />

establish the virtual directory of your web application <strong>and</strong> configure the proper user rights. This process is<br />

generally accomplished with the IIS administration tool.<br />

After the virtual directory is set up, the web application files can be copied to the virtual directory. Copying<br />

a web application’s files can be a bit tricky. A couple of configuration files, as well as the images that the<br />

pages might be using, need to be accounted for.<br />

Publishing a Web site<br />

Another deployment option for web projects is to publish the web site. Publishing a web site will precompile<br />

the entire site <strong>and</strong> place the compiled version into a specified location. The location can be a file share, FTP<br />

location, or any other location that can be accessed via HTTP. The compilation process strips all source<br />

code from the assemblies <strong>and</strong> creates the DLLs for deployment. This also includes the markup contained<br />

in the .ASPX source files. Instead of containing the normal markup, the .ASPX files contain a pointer to an<br />

assembly. Each .ASPX file relates to an assembly. This process works regardless of the model: code-behind or<br />

single file.<br />

The advantages of publishing a web site are speed <strong>and</strong> security. Speed is enhanced because all the assemblies<br />

are already compiled. Otherwise, the first time a page is accessed there is a delay while the page<br />

<strong>and</strong> dependent code is compiled <strong>and</strong> cached. The security is enhanced because the source code is not<br />

deployed. Also, because everything is precompiled before deployment all compilation errors will<br />

be found.<br />

You publish a web site from the Build - Publish menu choice. In the Publish Method drop-down menu, you<br />

can choose MSDeploy Publish, FTP, or file system. The FTP option will ask for the FTP address as well as<br />

any login credentials that will be needed. The file system option will ask for the path to the target location.<br />

The MSDeploy Publish option is the interesting option.<br />

You can define many properties for the deployment of your web site from the Package <strong>and</strong> Publish tab of<br />

the project properties page. You can define what files should be included, including debug information.<br />

Database information from the Deploy Sql tab can be included. This information includes connection<br />

strings, schema information <strong>and</strong> database script options.<br />

You can also select packaging options from here. A zip file that contains everything you need to install your<br />

web site will be generated. Along with the zip file, three other files will be generated:<br />

➤<br />

➤<br />

➤<br />

projectname.deploy.cmd — A comm<strong>and</strong> file used by MSDeploy to install the web site.<br />

projectname.SetParameters.xml — An XML file that contains different parameters to pass<br />

to the Web Deployment Tool. This can be used to deploy to different servers or in different<br />

environments.<br />

projectname.SourceManifest.xml — Settings used by Visual Studio 2010 to create the<br />

package.<br />

Projectname is the name of your project that is being packaged. Packages can be deployed using Visual<br />

Studio or by MSBuild.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!