How do I change the source program of the encapsulated C # to an EXE or MSI installation package?

Source: Internet
Author: User

Deployment of C # applications
1: New Installation Deployment project
Open VS, click New Item, select: Other item type-> installation and Deployment-> Setup wizard (same as Setup project), then click OK. (See figure below)
The relevant pictures of this topic are as follows:

2: Setup Wizard
After closing, open the Setup Wizard, click Next, or click Finish directly.


3: Start making
After the Setup Wizard completes, you can enter the project folder:
Double-click Application Folder to right-click in the margin on the right, select Add-> file, add the executable file of your application and the corresponding class library and components.
Then right-click your executable file, create a shortcut, and then cut or copy the shortcuts to the user's Program menu and user desktop on the left.
This will create a shortcut to the program on the start-> All programs and desktop after Setup installation completes.
Then right click the Application folder on the left to open the Properties dialog box:

Remove "[Manufacturer]" from the path of "DefaultLocation" in the attribute,
Otherwise do the installer default installation directory will be "C:/programm file/your username/installation solution name";

Then open Solution Manager, right-click your solution name, and select Properties:


In the Open property page, select the Net.framework option in the prerequisites (usually by default).

OK then click Build on the solution
Gaga ~ Your first complete program is complete.
A second method



Deploy C # As a Windows application--


Deploying Windows Applications
This walkthrough shows the process of creating a setup program for a Windows application that starts Notepad. In this walkthrough, you will first create a Windows application and then create an installer to set up shortcuts and file associations during Setup, add registry keys, display custom dialog boxes, and check the version of Internet Explorer.

Note When you create your own installer, you do not necessarily need to perform all of the following steps. The purpose of this walkthrough is to describe some of the optional features that you might use in your deployment. To simply create a basic setup program, you only need to complete the first four parts of the process.
Creating a Windows Application

On the File menu, point to New, and then select Project.
In the New Project dialog box, select Visual Basic project in the Project Types pane, and then select Windows Application in the Templates pane. In the Name box, type My Notepad.
Click OK to close the dialog box.
The project is added to Solution Explorer and the Windows Forms Designer opens.

In the Toolbox, select the Windows Forms tab and drag the button control to the form.
Double-click a button control to add an event handler for the button. In the event handler, add the following code:
Shell ("Notepad.exe", Appwinstyle.normalfocus)
This starts the Notepad.exe and points the focus to it.

On the Build menu, select Build My Notepad for this application.
To create a deployment project

On the File menu, point to Add Item, and then select New Project.
In the Add New Project dialog box, select Install and deploy projects in the Project Types pane, and then select Setup Project in the Templates pane. In the Name box, type My Notepad installer.
Click OK to close the dialog box.
The project is added to Solution Explorer and the File System Editor opens.

In Solution Explorer, select the My Notepad installer project. In the Properties window, select the ProductName property and type My Notepad.
Note The ProductName property determines the folder name and the name that is displayed for the application in the Add/Remove Programs dialog box.
To add a Windows application to the Setup program

In Solution Explorer, select the My Notepad installer project. In the File System Editor, select the Application Folders node.
On the Action menu, select Add-> project output.
In the Add Project Output Group dialog box, select My Notepad from the project Drop-down list. Click OK to close the dialog box.
Select the primary output group from the list and click OK.
On the Build menu, choose Build My Notepad installer.
Deploying an application (Basic installer)

If you are performing a complete walkthrough process, you can skip this step.

In Solution Explorer, select the My Notepad installer project. On the Project menu, choose Install.
This will run the installer and install my Notepad on the development computer.

Note You must have installation permissions on your computer to run Setup.
Optional deployment Features
The remaining steps demonstrate an optional deployment capability.

Create shortcuts
This step will create a shortcut for your application that will be placed on the desktop of the target computer during the installation process.

Create a shortcut for a Windows application

In Solution Explorer, select the My Notepad installer project.
In the File System Editor, select the main output from my Notepad node.
On the Action menu, select the Create master output shortcut from my Notepad.
This adds a "Master output shortcut" node from ' My Notepad '.

Rename this shortcut to "shortcut to my Notepad."
Select the shortcuts for my notepad and drag them to the User desktop folder in the left pane.
Create a file association
This step adds a file association to my Notepad to start my Notepad application when you double-click the. vbn file.

To create a file association for a Windows application

In Solution Explorer, select the My Notepad installer project. On the View menu, point to Editor, and then select file type.
In the File Type editor, select the file types on target computer node. On the Action menu, select Add File type.
A new document type #1 node will be added, and the node will open so that you can rename it.

Rename the new document type #1 to Vbn.doc.
In the Properties window, set the Extension property of the file type to VBN.
Select the Command property and click the ellipsis () button. In the Select Items in Project dialog box, navigate to the Application folder and select Master output from my Notepad.
Click OK to close the dialog box.
Add a registry key
This step adds a registry key and corresponding values to the registry. At run time, you can reference this registry key from your application code to retrieve per-user information.

To add a registry key for a Windows application

In Solution Explorer, select the My Notepad installer project. On the View menu, point to Editor, and select Registry.
Select the HKEY_CURRENT_USER node and expand it, then expand the Software node and select the [Manufacturer] node.
Note that the "Manufacturer" node has parentheses on both sides, indicating that it is an attribute. It will be replaced with the manufacturer attribute value of the input deployment project.
On the Action menu, select New-> item.
Renames the Userchoice item.
Select the Userchoice item.
On the Action menu, point to New, and then click String Value.
Renames the TextColor value.
In the Properties window, select the Value property and enter black.
Add a Custom Installation dialog box
This step adds and configures a custom user interface dialog box that is displayed during installation.

Add a Custom Installation dialog box

In Solution Explorer, select the My Notepad installer project. On the View menu, point to Editor, and then select User interface.
In the User Interface Editor, select the Startup node under the installation node.
On the Action menu, select Add dialog box.
In the Add Dialog dialog box, select check box (A).
Click OK to close the dialog box.
On the Action menu, select Move up two times, and place the check box (A) dialog box on the Install Folder dialog box.
In the Properties window, set the BannerText property to sample.
Set the BodyText property to the ' Install Sample files ' check box to control whether the sample files are installed. If it is unchecked, the example is not installed.
Set the Checkbox1label property to "Do you want to install the sample?" ”。
Set the Checkbox2visible, Checkbox3Visible, and Checkbox4Visible properties to false. This hides the other check boxes.
Using the sample
This step creates an Samples subfolder that will be installed under the application folder.

Add the Samples folder

In Solution Explorer, select the My Notepad installer project. On the View menu, point to Editor, and then select File System. The application folder should still be selected.
From the Action menu, point to Add, and then select folder.
Rename the new folder #1 to sample.
This step creates two simple text files that will be installed if the user chooses the Install Samples option in the custom dialog box.

To create a sample file for your application

Use Notepad or another text editor to create a text file that contains the text "This is Rules.vbn," and then save it as a rules.vbn.
Note To prevent Notepad from automatically adding a. txt extension, select all files from the file type Drop-down list.
Create another text file that contains the text "This is Memo.vbn" and save it as memo.vbn.
This step adds the sample file to the Samples folder and sets the criteria for deciding whether to install the file.

To add an example to the installer

In Solution Explorer, select the My Notepad installer project. From the View menu, point to Editor, select File System, and then select the Samples folder.
From the Action menu, point to Add, and then select File. Add the Rules.vbn and memo.vbn files to the Samples folder.
Select Rules.vbn in the File System Editor.
In the Properties window, set the Condition property to Checkboxa1=1. When you run Setup, the Rules.vbn file is installed only when the Custom check box is selected.
Select the Memo.vbn file in the file System Editor.
In the Properties window, set the Condition property to Checkboxa1=1. When you run Setup, the Memo.vbn file is installed only when the Custom check box is selected.
To add a launch condition
This step checks whether Internet Explorer 5.0 or later is installed on the target computer and stops the installation process if the required version of Internet Explorer is not installed.

To check the Internet Explorer version by adding a launch condition

Note This step is intended to illustrate the concept of a startup condition; the My Notepad application does not actually rely on Internet Explorer.
In Solution Explorer, select the My Notepad installer project. On the View menu, point to Editor, and then select Launch condition.
In the Launch Conditions Editor, select the requirements on target computer node.
On the Action menu, select Add File Launch condition.
A "Search File1" node is added under the Search target Computers node, and a "Condition1" node is added under the Launch Conditions node.

Rename "Search File1" to "Search Internet Explorer."
In the Properties window, set the FileName property to Iexplore.exe, set the Folder property to [ProgramFilesFolder], set the Depth property to 2, and set the MinVersion property to 5.00.
Select the "Condition1" node.
Set the message property to "This program requires Microsoft Internet Explorer version 5.0 or later." Please install Internet Explorer and rerun the ' Notepad ' installer. ”。
Set optional properties
This step sets a property to automatically install the Windows installation bootstrapper files when the correct version of Windows Installer is not available on the target computer.

To set optional properties for a deployment project

In Solution Explorer, select the My Notepad installer project. On the View menu, select Property Pages.
In the My Notepad Installer property page, select the Bootstrapper drop-down list and choose Windows Installer bootstrapper.
On the Build menu, choose Build My Notepad installer.
Installing on the development computer
This step runs setup and installs my Notepad on the development computer.

Install my Notepad on the development computer

In Solution Explorer, select the My Notepad installer project. On the Project menu, choose Install.
Note You must have installation permissions on your computer to run Setup.
Deploy to another computer
This step will run Setup and install my Notepad to a different computer.

Deploy my Notepad to another computer

In Windows Explorer, navigate to the project directory and look for the generated installer. The default path is/documents and settings/yourloginname/my notepad installer/project configuration/my Notepad Installer.msi. The default project configuration is Debug.
Copy my Notepad installer. msi file and all other files and subdirectories from this directory to another computer.
Note To install on a computer that is not connected to the network, copy the file to a traditional media such as a CD-ROM.
Double-click the Setup.exe file on the target computer to run Setup.
Note You must have installation permissions on your computer to run Setup.

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.