Create Setup and Deployment Project in Visual Studio 2008/2010

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.

Deployment-Project in-Visual Studio-1.jpg

First of all create a sample Windows/web application.

Create setup project


Right-click on Solution Explorer root and select "Add" > "New project".

Deployment-Project in-Visual Studio-2.jpg

In the add new project dialog box select "Setup and Deployment" from other project types and then select Setup Project.

Deployment-Project in-Visual Studio-3.jpg

In the setup project file system editor window, right-click on the Application folder then select "Add" > "Project Output".

Deployment-Project in-Visual Studio-4.jpg

Now select primary output from the next dialog box and click on OK.

Deployment-Project in-Visual Studio-5.jpg

Deployment-Project in-Visual Studio-6.jpg

Right-click on the user's Desktop and create a shortcut to primary output in the application folder.

Deployment-Project in-Visual Studio-7.jpg

Similarly add a shortcut in the user's Program Menu.

Deployment-Project in-Visual Studio-8.jpg

Build the project by right-clicking on the setup project name and run the setup.

Deployment-Project in-Visual Studio-9.jpg

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.

Deployment-Project in-Visual Studio-10.jpg

Go to "Project" –> "<Application Name> Properties" –> "Publish".

Deployment-Project in-Visual Studio-11.jpg

Publish Location

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.

Publish Version

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.

Application Files

Deployment-Project in-Visual Studio-12.jpg

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.

Prerequisites

Deployment-Project in-Visual Studio-13.jpg

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.

Updates

Deployment-Project in-Visual Studio-14.jpg

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.

Deployment-Project in-Visual Studio-15.jpg

Save and go to "Build" –> "Publish <Application Name>".

Deployment-Project in-Visual Studio-16.jpg

If you wish make any changes to the publish settings that you completed earlier then click "Next" or click on the "Finish" button.

Deployment-Project in-Visual Studio-17.jpg

Click "Next".

Deployment-Project in-Visual Studio-18.jpg

Click "Next".

Deployment-Project in-Visual Studio-19.jpg

And the deployment setup will be created in the published path.

Deployment-Project in-Visual Studio-20.jpg

Run the setup.exe to install the application. And click on the "Install" button.

Deployment-Project in-Visual Studio-21.jpg

Deployment-Project in-Visual Studio-22.jpg

Now close the application and change the label to 'Version 1.0.0.1'. And go to publish settings and on the update window, change the minimum required version to 1.0.0.1.

Deployment-Project in-Visual Studio-23.jpg

Click "Ok" and save the settings and publish the application.

There will be a start menu shortcut from the first installation.

Deployment-Project in-Visual Studio-24.jpg

Click on that to run the application. You will see an update screen and the updated application will be downloaded, installed and executed.

Deployment-Project in-Visual Studio-25.jpg

The previously described basic steps are required to deploy a .NET Windows application using ClickOnce.

Up Next
    Ebook Download
    View all
    Learn
    View all