You are on page 1of 17

Search:

Search

Advanced Forum Search

Forums
Programming
Web Development
Computers
Tutorials
Snippets
Dev Blogs
Jobs
Lounge

Login

Join!

Today's Topics

Dream.In.Code
> Programming Tutorials
> C# Tutorials

(4 Pages)

2
3

Last

Deploying A C# Application (Visual Studio Setup Project)


Deploy A C# Application Using Visual Studio Setup Project.
#1PixelCard

D.I.C Head

Reputation: 47

How To

Posts:139
Joined:20-June 08
Posted 19 July 2008 - 08:40 AM

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):

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

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

4. In the 'Project types' list, go to 'Other Projects -> Setup and


Deployment' and select the 'Setup Wizard' template:

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

This step is a 'welcome message'.


Step #2: Project Type

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

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.

Step #4: Files to include

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:

Step #5: Confirmation

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:

7. Now you can customize the setup project properties. To access the
project properties grid, click onSetup1 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:

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

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

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

You can add additional dialogs:

12. You can also customize the custom actions:

13. You can also customize the launch conditions:

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

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.
Is This A Good Question/Topic?20

Replies To: Deploying A C# Application (Visual Studio Setup Project)


#2avi123

New D.I.C Head


Reputation: -1

Posts:1
Joined:21-October 08
Posted 17 November 2008 - 02:12 AM

Hi,
I want to add flash player setup along with .net application.
how to do ut.
Thank you,
avinash
Was This Post Helpful?-1

#3laxman4dc

New D.I.C Head


Reputation: 0

Posts:1
Joined:25-February 09
Posted 25 February 2009 - 06:11 AM

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.
Was This Post Helpful?0

#4Jamesearoney

New D.I.C Head


Reputation: 0

Posts:13
Joined:08-March 09
Posted 10 March 2009 - 12:43 PM

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

#5versatile36

New D.I.C Head


Reputation: 0

Posts:32
Joined:02-October 08
Posted 11 March 2009 - 03:16 AM

Jamesearoney, on 10 Mar, 2009 - 11:43 AM, said:


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 ..


Was This Post Helpful?0

#6BigPhill

New D.I.C Head


Reputation: 2

Posts:1
Joined:28-May 09
Posted 28 May 2009 - 06:11 AM

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?
Was This Post Helpful?2

#7papuccino1

His name was Robert Paulson.

Reputation: 63

Posts:1,121
Joined:02-March 08
Posted 12 June 2009 - 06:34 PM

Great tutorial. I'll be sure to follow this when making an installer for my future
softwares.
Thanks!

Was This Post Helpful?0

#8netstruc65

New D.I.C Head


Reputation: 0

Posts:1
Joined:09-July 09
Posted 09 July 2009 - 03:08 PM

Can you configure the project so that everytime the application starts it will check
for a newer version, similar to a click once deployment?
Was This Post Helpful?0

#9kekranx

New D.I.C Head


Reputation: 0

Posts:1
Joined:26-August 09
Posted 26 August 2009 - 06:35 AM

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.microsof...z2d(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 August 2009 - 07:25 AM
Was This Post Helpful?0

#10riscy00

New D.I.C Head


Reputation: 0

Posts:2
Joined:29-November 09
Posted 29 November 2009 - 01:27 PM

This is very good presentation, I would like to ask how to


(a) Install application icon to replace the generic icon (the one that goes to
explorer window and other that goes to window taskbar?
(
How to make it to create shortcuts?
How to make it list program with in the program list of the start button (bottom
LHS of the window explorer)
Much appericated.
Was This Post Helpful?0

#11Daniel Joseph

New D.I.C Head


Reputation: 0

Posts:3
Joined:05-January 09
Posted 04 December 2009 - 11:26 PM

the explanation was useful...in case if i want another setup to be installed for
example if i want mysql to be installed while installing my appliction what should i
have to do..thank you
Was This Post Helpful?0

#12riscy00

New D.I.C Head


Reputation: 0

Posts:2
Joined:29-November 09
Posted 16 January 2010 - 02:02 AM

Hi this is very good tutorial


How to setup something that allow to create short cuts to window and start menu?
Can you make this practical (with picture, youtube whatever) so I can see how this
is done.
Thanks
Riscy00
Was This Post Helpful?0

#13Core

using System.Linq;

Reputation: 774

Posts:5,097
Joined:08-December 08
Posted 16 January 2010 - 05:18 AM

As you see, when you are creating the setup, there is the folder view, where you
can specify what is created where.

You need to add your files/shortcuts to the User's Desktop and User's
Programs Menu.
Was This Post Helpful?0

#14Dyslex

New D.I.C Head


Reputation: 0

Posts:1
Joined:26-January 10
Posted 26 January 2010 - 06:29 AM

I've got a big issue here, I need to install a video codec, the Directx SDK version
and the Speech SDK in order to my application to run.
Then I just made a Custom Action for each one of them (to run their respective
installers checking keys and all) at the Commit, but they all run at the same time,
and not in a sequence. Problem is that the Directx and Speech installers can't run
at the same time, so I need them to run in a sequence.
In an alternative way I created a batch file. Since batch files are sequential it
works as I expected, the batch checks the registry and then install the component
if needed, all in sequence. Then I created a exec file from the batch and a Commit
Custom Action for it but it just won't work. The batch file runs but it won't call the
others installers (due to permissions I guess).
So I'm lost... Any ideas on how to make sequencial Custom Actions?
This post has been edited by Dyslex: 26 January 2010 - 06:32 AM
Was This Post Helpful?0

#15Guest_BrianIreland*

Reputation:

Posted 25 February 2010 - 08:50 AM

Hi
When you open a solution, instead of clicking on File/New, should you not be
rightclicking on the solution and then choosing Add/Project/Setup Wizard?
Just a small point, class post btw.
Brian
Was This Post Helpful?0

Previous Topic
C# Tutorials
Next Topic

(4 Pages)

2
3

Last

Related C# Topicsbeta
Deploy C# Application With LinQ To SQL Connection Problem
How To Maintain Registries.........?
When I Run Code In Visual Studio I Get Error [identifier Expected\
Setup Project - Registry Keys, Install Paths, Sadness
Customize Setup Project
Basic Client/Server Chat Application In C#

Tutorial

Insert Update Delete Record In SQL With Windows Application Using C#


Visual Studio - Setup Project - Help!
Create A Setup In VS 2008 - I Want To Create A Setup Which Can Be Used For
A Single Pc
Converting A Set Of Images To Video Using C#

General Discussion
Caffeine Lounge
Corner Cubicle
Student Campus
Software Development
Industry News
Introduce Yourself
Nightmare.In.Code

Programming Help
C and C++
VB.NET
Java
C#
ASP.NET
.NET Framework
VB6
PHP
Ruby
Python
ColdFusion
Databases
Other Languages
Game Development
Mobile Development
52 Weeks Of Code

Web Development
Web Development
HTML & CSS
JavaScript
Graphic Design
Flash & ActionScript
Blogging
SEO & Advertising

Web Servers & Hosting


Site Check

Follow & Share

C# Tutorials
Database To Typed-DataSet, w/o BindingSource IV
Database To Typed-DataSet, With BindingSource III
Database To Typed-DataSet, With BindingSource II
Database to Typed-DataSet, with BindingSource
Introducing MVP (Model-View-Presenter) Pattern (WinForms)
Saving Settings using OR
From C# to F# and back again: lambdas and more.
Creating an Easy Data Access Layer using Entity Framework
String Manipulation
Collections - In Depth
237 More C# Tutorials...

Reference Sheets

Code Snippets
C Snippets
C++ Snippets
Java Snippets
Visual Basic Snippets
C# Snippets
VB.NET Snippets
PHP Snippets
Python Snippets
Ruby Snippets
ColdFusion Snippets
SQL Snippets

Assembly Snippets
Functional Programming Snippets
Perl Snippets
HTML/CSS Snippets
Javascript Snippets
Flash/ActionScript Snippets
Other Languages Snippets

DIC Chatroom
Join our IRC Chat

Bye Bye Ads

FAQ | Team Blog | Feedback/Support | Advertising


Us

| Terms of Use | Privacy Policy | About

Copyright 2001-2014 MediaGroup1 LLC, All Rights Reserved


A MediaGroup1 LLC Production - Version 6.0.2.1.36
Server: secure3

You might also like