In this example I will explain how to create a Setup and Deployment project using ClickOnce.for Windows Forms applications using Visual Studio 2005/2008/2010.
A similar approach can be applied for creating a setup project for web applications as well.
First of all create a sample Windows/web application.
Create setup project
Right-click on Solution Explorer root and select "Add" > "New project".
In the add new project dialog box select "Setup and Deployment" from other project types and then select Setup Project.
In the setup project file system editor window, right-click on the Application folder then select "Add" > "Project Output".
Now select primary output from the next dialog box and click on OK.
Right-click on the user's Desktop and create a shortcut to primary output in the application folder.
Similarly add a shortcut in the user's Program Menu.
Build the project by right-clicking on the setup project name and run the setup.
Deploying Windows applications using ClickOnce (Visual Studio 2008)
ClickOnce deployment allows you to publish Windows-based applications to a Web server or network file share for simplified installation. Visual Studio provides full support for publishing and updating applications deployed with ClickOnce. ClickOnce deployment is available for projects created with Visual Basic, Visual C#, and Visual J#, but not for Visual C++.
You can publish a ClickOnce application in three various ways: from a Web page, from a network file share, or from media such as a CD-ROM. A ClickOnce application can be installed on an end user's computer and run locally even when the computer is offline, or it can be run in an online-only mode without permanently installing anything on the end user's computer.
Open the Visual Studio 2008 IDE and create a new Windows application.
Go to "Project" –> "<Application Name> Properties" –> "Publish".
The Publishing folder location can be either a web site ("http://www.mydomain.com/installation/"), FTP site ("ftp://mydomain/installation") or file share. If you are using other than a file share for the deployment then you can provide an Installation Folder URL, since the end users may not have the permission to access the publishing folder directly. (Since I am using a shared path, an installation folder URL will not be required.)
Install Mode and Settings
If you select 'The application is available online only', each time it is run then it will be run from the published location and no start menu icon will be created.
But by selecting 'The application is available offline as well', A shortcut on the Start menu will be created for the application and it will enable the application to be run when the user is disconnected from the network.
Here you should state the publish version (not the application version). And if you check 'automatically increment revision with each publish' then that will ensure that the revision number will be incremented automatically ech time you publish your application.
Sometimes it is necessary to publish other files than the application. So this is where you state which ones to include or exclude from the deployment.
You can create a setup file to install the prerequisites, that are required by your application to function correctly. And all required prerequisites are selected automatically. But if you want, you can either add or remove them from your prerequisites setup.
In this window, you should define how your application should be updated. Check 'The application should check for updates' and choose whether it should be updated before or after the application starts. If you choose to update it after running the application then you can mention whether you want to check each time it runs or can mention a time period, that it should check. But it is always advisable to check before application starts, so users will get the latest updates each time they run the application.
And specify a minimum required version, so that the end user will get the specified version of the application, if they have an older version installed on their PC.
If the updating location is other than the publish location then please provide the path.
Save the settings and go to the form designer and add a label to the form.
Save and go to "Build" –> "Publish <Application Name>".
If you wish make any changes to the publish settings that you completed earlier then click "Next" or click on the "Finish" button.
And the deployment setup will be created in the published path.
Run the setup.exe to install the application. And click on the "Install" button.
Now close the application and change the label to 'Version 22.214.171.124'. And go to publish settings and on the update window, change the minimum required version to 126.96.36.199.
Click "Ok" and save the settings and publish the application.
There will be a start menu shortcut from the first installation.
Click on that to run the application. You will see an update screen and the updated application will be downloaded, installed and executed.
The previously described basic steps are required to deploy a .NET Windows application using ClickOnce.