Simple Deployment C# Help

If deployment is part of an application’s original design considerations, deployment can be as simple as copying a set of files to the target computer. For a Web application, it can be a simple menu choice in Visual Studio 2008. This section discusses these simple deployment scenarios .

To see how the various deployment options are set up, you must have an application to deploy. The sample download at contains three projects: SampleClientApp, SampleWebApp,and AppSupport. SampleClientApp is a smart client application. SampleWebAppis a simple Web app. AppSupport is a class library that contains one simple class that returns a sh’thg with the current date and time. sampleClientApp and SampleWebAppuse AppSupport to fill a label with the output of AppSupport. To use the examples, first load and build AppSupport. Then, in each of the other applications, set a reference to the newly built AppSupport .dll.

Here is the code for the AppSupport assembly:

This simple assembly suffices to demonstrate the deployment options available to you.


Xcopy deployment is a term used for the process of copying a set of files to a folder on the target machine and then executing the application on the client. The term comes from the DOS command xcopy. exe. Regardless of the number of assemblies, if the files are copied into the same folder, the application will execute – rendering the task of editing the configuration settings or registry obsolete.

To see how an xcopy deployment works, execute the following steps:

  1. Open the SampleClientApp solution (SampleClientApp. sln) that is part of the sample download file.
  2. Change the target to Release and do a full compile.
  3. Next, use either My Computer or File Explorer to navigate to the project folder \SampleClientApp\’ bin \Release and double-click SampleClientApp. exe to run the application.
  4. Now, click the button to open another dialog. This verifies that the application functions properly. Of course, this folder is where Visual Studio placed the output, so you would expect the application to work.
  5. Create a new folder and call it ClientAppTest. Copy the two files from the release folder to this new folder and then delete the release folder. Again, double-click the SampleClientApp. exe file to verify that it’s working.

That’s all there is to it; xcopy deployment provides the ability to deploy a fully functional application simply by copying the assemblies to the target machine. Just because the example that is used here is simple does not mean that this process cannot work for more complex applications. There really is no limit to the size or number of assemblies that can be deployed using this method. The reason that you might not want to use xcopy deployment is the ability to place assemblies in the global assembly cache (GAC) or the ability to add icons to the Start Menu. Also, if your application still relies on a COM library of some type, you will not be able to register the COM components easily.

Xcopy and Web Applications

Xcopy deployment can also work with Web applications with the exception of the folder structure. You must establish the virtual directory of your Web application and configure the proper user rights. This process is generally accomplished with the lIS administration tool. After the virtual directory is set up, the Web application files can be copied to the virtual directory. Copying a Web application’s files can be a bit tricky. A couple of configuration files, as well as the images that the pages might be using, need to be accounted for.

Copy Web Tool

A better way would be to use the Copy Web tool. The Copy Web tool is accessed from the Website Q Copy Web Site menu choice in Visual Studio 2008. It is basically an FIP client for transferring files to and from a remote location. The remote location can be any FIP or Web site including local Web sites, lIS Web sites, and Remote (FrontPage) Web sites. Another feature of the Copy Web tool is that it will synchronize files on the remote server with the source site. The source site will always be the site currently open in Visual Studio 2008. U the current project has multiple developers this tool can be used to keep changes in sync with the local development site. Changes can be synced back with a common server for testing.

Publishing a Web Site

Another deployment option for Web projects is to publish the Web site. Publishing a Web site will precompile the entire site and place the compiled version into a specified location. The location can be a
file share, FTP location, or any other location that can be accessed via HTTP. The ,compilation process strips all source code from the assemblies and creates the DLL’s for deployment. This also includes the markup contained in the . ASPX source files. Instead of containing the normal markup, the . ASPX files contain a pointer to an assembly. Each .ASPX file relates to an assembly. This process works regardless of the model: code behind or single file .

.The advantages of publishing a Web site are speed and security. Speed is enhanced because all of the assemblies are already compiled. Otherwise, the first time a page is accessed there is a delay while the page and dependent code is compiled and cached. The security is enhanced because the source code is not deployed. Also, because everything is precompiled before deployment all compilation errors will be found.

You publish a Web site from the Website Q Publish Web Site menu choice. You need to supply the location to publish to. Again, this can be a file share, FTP location, Web site, or local disk path. After the compilation is finished, the files are placed in the specified location. From there, they can be copied to a staging server, test server, or the production server.

Posted on October 31, 2015 in Deployment

Share the Story

Back to Top
Share This