C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,288 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,062 people online right now. Registration is fast and FREE... Join Now!




Deploying a C# application (Visual Studio Setup Project)

 
Reply to this topicStart new topic

> Deploying a C# application (Visual Studio Setup Project), How to deploy a C# application using Visual Studio Setup Project.

PixelCard
Group Icon



post 19 Jul, 2008 - 07:40 AM
Post #1


In this tutorial I will show how to deploy a C# application using a standard Visual Studio Setup Project.

Any application must be somehow provided to the end-user. If the application is very small and is composed of a single executable, it can be deployed by just providing the executable to the end user. In our situation, the application has many dependencies, that can or cannot be present on the client machine, so we need to create a setup project, that will install the needed dependencies and the application itself.

Special Tutorial Requirements:
  • Microsoft Visual Studio 2008 ('Setup and Deployment' projects are not available in Express editions)

Let's start.

1. First of all we need to open a C# project/solution (or any other project/solution you have made using one of the programming languages included in Visual Studio). Use 'File -> Open -> Project/Solution' (or Ctrl+Shift+O):

IPB Image

IPB Image

2. After opening a C# project/solution you will get something like this:

IPB Image

3. Now you have to add a setup project to the current solution. Use 'File -> Add -> New Project...':

IPB Image

4. In the 'Project types' list, go to 'Other Projects -> Setup and Deployment' and select the 'Setup Wizard' template:

IPB Image

As you see there are many 'Setup and Deployment' project types and you can create just a blank setup project and customize it by yourself, but in this tutorial I will show how to use the wizard, which is a little bit easier for beginners.

5. Now let's take a deeper look at the wizard.

The wizard is composed of 5 general steps:

Step #1: Initialization

IPB Image

This step is a 'welcome message'.

Step #2: Project Type

IPB Image

In this window you have to select the setup project type. You have four options:

To create a setup program to install an application:
  1. Create a setup for a Windows application
  2. Create a setup for a web application


To create a redistributable package:
  1. Create a merge module for Windows Installer
  2. Create a downloadable CAB file

I will use the 'Create a setup for a Windows application', as my C# project is a Windows application.

Step #3: Project Outputs

IPB Image

Here you must select the project outputs you wish to include in your installation package. For my project I select only 'Primary output', which includes the application DLL or EXE.

IPB Image

Step #4: Files to include

IPB Image

Here you have the opportunity to add additional files, like guides, HTML pages or just a ReadMe file. I will add just a ReadMe file:

IPB Image

Step #5: Confirmation

IPB Image

Here you can see the settings for the project that will be created. If you find a mistake or something, you can easily go back and change a specific setting.

6. If the project was successfully created, you will see this:

IPB Image

7. Now you can customize the setup project properties. To access the project properties grid, click on Setup1 project in the 'Solution Explorer' window:

Here are the properties and a short explanation of what they do:

AddRemoveProgramsIcon - Specifies an icon to be diplayed in the Add/Remove Programs dialog.
Author - Specifies the name of the author of an application or component.
Description - Specifies a free-form description for an installer.
DetectNewerInstalledVersion - Specifies whether to check for newer versions of an application on the user's computer.
InstallAllUsers - Specifies whether the package is installed for all users or only the current user.
Keywords - Specifies keywords used to search for an installer.
Localization - Specifies the locale for string resources and the run-time user interface.
Manufacturer - Specifies the name of the manufacturer of an application or component.
ManufacturerUrl - Specifies a URL for a Web site containing information about the manufacturer of an application or component.
PostBuildEvent - Specifies any commands to execute after the build ends.
PreBuildEvent - Specifies any commands to execute before the build starts.
ProductCode - Specifies a unique identifier for an application.
ProductName - Specifies a public name that describes an application or component.
RemovePreviousVersions - Specifies whether an installer will remove previous versions of an application or component.
RunPostBuildEvent - Specifies the condition under which the post-build event runs.
SearchPath - Specifies the path that is used to search for assemblies, files or merge modules on the development computer.
Subject - Specifies additional information describing an application or component.
SupportPhone - Specifies a phone number for support information for an application or component.
SupportUrl - Specifies a URL for a Web site containing support information for an application or component.
TargetPlatform - Specifies the target platform of the installer.
Title - Specifies the title of an installer.
UpgradeCode - Specifies a shared identifier that represents multiple versions of an application or component.
Version - Specifies the version number of an installer, merge module, or .cab file.

8. You can also specify what folders to create on the desktop and in the Start menu:

IPB Image

9. You can also customize the entries that will be added to the registry:

IPB Image

IPB Image

10. You can also customize the file types on the target machine:

IPB Image

IPB Image

11. You can also customize the user interface of the installer:

IPB Image

IPB Image

You can add additional dialogs:

IPB Image

12. You can also customize the custom actions:

IPB Image

IPB Image

13. You can also customize the launch conditions:

IPB Image

IPB Image

14. When you're done with project customizations, build the project (right click on 'Setup1', then select the 'Build' option):

IPB Image

Now you've got a new installation package for your application or component.

This tutorial showed the basics of creating a setup project, so now you can easily deploy your applications to the end-user.
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

avi123
*



post 17 Nov, 2008 - 01:12 AM
Post #2
Hi,
I want to add flash player setup along with .net application.
how to do ut.
Thank you,
avinash
Go to the top of the page
+Quote Post

laxman4dc
*



post 25 Feb, 2009 - 05:11 AM
Post #3
Hi,

We could add Flash files as we do other files, however my concern is I want to put restriction on direct running of programs from programfiles folder where deployed files have been copied after setup or installation. I.e. I dont want user to copy my files from program files and paste it on another machine and run my flash files which we can consider as piracy or multiplying users with the cost of only one! Could you please help me on this?

Thanks
Laxman.
Go to the top of the page
+Quote Post

Jamesearoney
*



post 10 Mar, 2009 - 11:43 AM
Post #4
Hi, nice tutorial, but have you got a download link for the application, or do you have to buy it?
Go to the top of the page
+Quote Post

versatile36
*



post 11 Mar, 2009 - 02:16 AM
Post #5
QUOTE(Jamesearoney @ 10 Mar, 2009 - 11:43 AM) *

Hi, nice tutorial, but have you got a download link for the application, or do you have to buy it?


this is not an APP, do it with Visual Studio ..
Go to the top of the page
+Quote Post

BigPhill
*



post 28 May, 2009 - 05:11 AM
Post #6
Good morning friend!
I follow the tutorial and works exactly how you said... but I have a question... how can I make the .NetFramework be installed direct from my application cd, instead download from microsoft?
Go to the top of the page
+Quote Post

papuccino1
Group Icon



post 12 Jun, 2009 - 05:34 PM
Post #7
Great tutorial. I'll be sure to follow this when making an installer for my future softwares.

Thanks!
Go to the top of the page
+Quote Post

netstruc65
*



post 9 Jul, 2009 - 02:08 PM
Post #8
Can you configure the project so that everytime the application starts it will check for a newer version, similar to a click once deployment?
Go to the top of the page
+Quote Post

kekranx
*



post 26 Aug, 2009 - 05:35 AM
Post #9
I'm trying to add a custom Form in my Setup Project. First, I referenced the Form project output in my setup project, then added this ouput to the customAction Install. But I never see the form when I execute my setup project. I tried to wrap the form in a custom class derived from Installer. then done with the wrapper class the same thing I did with the form. Same result. I must have missed something like setting a property in my setup project or maybe an attribute in my my class derived from Installer.
It seems to me like a very common requirement so if somebody could give me a hint.
I found the answer there : http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx
but it's rather odd (to say the less) that the project output must be in the Install and the Commit custom action to be activated
And you must add [RunInstaller(true)] attribute to your Installer derived class

This post has been edited by kekranx: 26 Aug, 2009 - 06:25 AM
Go to the top of the page
+Quote Post

Deadlocked
*



post 29 Sep, 2009 - 09:53 AM
Post #10
Any chance you would reupload the images.

I cant see them.

Cheerss
Go to the top of the page
+Quote Post

Martyr2
Group Icon



post 29 Oct, 2009 - 06:20 PM
Post #11
QUOTE(Deadlocked @ 29 Sep, 2009 - 09:53 AM) *

Any chance you would reupload the images.

I cant see them.

Cheerss


There must be something wrong with your browser then, these images appear just fine. They are standard .jpg files.
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
4 User(s) are reading this topic (3 Guests and 0 Anonymous Users)
1 Members: Fuingurth

 


Lo-Fi Version Time is now: 11/7/09 12:15PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month