Setup Project Deployment of Windows Form Application
Create ASP.NET Windows Forms Application in Visual Studio 2010 and gives the functionality enable user to automatically install and deploy it on servers via an easy setup program.
Create Windows Form Application Project
Create a new Windows Forms Application project:
select File->New Project-> Windows Forms Application
Add Setup Project to the Solution
Choose the File->Add->New Project menu item to add one into your solution:
Note that the “Setup Project” type shows up under the “Other Project Types->Setup and Deployment->Visual Studio Installer” node in the New Project dialog above. Name it whatever you want and hit ok. It will then show up in your solution explorer as a separate project.
Add Project Output in Setup
Our next step will be to configure the setup project to take the compiled assemblies project and use them as inputs within our setup project. To-do this, right-click on the web setup project node in the solution explorer and choose the “Add->Project Output” context menu item:
A dialog will then appear allowing us to select which project in the solution, and which of its project contents, we want to add to the setup package:
For ASP.NET Projects it is really important that we select both the “Primary Output” (which are the compiled assemblies for the \bin directory) as well as the “Content Files” within this dialog.
Add File System in Setup
By default, the setup project will copy both of these items into the root of the target Application Folder that the setup project will create. You can see that it is configured this way by opening up the “File System” view within the setup project (right click on the setup project root and choose View->File System):
File System will show you 3 folders:
Application Folder: Contained the files installed in application folder in selected location.
User’s Desktop: Contained the files/shortcuts placed on desktop.
User’s Programs Menu: Contained the shortcuts in program menu.
Create Shortcut of your exe file:
Select Application Folder->Right Click on Primary output from [APPLICATION NAME] (Active), Select Create Shortcut to Primary output from [APPLICATION NAME] (Active)
Create Shortcut and set icon to exe file on desktop:
Right click on “Create Shortcut to Primary output from [APPLICATION NAME] (Active)” select properties windows, select Folder to User Desktop.
You can set icon to shortcut from icon property
Add GAC enabled File to GAC Assemble on Machine:
Right Click on File System on Target Machine, Add Global Assembly Cache Folder in it.
When Global Assembly Cache Folder is added under File System on Target Machine then select Application Folder, it will show you all the dll files, now drag the dll files on Global Assembly cache Folder which you want to move to GAC of machine, when setup is installing it will automatically installed on GAC of machine.
Make GAC file to permanent reside on machine or remove at the time of un-installation of setup
Select dll file and open properties window of that dll, Set Permanent property of dll file to True which make sure that after un-installation of setup dll will not remove from the machine, by default it is False and when user un-install the setup it will automatically uninstall the dll from machine without check its dependencies which will cause other applications who already using that dll.
Set Properties Settings for Setup project:
Now there are some other settings that are up to you to change.
Make sure you clicked on the “SetupProject” in the solution explorer.
In the properties toolbox, you can edit the “AddRemoveProgramsIcon”, the “Author”, “Descriptions”, “Manufacture”, “Target Platrorm”, “InstallAllUser” etc.
Change Remove Previous Version to True which ensure that while installing the setup again it will remove the previous version automatically form the machine and install new setup.
Set Prerequisties of the setup:
Right click on setup project, select properties from dialog box:
Configure the “SetupProject” to include the Prerequisites
Now we will configure our Setup Project to include the prerequisites
1. In the solution Explorer search for “SetupProject” and right click on it.
2. Select Properties
3. Click on “Prerequisites”.
4. The first check box, “Create setup program to install prerequisites components” on top should be ticked, if not, tick it.
5. Now make sure that you tick “Windows Installer 3.1” and “.Net Framework 3.5” in the “Choose which Prerequisites to install” list.
6. Further down in the window there are 3 options. Make sure the “Download prerequisites form the same location as my application” is selected.
7. Close the window.
8. Close the Properties window.
NOTE: Setup will check the prerequisites already installed on machine or not while installing, it is not installed then setup will install the prerequisites on machine from the location set under “Specify the install location for prerequisites”, because of we have selected “Download prerequisites form the same location as my application”, setup will install the prerequisites from the setup folder.
Build and Run Setup Project to the Solution
To build the web-setup project we can right-click on the web setup project node within the solution explorer and choose the “Build” option:
Now that we have all the basic required settings, we can test the application.
1. Build your solution
2. Select Setup Project in the solution explorer and right click it.
3. Select Build
4. Browse to your project debug folder and double click on setup file.
Our “MyApplicationSetup” project created a new MyApplicationSetup.msi Windows installer file and compressed and packaged the contents of our ASP.NET Web Application (note: in the web setup project properties dialog you can choose whether the compression algorithm used is optimized for size or speed).
Very Important: Because setup projects take awhile to build, they are by default marked not to build as part of the solution. What this means is that you need to right-click on them and explicitly do a build in order for them to be recompiled. Be careful to-do this when you make and test changes – otherwise you’ll be running the previously compiled version and not the one with your latest code!
To test it, we can right-click on the web setup project within the solution explorer and choose the “Install” option to install it (or alternatively launch it outside of VS by running it):
This will launch a standard Windows installer and walk the user through installing the application on IIS:
Select Folder location where to install the application:
Once installed the application will also show up in the standard “Add or Remove Programs” utility within the Windows Control Panel:
You can remove the application either by running uninstall from the control panel utility, or (at development time) by right-clicking on the web setup project node within the VS Solution Explorer and selecting the “Uninstall” menu item. This will cause all installed files to be removed from disk.
Update the Wizard UI of the Setup Project
By default the Windows installer created by a web setup project has some default instruction strings and banner images for the setup:
You can change this and customize the screens by right-clicking on the web setup project node in the VS solution explorer and selecting the “View->User Interface” context menu item):
This will then bring up a screen that shows the list of screens to be displayed during setup:
Unfortunately there isn’t a forms-designer that you can use to override the screens above. However, you can select a screen, and then go to the property grid to customize its CopyrightWarning and WelcomeText:
Add Dialog during Start of application
Add Dialog Box
You can select any welcome image at the time of begin of installation of setup in splash dialog box:
For custom Actions Please refer:
It’s often necessary to add your own code to a Visual Studio setup project, which is accomplished using custom actions. Custom actions are in contrast to the standard actions that Windows Installer performs during an installation. Please refer the link to use custom actions in yout project.
http://msdn.microsoft.com/en-us/library/d9k65z2d(v=vs.100).aspx