Deploying Programs in C#


Deploying projects in Visual Studio.NET is fairly straightforward.  Most of the process is automated for you through some convenient wizards so it doesn't require much effort.  Keep in mind, though that you probably need the Windows Component Update Beta 1 on the machine you are deploying to. I suspect you also need the Microsoft .NET Framework, as well (for now). Also, note that Microsoft states that the current Deployment may not work in the future:
"Caution   Installers and merge modules created with the Beta release may not be 100 percent compatible with final Visual Studio.NET versions. While we want you to explore deployment and test the technology, we also want you to make sure that you don't distribute any installers or merge modules created with this release."-MSDN
Once your application is completed in Visual Studio, you can deploy it using the following steps:
First,  choose Add New Project from the File Menu:
Once you've done this, choose Setup and Deployment Projects.  Visual Studio then gives you a list of options for deploying your project, depending upon whether you are deploying to the web, in a compressed .cab file, or as a windows setup program. 
Below are the different types of project setups, their description, and their purpose:
Project Setup Description Purpose
CAB Project A Microsoft Compressed Cabinet file that can be opened using cabarc.exe Used for deploying applications for download from the web
Deploy Wizard Creates Deployment files for either the web or as a windows installation using a .msi setup file
and deploying them to a remote machine or your own machine
Used for creating setup files and deployment of the project all at once.
Merge Module Packages components that are shared by different applications Deploys a library of components
Web Setup Wizard Creates an installation for web-based applications.  The installation will install into the virtual root directory on a web server Used for creating an Installation for a web server
Setup Wizard Creates setup files for  a windows installation using a .msi setup file Used for creating setup files.  It seems to create only the .msi file with everything compressed into this file. Running places the program in the program files directory.
We will choose the setup wizard to deploy this particular application.  The setup wizard brings up a nice step by step dialog for creating our setup project:
As stated in the dialog,  the wizard creates an installer that you can use to install your project.  The next screen asks you what kind of installer you wish to create:
We want a plain old Windows setup, so we choose set up for a rich client application.  The next screen prompts us as to which files we would like installed:
If you just want to deploy the application with no source or documentation, then just choose Primary output. This will deploy the necessary exes and dlls for your application.  
The next screen prompts you for additional files such as readme.txt, web pages, or anything else you'd like to include in the install that Microsoft didn't think of. In the case of Hangman, we added the sound files:
The last screen is just a report informing you of what you've done and where the vdp (visual deployment project) is created:
When you click finish, a directory is created for deployment.  Now we need to build our project in order to deploy it, so simply choose build solution from the build menu.  This will create the MySetupProject.msi file needed to install the application.
If we double click on MySetupProject.msi after it is created, it will launch the installation.  For most installations, this just means xcopying all the necessary files into a directory under program files.  In the case of the hangman project, these would be all the's, the's (CLR Libraries), NLP files (common language resources), the runtime class library mscorlib.DLL, mngdist.dll(not sure what it does, but I guess it manages distribution), xxx.wav (sound files) and of course our own executable(In this case Hangman.exe.)

Similar Articles