How the C # WinForm program is packaged into an installation project (illustrated)

Source: Internet
Author: User
Tags visual studio installer

http://blog.csdn.net/qingdujun/article/details/37563661

Original address: http://blog.csdn.net/qingdujun/article/details/37563661


Development environment: Vs2010+sql Server 2008

Operating system: Win7_32bit flagship edition

Development language: C #

Project name: Student Boarding Management system


Here's how to package Windows applications?

First step:

Open VS2010, open the item you want to package, and then right-click "Solution", "Add", "New Project", and pop up the interface as shown in the following image:

Click the triangle to the left of "install and deploy", select "Visual Studio Installer" below, select "Install Project", and change the following name to "Setup" click OK.



Step Two:

Click the "Setup" generated in the solution to change the protectname in the attribute to "student boarding system V1.0" (Your project name)



Step Three:

Right-click Setup in the solution, and then select Properties. The Popup property page interface is shown in the second picture:

Then click on the system prerequisites inside.

Important: Check "Download Prerequisites (D) from the same location as my application", which means that after you have checked, when you build the Setup project, you will have the component you checked in the prerequisites list when you install the project. (The system completes automatically, this is also good, does not need you to download the component)

1), Windows Installer 3.1 (required)

2),. NET Framework 3.5 (optional) Reference final description

3), Crystal reports Basic for Visual Studio2008 (x86,x64) (optional) project to use the Crystal Report you need to check this



Fourth Step:

Right-click the application folder, click "Add", and then click on the folder, named "DB" (optional) for storing your database files.

Then right click on the "DB" folder you just added, add, file, and add your database in.




Fifth Step:

Right-click Application Folder, click "Add" and click "File". Add all the files below your release directory.



Sixth step:

Right-click Application Folder, click Add, select Project Output ..., note: In the project bar, select your own project (my Project name: Studentjisu), and then select "Main Output", click OK.




Seventh Step:

Create a desktop shortcut, right-click the primary output that you just added, and then select the first create shortcut, and then you can rename the shortcut (I renamed it: Student Boarding management system)

Finally, click the left mouse button to live the shortcut, and then drag and drop it under the User Desktop folder.




Eighth Step:

Create an uninstall program. Right-click the application folder, click "Add", select "File", and then add the "Msiexec.exe" file under "C:\Windows\System32", if you can't find it, you can search it directly. Of course, you can also create a shortcut to Msiexec.exe named "UnInstall".



After naming the shortcut, copy the Setup property (click the setup pop-up attribute in the solution) ProductCode to the arguments of the uninstall attribute:

At the same time, add "/x" to the front, note: There is a space behind the X.



Nineth Step:

Change the logo for desktop shortcuts. The logo is too lame, you can download a picture online, and then convert to the. ico format.

The following figure "Application Folder" refers to the location where the logo is stored, which is generally in place.



Tenth step:

Attach a database. We now add a class to write additional database code.

Right-click Solution, click Add, select New Project, and then create a new C # class library, named "Installdb."

Finally, the "Class1.cs" is deleted.




11th Step:

Creates a new class for writing the code that the database attaches to the database management system. Right-click the newly-created "Installdb" and click "Add" and select "New Item".

Then in the pop-up interface, select "Installer Class" and name "InstallDB.cs".




12th Step:

Because the additional database requires users to enter some information about the local database, such as: server name, database administrator name and password, and so on. At this point, we can pop up a box waiting for user input during the installation process:

Right-click "Setup" and click "View" to select "User Interface". Pop up the following second interface, right-click "Start", click "Add Dialog", select "text box (A)", and drag and drop it to "welcome" below, the third picture below.

Finally, according to their own needs to fill out the "text box (A)" Properties, you can refer to the third diagram.

Note: The variables defined inside are mainly defined for the following additional code.





13th Step:

Add the primary output of the attached database. Right-click Setup and select View, custom Actions.

Then, right click Install, select Application Folder, select Installer Class "Installdb", or select "Primary Output" to determine.

Next, copy and paste inside the Costomactiondata as follows:

[SQL] view plain copy

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.