Vs. Net (C #) Package C #'s source program into an EXE or MSI installation package

Source: Internet
Author: User
C # Application Deployment 1: new installation and deployment project open vs, click New Project, select other project types> installation and deployment> Installation Wizard (the same is true for the installation project ), click OK. (For details, see) The following figure shows the topic. 2. Open the Installation Wizard after the installation wizard is closed, click Next, or click Finish. 3: After the installation wizard is complete, go to the project folder. Double-click "application folder", right-click the blank area on the right, and choose add> file, add the executable files and corresponding class libraries and components of your application. right-click your executable file, create a shortcut, and cut or copy the shortcut to "user's 'project' menu" and "User desktop" on the left. after the installation and installation of the installer are complete, the program shortcut will be generated on "start-> All Programs" and "desktop. right-click "application folder" on the left to open the Properties dialog box: Remove "[manufacturer]" from the "defaultlocation" path in the property, otherwise, the default installation directory of the installation program will be "C:/programm fi Le/your username/installation solution name "; then open solution manager, right-click your solution name, and select Properties: On the open properties page, select net. framework Options (usually selected by default), OK and click Generate on the solution above ~ Your first complete program completes the second method to deploy C # As a Windows application--deploy a Windows application this walkthrough demonstrates creating an installer for the Windows application that starts notepad. In this walkthrough, you will first create a Windows application and then an installer; this allows you to set shortcuts and file associations, add registry keys, display custom dialog boxes, and check Internet Explorer versions during installation. Note that you do not need to perform all the following steps when creating your own installer. The purpose of this walkthrough is to introduce some optional functions that may be used during deployment. To create a basic installer, you only need to complete the first four parts of the installation process. Create a Windows application, point to "new" on the "file" menu, and select "project ". In the Create Project dialog box, select Visual Basic Project in the project type pane, and select windows application in the template 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 Form Designer is enabled. In the toolbox, select the Windows Forms tab and drag the button control to the form. Double-click the button control to add an event handler for the button. Add the following code to the event handler: Shell ("notepad.exe", appwinstyle. normalfocus). This will start notepad.exe and focus on it. On the "generate" menu, select "generate my notepad" for this application. Create a deployment project on the "file" menu, point to "add Project", and then select "new project ". In the Add new project dialog box, select "Install and deploy Project" in the "project type" pane, and select "Install Project" in the "template" pane ". In the "name" box, type "my notepad installer ". Click OK to close the dialog box. The project is added to Solution Explorer and opened in the file system editor. In Solution Explorer, select the my notepad installer project. In the "properties" window, select the productname attribute and type "my notepad ". Note that the productname attribute determines the folder name and the name displayed in the "Add/delete programs" dialog box for the application. Add a Windows application to the installer and select the "my notepad installer" project in Solution Explorer. In the file system Editor, select the application folder node. On the "operations" menu, choose "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 "generate" menu, select "generate my notepad installer ". Deploy the application (Basic installer). skip this step if you are performing a full walkthrough. In Solution Explorer, select the my notepad installer project. Select "Install" from the "project" menu ". This will run the installer and install "my notepad" on the development computer ". Note that you must have the installation permission on your computer to run the installer. Optional deployment functions the remaining steps demonstrate the optional deployment functions. Create shortcuts this step creates a shortcut for your application. During installation, the shortcut is placed on the desktop of the target computer. Create shortcuts for Windows applications. In Solution Explorer, select the my notepad installer project. In the file system Editor, select the "main output from my notepad" node. On the "operations" menu, select "create primary output shortcut from my notepad ". This will add a "primary output shortcut from my notepad" node. Rename this shortcut to "my notepad shortcut ". Select "my notepad shortcuts" and drag it to the "user desktop" folder in the left pane. Create File Association this step adds a file association for "My Notepad" to start the "my notepad" application when you double-click the. VBN file. 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 select "file type ". In the file type editor, select the file type node on the target computer. On the "operations" menu, select "add file type ". A "New Document Type #1" node will be added, and the node will be open for you to rename. Rename "New Document Type #1" to vbn.doc. In the Properties window, set the extension attribute of the file type to VBN. Select the command attribute and click the ellipsis. In the "select items in project" dialog box, locate "application folder" and select "main output from 'my notepad '". Click OK to close the dialog box. Add registry key this step adds a registry key and the corresponding value to the Registry. During running, you can reference this registry key from the application code to retrieve information about each user. Add a registry 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, expand it, expand the "software" node, and select the "[manufacturer]" node. Note that the manufacturer node has parentheses, indicating that it is an attribute. It will be replaced with the manufacturer property value of the input deployment project. On the "operations" menu, choose "New"> "item ". Rename the userchoice item. Select the userchoice item. On the "operations" menu, point to "new" and click "string value ". Rename the textcolor value. In the "properties" window, select the Value Attribute and Enter black. Add custom installation dialog box this step adds and configures a Custom User interface dialog box displayed during installation. In the add custom installation dialog box, select "my notepad installer" in Solution Explorer. On the "View" menu, point to "Editor" and select "User Interface ". In the User Interface Editor, select the Start Node under the "Install" node. On the "operations" menu, select "add dialog box ". In the Add dialog box, select check box ()". Click OK to close the dialog box. On the "operations" menu, select "Move Up" twice, and place the "check box (a)" dialog box on the "Install Folder" dialog box. In the "properties" window, set the bannertext attribute to "example ". Set the bodytext attribute to the "install sample file" check box to check whether the sample file is installed. If it is not selected, the example is not installed. Set the checkbox1label attribute to "do you want to install an example ?". Set the checkbox2visible, checkbox3visible, and checkbox4visible attributes to false. This hides other check boxes. Use this example to create a samples sub-folder, which 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 select "File System ". The "application folder" should still be selected. From the "operations" menu, point to "add" and select "folder ". Rename "new folder #1" as "example ". This step creates two simple text files. If you select the "installation example" option in the Custom dialog box, the two text files will be installed. Create a sample file for the application. use notepad or another text editor to create a text file containing the text "this is rules. VBN" and save it as 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 containing the text "this is Memo. VBN" and save it as memo. VBN. In this step, add the sample file to the samples folder and set the conditions to determine whether to install the file. Add the example to the installer and select the "my notepad installer" project in Solution Explorer. From the "View" menu, point to "Editor", select "File System", and select the "example" folder. From the "operations" menu, point to "add" and select "File ". Add the rules. VBN and memo. VBN files to the "example" folder. In the file system Editor, select rules. VBN. In the "properties" window, set the condition attribute to checkboxa1 = 1. When running the installer, the rules. VBN file is installed only when the custom check box is selected. In the file system Editor, select the memo. VBN file. In the "properties" window, set the condition attribute to checkboxa1 = 1. When running the installer, the memo. VBN file is installed only when the custom check box is selected. Add startup conditions this step checks whether Internet Explorer 5.0 or later is installed on the target computer. If you do not install the required version of Internet Explorer, the installation process is stopped. Add a start condition to check Internet Explorer versions. Note that this step aims to describe the concept of a start 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 select "Startup conditions ". In the launch condition editor, select the requirement node on the target computer. On the "operations" menu, select "add file startup conditions ". A "Search for file1" node will be added under the "Search for target computer" node, and a "condition1" node will be added under the "Start condition" node. Rename "Search for file1" to "Search for Internet Explorer ". In the "properties" window, set the filename attribute to iexplore.exe, set the folder attribute to [programfilesfolder], set the depth attribute to 2, and set the minversion attribute to 5.00. Select the "condition1" node. Set the message attribute to "this program requires Microsoft Internet Explorer 5.0 or later. Install Internet Explorer and run the 'notepad 'installer again .". Set optional properties this step sets an attribute to automatically install the Windows Installation Guide file when the target computer does not have a correct version of Windows Installer. Set the optional properties of the deployment project. In Solution Explorer, select the "my notepad installer" project. On the "View" menu, select "attribute page ". On the "my notepad installer" property page, select the "Bootstrap" drop-down list and select "Windows Installer ". On the "generate" menu, select "generate my notepad installer ". Install this step on the development computer to run the installer and install "my notepad" on the development computer ". Install "my notepad" on the development computer and select the "my notepad installer" project in Solution Explorer. Select "Install" from the "project" menu ". Note that you must have the installation permission on your computer to run the installer. Deploy to another computer this step will run the installer and install my notepad on another computer. Deploy "my notepad" to another computer in Windows Resource Manager, locate the project directory, and find the generated installer. The default path is/Documents and Settings/yourloginname/my notepad installer/project configuration/my notepad Installer. MSI. By default, "project configuration" is "debugging ". Copy the my notepad Installer. MSI file and all other files and subdirectories in the directory to another computer. Note to install it on a computer that is not connected, copy the file to a traditional media such as a CD-ROM. Double-click the setup.exe file on the target computer to run the installer. Note that you must have the installation permission on your computer to run the installer.

References: http://caixiaofengtcx.bokee.com/2907794.html

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.