Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Create Installer File for Windows Application using Visual Studio

Mar 22, 2017
Introduction

Here we will learn how to create installer file for windows application
 in c# using visual studio with examples or create setup file for windows form application in visual studio in c# with example. By using setup project in visual studio setup and deployment section templates we can easily create installer or setup file for windows application in c#.

Description:
  
In previous articles I explained set startup page in windows application, show the progressbar in windows application in c#, vb.net, bind data to datagridview with example in c#, vb.net, export datagridview data to excel with example in c#, vb.netconstructors in c# with examples, difference between virtual, override, new keywords in c#
 and many articles relating to asp.net, c#vb.net and JQuery. Now I will explain how to create installer or setup file for windows form application in visual studio using c# with example.

Before we create installer or setup file for windows form application first we will create one sample windows forms application

Go to File à project à select Windows Forms Application à Give name to your application à click OK like as shown below


Now in your page add Textbox and button controls and double click on your button and write the code like as shown below


private void button1_Click(object sender, EventArgs e)
{
string str = textBox1.Text.Trim();
if(str!="")
{
MessageBox.Show("Thank You For Interest", "Success");
}
else
{
MessageBox.Show("Please Enter Name", "error");
}
}
Once you write the code run your application that will return the output like as shown below

Output

Now we have sample windows form application for this we will create setup file.

First close your application and again open visual studio and create new setup project by following below steps

Go to File à Project à Other Project Types à Select Setup and Deployment à Select Setup project like as shown in below image


It will open window like as shown below in which contains three folders those are Application Folder, User’s Desktop and Users’ Program Menu. These folders are the places where we want to copy our setup files during installation process. Now right click on Application folder and select Add à File like as shown below

Once we click on File it will open new window in that navigate to bin folder of your sample windows form application and select your application .exe file and click OK like as shown below

Once we add exe file now right click on your setup file and click on create shortcut to add that shortcut to User’s Desktop folder or User’s Program menu when you install the application

Now right click on your setup project like as shown below to change properties

In properties window click on Prerequisites button to add required changes like .NET framework, SQL Server Compact to setup file like as shown below

Once you done all the changes now right click on your setup project and click Build it will create setup file in your setup application folder like as shown below


Now open your setup files application folder and check it in debug folder it will contains setup files like as shown below 

Create Installer File for Windows Application using Visual Studio
Now click on your setup file to install it. If you click on setup file it will open window like as shown below

Now click Next Next in windows it will install your application like as shown below


Once installation completed it will create shortcut on desktop because we added a properties to create shortcut on desktop if you open it will be like this

I hope it helps you to create setup file for your windows form application.....

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

3 comments :

jobs said...

good explanation..

Anonymous said...

Could you please let me know how to add prerequisites for application like .net framework and sql server.

Jitendra Kumar Karna said...

Hello,
good article, but i need my custom installation have textbox and other controls. can you please tell me how to do that.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.