Monday, March 1, 2010

Create Setup and Deployment Project Visual Studio 2008


Creating a Setup and Deployment Project
In this article I will cover the basics of creating a Windows Installer. This article will explain the step by step process of creating a Setup Project.


Step 1: Create a Sample .Net Project. I have named this project as "TestBlogProject".











Figure 1 Sample Project


Create a Setup Project
Open the TestBlogProject in the VS IDE.





Figure 2: Add New Project




Figure 3: Setup Project Dialog


There are five different templates that are available when you select the project type 'Setup and Deployment Projects'.
  1. Setup Project: Creates a Windows Installer project to which files can be added. This project type is the most generic of the five.
  2. Web Setup Project: Creates a Windows Installer web project to which files can be added.
  3. Merge Module Project: Creates a Windows Installer Merge Module project to which files can be added. This project type is most commonly used for using third party products.
  4. Setup Wizard: Creates a Windows Installer project with the aid of a wizard.
  5. Cab Project: Creates a Cab project to which files can be added.
For the purpose of this article, I will be using the template Setup Project. Provide a name for the project as well choose the location where this project will be established. (See Figure 3) Once you have done this click 'OK' and you should now see a screen like the following.

 




Figure 4: Default Setup Project File View


Now that we have an empty Setup Project established.
Let us discuss about the various editors that are available.



  1. Right Click on the Setup Project and Click View.

Figure 5: File System Editor


  1. Click on the File System

File System Editor
The File System (Figure 6) provides you the essential tools to work with the application folder, user's desktop, and the user's programs menu.




Figure 6: File System Editor

The first thing we want to do here is to include the relevant files and folders we wish to install on the user's machine. This is accomplished by right clicking the Application Folder and selecting 'Add'. The following screenshot is an example of something similar you may see.



Figure 7: Add Project Output

Now to add project output files to this folder, Click Project Output.



Click OK.

Merely add one or more of the files that is vital for your application by clicking on File…. Now that you have you files in place.


Figure 8: Project Output


We could take additional steps such as manipulating the user's desktop with items such as a shortcut, as well you can add a program group to the user's program group.

Create Shortcut





Name the shortcut as you want. I have given the name as TestBlog. Drag and drop to User's Desktop Folder

Figure 9: Desktop Shortcut to application


The next item you find of immense importance is the User Interface Editor. Inside of this editor you may eliminate or include dialogs that are needed for this install project. The following screenshot is the default User Interface that is created when I initially created this setup project (See Figure 10). The only variation is that I have added a Customer Information dialog.

Figure 10: User Interface Editor
To include the Customer Information dialog that I spoke of follow the following steps.
  1. Under Install right click on the 'Start' node
  2. Choose 'Add Dialog'



Figure 11: Customer Information


  1. Select the Customer Information Dialog and click 'OK'
As you can see there are is an ample variety of dialogs you can choose from.


Prerequisites Installation in Windows Installer
Most applications have prerequisites: Components such as the .NET Framework runtime must be available on a target computer in order for the application to run. The deployment tools in Visual Studio include the capability to automatically detect the existence of components during installation and install a predetermined set of prerequisites — a process known as bootstrapping.


This will be achieved as follows:


To choose which prerequisites to install
  1. In Solution Explorer, select the deployment project and Right Click
  2. Click Properties.
  3. In the Property Pages dialog box, expand the Configuration Properties node, and then select the Build property page.
  4. Click the Prerequisites button.
  5. In the Prerequisites dialog box, make sure that the Create setup program to install prerequisite components box is checked.
  6. In the Choose which prerequisites to install list, check the prerequisites that you wish to install, and then click OK.
To specify the download location for prerequisites
  • In Solution Explorer, select the deployment project, right click.
  • Click Properties.
  • In the Property Pages dialog box, expand the Configuration Properties node, and then select the Build property page.
  • Click the Prerequisites button.

  • In the Prerequisites dialog box, choose a location:
    • If you want to deploy the installers for the prerequisites to a vendor, click Download prerequisites from the component vendor's web site.
    • If you want to deploy the installers for the prerequisites to the same location as your application installer, click Download prerequisites from the same location as my application.
    • If you want to deploy the installers for the prerequisites to a different location, click Download prerequisites from the following location and enter a local path, URL, or file-share location.
  • Click OK to continue.











In this article, I have covered adding a new setup project, about File System Editor, adding installer prerequisites to Windows Installer.

108 comments:

  1. Great stuff - really helped me out.

    ReplyDelete
  2. I am glad my article helped you.

    ReplyDelete
  3. tintin:
    fantastic,this is good stuff!

    ReplyDelete
  4. How do you integrate a dialog with textboxes, adding this dialog is a simple as what you do, but at some point you need to acces the properties (e.g. EDITA1, EDITA2,...) how do you do this? In my case I want to enter a "default" value in the texfield that depends on the windows version on the PC. The user can if needed change this value but ofcourse I need to be able to read it afterwards (e.g. when the program is booted).

    ReplyDelete
  5. Great !!!!!!!.
    How can we create a setup that can only be installed on one and only one computer.
    THank a lot for ur appreaciation.
    Manoj

    ReplyDelete
  6. great..Thanks a lot..=D

    ReplyDelete
  7. Nice post can u please explain how to customize the Prerequisites.

    ReplyDelete
  8. I am glad my article helped you

    ReplyDelete
  9. Please help me. i have set the prequisites install location --- i have selected *download prequisites from the same location of my application. Please help me.

    ReplyDelete
  10. how i can add some third party installer in prerequisites such as xampp, joytick drivers...... its must automatically install while instaling the software.
    thank you

    ReplyDelete
  11. Hi there,

    I am wondering, If I need to amend again my project(change some codes) do I need to run the setup again? Kindly advise .

    ReplyDelete
  12. I did everything but i can't publish the Project setup1. how can i do it?

    ReplyDelete
  13. Hi,
    I did used, but no solution

    ReplyDelete
  14. Thanks But please tell tthat should i add my MS Access Database in Project output.Bcause if i dont add my database in project output then i receives eroor that database not found

    ReplyDelete
  15. Thank you so much. You are a life saver. I was about to commit suicide you know. Just exaggerating.

    ReplyDelete
  16. How to add ms access database and microsoft viewer report in setup?
    Please help

    ReplyDelete
  17. how to add a sqlserver database into my setup please help

    ReplyDelete
  18. where is the set up file created

    ReplyDelete
  19. how to add a sqlserver database into my setup please help

    ReplyDelete
  20. HOW TO ADD SQL SERVER INTO MY PROJECT(WINDOWS APPLICATION BY C#) AND AFTER INSTALLATION IT INTO DIFFERENT COMPUTER, HOW TO SOLVE REMOTE CONNECTION ERROR. PLEASE HELP ME.

    ReplyDelete
  21. Thanks for your article

    ReplyDelete
  22. Hi there,
    I have developed an Excel add-in using MATLB, after I am done with deployment I am left with a dll and the addin. Now, I want to distribute the dll, excel add-in and a Compiler called the Matlab Compiler runlime (MCR), so that the user can install the compiler and run the add-in that was developed. Can I make a set up project that will install the MCR (160 Mb) in a pirticular location of the users machine and copy the dll and the add-in file aswell in that location?

    Regards,

    Karthik

    ReplyDelete
  23. Hi.
    Can Anyone tell me how to I create My won Instaling Interface????not using Visual Studio Defalt Instaling Interface...

    ReplyDelete
  24. Is there any way to create multilingual setup project in VS ??? (i mean using VS default Setup Project) Without Using Wix or any other tool.

    ReplyDelete
  25. Hello Dear..
    i have created on project with sql database.
    and when i create setup as above than after an installation i faced an error in connection of database...
    i have already use |DataDirectory| for dynamic conection of file.

    then plz tell me how create an setup of project with sql databsefile.

    send me email on
    divyesh07163@gmail.com
    dvsbharadva@gmail.com

    hopping to be favoured me and thanking to you.,..

    ReplyDelete
  26. how to add a sqlserver database into the setup
    please help me...

    send me on
    libra.diya@gmail.com

    ReplyDelete
  27. how to get desktop shortcut after installation & it has a icon too ?

    ReplyDelete
  28. how to add a sqlserver into setup and also how to add Serial Number while setup wizard going on..i mean how add serial number to application in VB.net

    plz help me
    send me answer at atulparmar19@yahoo.co.in

    ReplyDelete
  29. according to my knowledge you have to put the sql server in installing machine first and then should mannually put the database.i use a sql scripts and run it to put my db on that machine..any comments on this??

    ReplyDelete
  30. thx but i want to include my DB with that EXE??????? Can u help me

    ReplyDelete
  31. How to deploy a vb.net 2008 project with the SQL server-2005 database... I am able to deploy using above procedure but my database is not getting connected.. Il b glad if u could help me...

    ReplyDelete
  32. how to deploy a software with sql database??

    ReplyDelete
  33. Good Article thankyou :-) helped me a lot.

    ReplyDelete
  34. Hi, Thanks its very help full to me.

    ReplyDelete
  35. i have problem with deployment before deployment everything run ok but when i deploy project & show the report this time its shows Load Report Failed can u help i think in my deployment there no show all the form

    ReplyDelete
  36. I want to add a confirmation dialog box for the application version.if previous version is available then ask to remove the previous version.

    ReplyDelete
  37. To attach your 'Access' database: In the figure 4 of this tutorial -> right click on 'Application Folder' -> select 'File...' and then search the *.mdb file on your hard disk. When you compile (Debug or Release) it will copy the database to the App Folder, voilá!. Do the same for the App Icon and configure the shortcuts by looking into this folder for the icon. For SQL databases I'm not sure this same process works, I'll try tomorrow to see if it works, what I'm sure is that you need to enable SQL Server Express on 'Prerequisites' on the last picture in this tutorial, because for SQL you need the server installed and the database attached to it!

    ReplyDelete
  38. hi ,everyone i m don't understand these concept please explain it............

    ReplyDelete
  39. Thanks a lot..U did a Nice job,It is really helped us..once again thanks

    ReplyDelete
  40. hola alguien sabe ya como incluir la base de datos SQL!!

    ReplyDelete
  41. hi .please help me
    how to add sql database with set up file

    ReplyDelete
  42. hi please help me
    I have 2 problems

    1) How can we create a setup that can only be installed on one and only one computer


    2) HOW TO ADD SQL SERVER INTO MY PROJECT(WINDOWS APPLICATION BY C#) AND AFTER INSTALLATION IT INTO DIFFERENT COMPUTER, HOW TO SOLVE REMOTE CONNECTION ERROR. PLEASE HELP ME.


    please send me the steps for these problems.

    My mail id : suresh_gotika@yahoo.co.in

    ReplyDelete
  43. HOW TO ADD SQL SERVER INTO MY PROJECT(WINDOWS APPLICATION BY C#) AND ,HOW TO CREATE A LICENCE KEY IN SETUP.. PLEASE HELP ME.
    TO SEND DETAIL-
    My mail id - shiva.chauhan@gmail.com , mydemo.niit@gmail.com

    ReplyDelete
  44. shivnandan singh chauhanJanuary 2, 2012 at 3:08 AM

    HOW TO ADD SQL SERVER INTO MY PROJECT(WINDOWS APPLICATION BY C#) AND ,HOW TO CREATE A LICENCE KEY IN SETUP.. PLEASE HELP ME.
    TO SEND DETAIL-
    My mail id - shiva.chauhan@gmail.com , mydemo.niit@gmail.com

    ReplyDelete
  45. thanks for being so much helpful.
    From: www.kaszona.com

    ReplyDelete
  46. We would be much obliged if you could include a step by step procedure on how to effectively include the need for a serial in the setup... Thank you

    ReplyDelete
  47. Can you give me a link for download? (Setup Project)

    ReplyDelete
  48. Best Guide Ever.. i have been looking around for days. Maybe the other explains it well too, BUT its impossible to understand for beginners. And this type of Manual/Guide are always for beginners. Thanks again for your time. AND AS I SAID, BEST GUIDE ever

    ReplyDelete
  49. How can we create a setup file which will work with both 32 and 64bit

    ReplyDelete
  50. any idea how to include the run as administrator option in the setup.exe file? iv tried looking everywhere and even tried searching for software which modifies the binary iv found software and modified the binary detalials of the setup.exe but still no luck adding run as administrator to the right click menu items of the setup.exe

    ReplyDelete
  51. Thanks... it helped me a lot :)

    ReplyDelete
  52. hi guys nice helping ..
    my problem is the client computer not having any configure of .net frame work and service pack 3 and no sql server..
    i made a simple program in my system of ado.net
    this program is running in my system but not running in another as client systme why?
    and how to attach a local db space for client

    plz help us ..??

    ReplyDelete
  53. i think u can attach file with the help of "download prequisites from local location" and then browse ur mdf file from the system then add....


    hope it works! tc.

    ReplyDelete
  54. Really good article

    ReplyDelete
  55. Great! Thank You :)

    ReplyDelete
  56. Thank you sir.....This article is really helpful.....You did an awesome job....:)avi

    ReplyDelete
  57. I have followed what have said how to do the setup.
    How do I publish it with my project? When I do the build publish, it is still the same. it doesn't do what I put in the setup.

    ReplyDelete
  58. Call us at We24Support E-mail support number at 1-866-978-0799 and Enhance your system functioning and keep it clean with We24Support services.
    E mail Setup and Support
    email support

    ReplyDelete
  59. HOW TO ADD SQL SERVER INTO MY PROJECT(WINDOWS APPLICATION BY C#) AND ,HOW TO CREATE A LICENCE KEY IN SETUP.. PLEASE HELP ME.
    TO SEND DETAIL-
    My mail id - rajeshk997@gmail.com

    ReplyDelete
  60. This is very nice but how to give the serial number validation in the customer information.

    ReplyDelete
  61. This is the very good steps to deployment vs project.
    thanx a lot sir...

    ReplyDelete
  62. hey check this new website www.countcode.com. It's a social network made for programmers, where you can download,share or upload source codes, where you can count your own code lines for free. You have access to the web forum and the web chatroom. we are happy to have you joined to our community!

    ReplyDelete
  63. Thanks a lot for this topic, but I have a question:
    How can we create a setup that can only be installed on one and only one computer?
    please If you can help me by send steps of this method, because I search via Google several times with no success.
    My e-mail : dd_hefzy@yahoo.com

    Thanks again

    ReplyDelete
  64. Great !
    How can I change the text in the installer page like welcome screen.
    e.g. In welcome screen I want 'Welcome to my project 1 Installation' and for other client I want 'Welcome to my project 2 Installation'.
    Is there a way to do it using single setup project???

    ReplyDelete
  65. i have a problem

    after i install it. some of the codes change, so the first deploy must be in update.. how to update your first deploy with the new one?

    pls.. email me..likasjemboy@yahoo.com.ph

    ReplyDelete
  66. How to add the all dll and how to set the registry value to regeditor atomatically

    ReplyDelete
  67. Hi
    How to set the Regedit value atomatically from installed path.Plz help me...

    ReplyDelete
  68. Hi sir

    How to add the dlls and main exe.And locate the database and ini file using setup and deployment.Please help me ..

    Solution to mail me
    sabaritky@gmail.com

    ReplyDelete
  69. Thanks...Its helped me a lot...!!!!

    ReplyDelete
  70. thanks a lot... it helped me...

    ReplyDelete
  71. This walk through was very helpful!!!! Thank you so much for posting!!!

    ReplyDelete
  72. I written windows service in c# which reads some data from registry.Then I created windows installer using visual Studio 2010 for that service and also adding data to registry required for service. My problem is installer starts installing service before adding data to installer which causes failure in installing the service.I wanted to add data to registry before installing service so that it can use that data.

    ReplyDelete
  73. Can anyone tell me how to import the SqlServer database tables into the setup wizard in visual studio 2010 for windows application?
    cause when i create the setup(installation file) ,after installing, my installed application crashes as database is not include during setup creation.

    my mailid is samuraisau@yahoo.co.in

    ReplyDelete
  74. Hi,
    Dear Friends i have complete my C# project and its working great,
    I have three project such as BLL Project,Interface Project and Win form project.
    Now i want to make a Setup / Installation file of my Completed C# project.how can solve the problem. Please help me. please sent the solution in my Email. shakibmist@gmail.com

    ReplyDelete
  75. Greetings,

    Thank you so much for this tutorial. Very straight forward. :D

    ReplyDelete
  76. Good article.. but how do we add the log information for the installer. This would be required when i am packaging the installer / vsix for some project.

    reply is highly appreciated.

    ReplyDelete
  77. i wanna create a setup file with key in visual studio....can anyone send me steps to achieve my requirement through email.
    my mail id is: sureshgoud14@gmail.com

    ReplyDelete
  78. How can we create a setup that can only be installed on one and only one computer...?

    ReplyDelete
  79. Code to create free and Trial version

    ReplyDelete
  80. Awesome Article, thankyou for sharing

    ReplyDelete
  81. thanks .. this was a good article
    I have a query
    In my project I have created my database in MYSQL (freeware) and connected it through mysql connector now I want to create a setup of my project, is there any way to embed mysql server application to my current project so in one setup file my current project and the server both should be installed in clients computer.

    ReplyDelete
  82. In my project i have created my database in sql express 2005 for windows application bulid in visual studio 2008.now i want to create a setup of my project to embed sqlexpress in my project.so that there will be no need to install sql server .

    ReplyDelete
  83. Hi All
    In my project i need to create a user inteface and validate textbox filds (username , email , passwprd , conform password)during setup and deployment.

    I am able to create a user interface dialog (using orca) , In installer class i written the logic for validating user input after click on next button
    if user given wrong input able to display the error message box
    information.
    but problrm is after displying error msg installation was not stopped. I want to stay back at same dialog if user enters wrong input.
    Thanks in Advance

    ReplyDelete
  84. hi,
    I have developed an application using vs 2012 and access database.I am not good in exe file creation..Kindly help me to create the exe file and runing steps..

    Jeeshma

    ReplyDelete
  85. hi,
    how to create setup if crystal reports is used in project.

    ReplyDelete
  86. hi, i just want to use sql server 2012 express in our prequesties list to select in setup. is that possible in vs 2008 setup and deployment

    ReplyDelete
  87. Hi, nice method for Creating Setup and Deployment Project Visual Studio 2008.This method also helps in Visual studio 2010.Thanks....

    -Aparna
    Theosoft

    ReplyDelete
  88. my data base connection is SqlConnection sc = new SqlConnection("Data Source=MAHESH-pc;Initial Catalog=mahesh10am;Integrated Security=True");.........
    how to create setup file with database also , and i want to install client system...please help me ,


    thi is my mail id::- mbollapu@gmail.c0m

    ReplyDelete
  89. very nice..........

    ReplyDelete
  90. how to give own product key in customer information dialog box ...................when we making the setup ......product key is security of the software

    ReplyDelete
  91. hi can any one send me how to create info file that means when i create setup and install it into machine then some info file will also create at that machine.?????

    Guys i need help please have a look

    ReplyDelete
  92. thanx a lot............. for ur free stuff ............

    ReplyDelete

  93. hi this is a tejas
    i m last year bscit students
    i m developing two stand alone system(Windows application) one is housing management system and second gym management system using c# for front end & sql server 2008 management studio for back end….
    both project are completely done without any error and bugs..

    but i have face problem for setup(.exe file) to both projects…

    my problem is my poroject has install & working properly on my pc

    In another pc install successfully but not working properly..

    error is database can not found..

    anyone can help me to how to create proper setup of c#…..

    ReplyDelete
  94. Hi Sir,
    I m Nadeem Ansari,
    How to set Key when we should create setup in visual studio.
    Please help...

    nadeemansarikjn@gmail.com

    ReplyDelete
  95. Hello Sir,

    I am maij shaikh

    I want to create a setup file including prerequisites in a way that is compatible for both 32 bit and 64 bit machine. And one exe can be used for both machines

    Please reply on
    maij_shaikh@rediffmail.com

    Thanks in advance..

    ReplyDelete
  96. hi i have an issue
    Could not load file or assembly EPPlus , version=4.0.4.0 , culture=neutral ,public key token=ea159fdaa78159a1 or one of its dependencies. the system cannot find the specified file .
    help me with this issue
    thanks in advance

    ReplyDelete
  97. Hello Sir
    I am Akshay
    I want to create setup with Product Key and won Image and add other Fils
    justlike Database.

    ReplyDelete