Install and deploy (from msdn)

Source: Internet
Author: User
Visual Studio  
Walkthrough: deploying a Windows Application

This walkthrough demonstrates the process of creating an installer for a Windows application that launches notepad. in this walkthrough, you will create the windows application, then create an installer that sets up shortcuts and file associations, adds an entry to the Registry, displays custom dialogs, and checks the version of Internet Explorer during installation.

NoteWhen creating your own installers, not all of these steps are necessary. this walkthrough is intended to introduce you want some of the optional capabilities of deployment that you may find useful. to create a basic installer, complete the first four sets of procedures.

To create a Windows Application

  1. OnFileMenu, pointNew, And chooseProject.
  2. InNew projectDialog box, selectVisual Basic ProjectsInProject typesPane, and then chooseWindows ApplicationInTemplatesPane. InNameBox, typeMy notepad.
  3. ClickOKTo close the dialog box.

    The project is added to Solution Explorer, and the Windows Forms designer opens.

  4. SelectWindows FormsTab in the toolbox and dragButtonControl onto the form.
  5. Double-clickButtonControl to add an event handler for the button. In the event handler, add the following code:
    Shell("Notepad.exe", AppWinStyle.NormalFocus)

    This will launch notepad.exe and give it focus.

  6. OnBuildMenu, chooseBuild my notepadTo build the application.

To create a deployment project

  1. OnFileMenu, pointAdd Project, And chooseNew project.
  2. InAdd new projectDialog box, selectSetup and deployment projectsInProject typesPane, and then chooseSetup ProjectInTemplatesPane. InNameBox, typeMy notepad Installer.
  3. ClickOKTo close the dialog box.

    The project is added to Solution Explorer, and the file system Editor opens.

  4. SelectMy notepad InstallerProject in Solution Explorer. In the Properties window, selectProductnameProperty and typeMy notepad.
    NoteThe ProductnameProperty determines the name that will be displayed for the application in folder names and in Add/Remove ProgramsDialog box.

To add the windows application to the installer

  1. SelectMy notepad InstallerProject in Solution Explorer. In the file system Editor, selectApplication folderNode.
  2. OnActionMenu, chooseAdd,Project output.
  3. InAdd project output GroupDialog box, chooseMy notepadFromProjectDrop-down list. ClickOKTo close the dialog box.
  4. SelectPrimary outputGroup from the list, then clickOK.
  5. OnBuildMenu, chooseBuild my notepad Installer.

To deploy the application (Basic installer)

This step can be skipped if you are following the complete walkthrough.

  • Select the my notepad installer project in Solution Explorer. OnProjectMenu, chooseInstall.

    This will run the installer and install my notepad on your development computer.

    NoteYou must have install permissions on the computer in order to run the installer.

Optional deployment capabilities

The remaining steps demonstrate optional deployment capabilities.

Creating a shortcut

This step creates a shortcut cut to your application that will be placed on the desktop of a target computer during installation.

To create shortcuts for the Windows Application

  1. Select the my notepad installer project in Solution Explorer.
  2. In the file system Editor, selectPrimary output from my notepadNode.
  3. OnActionMenu, chooseCreate procedure cut to primary output from my notepad.

    This will addShortcut Primary output from my notepadNode.

  4. Rename the shortcutShortcut cut to my notepad.
  5. SelectShortcut to my notepadAnd drag it toUser's desktopFolder in the left pane.
Creating a File Association

This step adds a file association for my notepad so that double-clicking. VBN files will launch the my notepad application.

To Create File Associations for the Windows Application

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, And chooseFile Types.
  2. SelectFile Types on target machineNode in the File Types Editor. OnActionMenu, chooseAdd file type.

    ANew Document Type #1Node is added and opened for renaming.

  3. Rename new document type #1Vbn.doc.
  4. In the Properties window, setExtensionProperty of the file typeVBN.
  5. SelectCommandProperty and clickEllipsis() Button. InSelect item in ProjectDialog box, navigate toApplication Folder, And selectPrimary output from my notepad.
  6. ClickOKTo close the dialog box.
Adding a registry entry

This step adds a registry key and value to the Registry. You cocould reference this registry key from your application's code to retrieve per-user information at run time.

To add a registry entry for the Windows Application

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, And chooseRegistry.
  2. SelectHKEY_CURRENT_USERNode and expand it, then expandSoftwareNode and select[Manufacturer]Node.
    NoteThe manufacturer node is surrounded by brackets to denote that it is a property. It will be replaced by the value entered for ManufacturerProperty for the deployment project.

  3. OnActionMenu, chooseNew,Key.
  4. Rename the keyUserchoice.
  5. Select the userchoice key.
  6. OnActionMenu, pointNew, Then clickString Value.
  7. Rename the valueTextcolor.
  8. In the Properties window, selectValueProperty and enterBlack.
Adding a custom installation dialog box

This step adds and configures a Custom User interface dialog box that will be displayed during installation.

To add a custom installation dialog box

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, And chooseUser Interface.
  2. In the User Interface Editor, selectStartNode underInstallNode.
  3. OnActionMenu, chooseAdd Dialog.
  4. InAdd DialogDialog box, chooseCheckboxes ().
  5. ClickOKTo close the dialog box.
  6. OnActionMenu, chooseMove upTwice to positionCheckboxes ()Dialog box aboveInstallation FolderDialog box.
  7. In the Properties window, setBannertextPropertySamples.
  8. SetBodytextPropertyThe Install samples check box controls whether or not the sample files are installed. If left unselected, the samples will not be installed.
  9. SetCheckbox1labelPropertyInstall samples?
  10. Set the propertiesCheckbox2visible,Checkbox3visible, AndCheckbox4visibleToFalse. This will hide the additional check boxes.
Working with samples

This step creates a samples subfolder that will be installed beneath the application folder.

To add a samples folder

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, And chooseFile System.Application FolderShocould still be selected.
  2. FromActionMenu, pointAdd, And chooseFolder.
  3. Rename "new folder #1"Samples.

This step creates two sample text files that will be installed if the user chooses the install samples option in the Custom dialog.

To create sample files for the Application

  1. Using notepad or another text editor, create a text file containing the textThis is rules. VBN.Save itRules. VBN.
    NoteTo prevent notepad from automatically adding a. txt extension, choose All filesIn Files of TypeDrop-down list.

  2. Create another text file containing the textThis is Memo. VBN.Save itMemo. VBN.

This step adds the sample files to the samples folder, and sets a condition that determines whether to install the files.

To add the samples to the installer

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, ChooseFile System, And selectSamplesFolder.
  2. FromActionMenu, pointAdd, And chooseFile. AddRules. VBNAndMemo. VBNFiles toSamplesFolder.
  3. Select the fileRules. VBNIn the file system editor.
  4. In the Properties window, setConditionPropertyCheckboxa1 = 1. When the installer is run, the fileRules. VBNWill only be installed if the custom check box is selected.
  5. Select the fileMemo. VBNIn the file system editor.
  6. In the Properties window, setConditionPropertyCheckboxa1 = 1. When the installer is run, the fileMemo. VBNWill only be installed if the custom check box is selected.
Adding Launch Conditions

This step checks to see if Internet Explorer 5.0 or higher is installed on a target computer, and halts installation if it is not installed.

To add a launch condition to check the Internet Explorer version

NoteThis step is intended to demonstrate the concept of launch conditions; The my notepad application has no actual dependency on Internet Explorer.

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, pointEditor, And chooseLaunch Conditions.
  2. In the Launch Conditions Editor, selectRequirements on target machineNode.
  3. OnActionMenu, chooseAdd file launch condition.

    ASearch for file1Node is added beneathSearch target machineNode, andCondition1Node is added beneathLaunch ConditionsNode.

  4. RenameSearch for file1ToSearch for Internet Explorer.
  5. In the Properties window, setFilenamePropertyIexplore.exe,FolderProperty[Programfilesfolder],DepthProperty2, AndMinversionProperty5.00.
  6. SelectCondition1Node.
  7. SetMessagePropertyThis program requires Microsoft Internet Explorer 5.0 or higher. Please install Internet Explorer and rerun the notepad installer.
Setting optional Properties

This step sets a property to automatically install the Windows Installer bootstrapping application files if the correct version of Windows Installer is not present on the target computer.

To set optional properties for the deployment project

  1. SelectMy notepad InstallerProject in Solution Explorer. OnViewMenu, chooseProperty pages.
  2. OnMy notepad InstallerProperty page, selectBootstrapperDrop-down list, and chooseWindows Installer bootstrapper.
  3. OnBuildMenu, chooseBuild my notepad Installer.
Installing on your development computer

This step will run the installer and install my notepad on your development computer.

To install my notepad on your development computer

  • SelectMy notepad InstallerProject in Solution Explorer. OnProjectMenu, chooseInstall.
    NoteYou must have install permissions on the computer in order to run the installer.

Deploying to another computer

This step will run the installer and install my notepad on another computer.

To deploy my notepad to another computer

  1. In Windows Explorer, navigate to your project directory and find the built Installer. The default path will be/Documents and Settings/Yourloginname/My notepad installer/Project Configuration/My notepad Installer. MSI. The defaultProject ConfigurationIs debug.
  2. Copy the my notepad Installer. MSI file and all other files and subdirectories in the directory to another computer.
    NoteTo install on a computer that is not on a network, copy the files to traditional media such as CD-ROM.

  3. On the target computer, double-clickSetup.exeFile to run the installer.
    NoteYou must have install permissions on the computer in order to run the installer.

Testing

This step will test starting the installer from a desktop shortcut cut and uninstalling.

To test the installation

  1. Verify that the specified cut is installed on the desktop and that it correctly launches the my notepad application.
  2. Uninstall the application usingAdd/Remove ProgramsTool in Control Panel.
    TipTo uninstall from your development computer, on ProjectMenu, choose Uninstall.

See also

Creating or adding deployment projects | adding items to a deployment project | File Installation Management in deployment | Registry Settings Management in deployment | file types Management in deployment | User Interface Management in deployment | launch Condition Management in deployment

 

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.