Logo
PREGNANCY
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows 7

Visual Studio 2010 : Deploying Smart Client Applications (part 2) - Making a Windows Installer

7/21/2011 4:42:09 PM

2. Making a Windows Installer

Visual Studio 2010 provides setup projects you can use to deploy your applications. Setup projects create a Windows Installer file with the extension .msi.

These setup projects are available in Visual Studio:

  • Setup projects create an installer file that you can use to deploy a program on a target machine or to a virtual directory on a Web site. Visual Studio provides a wizard to walk you through creating setup projects.

  • Merge module projects create reusable setup components for consumption by setup projects.

  • A Cab project creates a CAB file from the items added to Solution Explorer. CAB files are often used to distribute components, such as ActiveX controls. The .cab file format (short for Microsoft Cabinet) is used for compressing files.

You can distribute the resulting MSI (Microsoft Installer) files by using CDs or DVDs, or a file share for installation across a network. MSI files can install an application on a target machine in a Windows application or on a Web site in a Web application.

The installation projects provided by Visual Studio take advantage of Windows Installer, which is an installation framework available on Windows operating systems. The installer takes care of how everything gets installed; you just focus on what you need to install. For example, the installer can create Registry entries, shortcuts, and Open Database Connectivity (ODBC) connections for you. You use a Visual Studio setup project to tell Windows Installer what to install. You don't have to write the code to make any of this installation happen. Windows Installer gets it installed for you.

Applications installed by using Windows Installer can

  • Self-repair if the program is damaged.

  • Roll back if the installation can't be completed.

NOTE

Windows Installer is sophisticated, and there's nothing you can't install with it.

2.1. Creating a setup project for an existing application

Although you can create standalone setup projects, you usually add setup projects to an existing solution that you want to deploy. To create a setup project for an existing application, follow these steps:

  1. Open a solution that includes a project you want to deploy.

  2. Right-click the solution in Solution Explorer.

    A shortcut menu appears.

  3. Choose Add=>New Project.

  4. In the Add New Project window, expand the Other Project Types category and select Setup and Deployment.

    You can choose either Install Shield 2010 or Windows Installer. If you choose Windows Installer, a list of project templates appear.

  5. Select Setup Wizard.

  6. Type a name for the project and then click OK.

    The Setup Wizard appears.

  7. Click Next.

    The Choose a Project Type page appears.

  8. Select the Create a Setup for a Windows Application option.

    You can use the wizard to create a Web setup project, a merge module, or a CAB file.

  9. Click Next.

    The Choose Project Outputs page appears. The project output from the other projects in the solution appears on this page. If no other projects are in the solution, this page doesn't appear. You have to add files to the setup project manually.

  10. Select the project output groups you want to deploy with your setup project.

    You want, at a minimum, content files and the primary output, which is the assembly created by your project.

    Specify that a file should be included as a content file by accessing the file's properties in Solution Explorer.


  11. Click Next.

  12. Add any files you want to deploy with your setup project.

  13. Click Next.

    The Create Project page appears.

  14. Click Finish.

    The project is created, and the content is added to Solution Explorer, as shown in Figure 10.

Setup projects have a number of editors you can use to build your installer, including the ones in this list:

  • File System: Identifies which files and shortcuts are created on the file system of the target machine

  • Registry: Creates Registry entries

  • File Types: Associates file extensions with applications

  • User Interface: Customizes the installation wizard

  • Custom Actions: Customizes the installation process

  • Launch Conditions: Creates conditional installation steps

Figure 10. Setup Wizard adds the new setup project in Solution Explorer.

These editors are fairly straightforward to use after you realize that you're taking the perspective of the target computer. You have to start by asking yourself what you want the target machine to look like when the installer is complete and then figure out how to make that happen by using these editors.

2.2. Putting the installer to work

To install a simple application and create shortcuts on the user's desktop and Start menu, use the File System Editor:

  1. Create a new setup project, as described in the preceding set of steps.

    The File System Editor opens by default.

    You can open any of the editors by using the View menu or the icons on the Solution Explorer toolbar.

    The File System Editor displays the file system of the target machine. You can elect to install files or shortcuts to special folders that are common to all Windows computers, such as a User's Desktop or Favorites folder.

    By default, the Application Folder, User's Desktop, and User's Program Menu folders are added to the editor. Right-click the File System on Target Machine option to add more folders.

  2. Select Application Folder.

    The folder's contents appear in the pane on the right.

    If you added your setup project to a solution with an existing project, the projects' output selected in the wizard appears. Right-click Application Folder and choose from the menu to add more files.

    Use the Properties window to set an installation folder for Application Folder.

  3. Right-click Primary Output in the Application folder.

    A shortcut menu appears.

  4. Choose Create Shortcut.

    A new shortcut appears, as shown in Figure 11.

    Figure 11. Adding shortcuts is easy, and they show in this list.
  5. Type a name for the shortcut.

    You want the shortcut to appear on the target computer.


  6. Right-click the shortcut and choose Cut.

  7. Right-click User's Desktop and choose Paste.

    The shortcut appears in the folder.

  8. Right-click the User's Programs Menu folder.

  9. Choose Add=>Folder from the shortcut menu.

  10. Type a name for the folder.

    You want the folder to appear on the user's Program menu.


  11. Repeat Steps 3 through 7 to add a shortcut to the new folder.

You now have an installer that installs your application and creates shortcuts on the user's desktop and then adds a folder with a shortcut to the Program menu.

Here's how to test the installer:

  1. Right-click the setup project in Solution Explorer.

  2. Choose Build from the shortcut menu.

    The project builds and packages the files.

    If you choose to build the entire solution, the setup project isn't included in the solution's build configuration in Configuration Manager. Either enable it to be built or build the project from the Build menu.

  3. Repeat Step 1 and choose Install from the shortcut menu.

    The installation wizard appears.

  4. Step through the wizard to install your application.

2.3. Sharing assemblies

Most of the time, you want your assemblies to be private. Only your application can access private assemblies. If you want to share your assemblies with other applications, you need to place them in the GAC. Examples of assemblies you may find in the GAC are the assemblies of the .NET Framework. When you place the assemblies in the GAC, all applications have access to them.

To publish an assembly to the GAC, it must use a strong name, which guarantees that all assemblies in the GAC have a unique name. A strong name comprises the assembly name, version number, public key, and digital signature. Suppose that your company creates an assembly named OrderEntry. Another company could feasibly create an assembly with the same name. A strongly named assembly creates a unique assembly, even if the assembly names were identical.

If you attempt to publish to the GAC an assembly that isn't strongly named, you receive an error message.

Visual Studio 2010 provides a way to strongly name assemblies and publish them to the GAC. To strongly name an assembly, follow these steps:

  1. Go to the Signing tab of Project Designer for the assembly you want to sign.

  2. Select the Sign the Assembly option.

  3. Open the Choose a Strong Name Key File drop-down list.

  4. Click Browse to reuse an existing key file or click New to create a new key file.

    If you click New, the Create Strong Name Key window appears. Type a name for the key file and a password to protect the file.

    The key file appears on the tab, as shown in Figure 12.

Figure 12. The strong key file has been added.

To install the assembly in the GAC by using a setup project, follow these steps:

  1. Open the File System Editor in the setup project.

  2. Right-click File System on Target Machine.

    A shortcut menu appears.

  3. Choose Add Special Folder=>Global Assembly Cache Folder.

    A GAC folder appears in the editor.

  4. Right-click Global Assembly Cache Folder in the editor.

  5. Choose Add=>Project Output.

    The Project Output Group window appears.

  6. Select the project from the Project drop-down list and then choose Primary Output, as shown in Figure 13.

    Figure 13. The project will install to the GAC.
  7. Click OK.

    The primary output appears in the editor.

Build the setup project and install it on a test machine. To view the GAC to ensure that the assembly was installed, take these steps:

  1. Open Administrative Tools in Control Panel.

  2. Double-click Microsoft .NET 4 Configuration.

    The configuration management console appears.

  3. Select Manage the Assembly Cache.

  4. Select the View List of Assemblies in the Assembly Cache option.

    A list of assemblies appears.

Other -----------------
- Microsoft Visio 2010 : Applying Themes to Your Diagrams (part 2)
- Microsoft Visio 2010 : Applying Themes to Your Diagrams (part 1)
- Microsoft Visio 2010 : Turning Off the Grid
- Managing Disks : Using the Disk Management Utility (part 2) - Understanding the Disk Management Utility
- Managing Disks : Using the Disk Management Utility (part 1) - Using the Microsoft Management Console
- Managing Disks : Configuring File Systems & Configuring Disk Storage
- Microsoft Excel 2010 : Saving and Managing a Chart Template
- Microsoft Excel 2010 : Adding and Deleting a Data Series
- Microsoft Visio 2010 : Using the Format Painter
- Microsoft Visio 2010 : Applying Line Styles and Colors
- Managing the Windows 7 Environment : Managing Windows 7 Services
- Managing the Windows 7 Environment : Configuring Advanced Power Settings
- Managing the Windows 7 Environment : Configuring Mobile Computing
- Visual Basic 2010 : Exposing .NET Objects to the COM World
- Visual Basic 2010 : Importing and Using COM Objects
- Microsoft Visio 2010 : Applying Color and Fill Patterns
- Microsoft Visio 2010 : Using the Auto Align & Space Feature
- Managing the Windows 7 Environment : Configuring Remote Connections (part 3) - Configuring a VPN Connection
- Managing the Windows 7 Environment : Configuring Remote Connections (part 2) - Remote Desktop
- Managing the Windows 7 Environment : Configuring Remote Connections (part 1) - Remote Assistance
 
 
Most view of day
- Microsoft Exchange Server 2013 : Working with cmdlets (part 2) - Understanding cmdlet errors, Using cmdlet aliases
- Microsoft Exchange Server 2010 : Setting Up Transport Rules (part 5) - Creating New Rules with the Exchange Management Shell
- Evaluating Applications for Windows 7 Compatibility : The Application Compatibility Toolkit (part 2) - Installing ACT
- QuarkXPress 8 : Checking spelling (part 1) - Running a spell check, Creating custom spelling dictionaries
- Collaborating Within an Exchange Environment Using Microsoft Office SharePoint Server 2007 : Customizing and Developing MOSS Sites
- Microsoft Word 2010 : Collaborating with Others - Limiting What Other Users Can Do to a Document
- QuarkXPress 8 : Checking spelling (part 2) - Searching and replacing, Exporting text
- Microsoft Exchange Server 2007 : Single Copy Clusters (part 2) - Installing Exchange Server 2007 on the Active Node
- Working with E-mail, Contacts, and Events : Add a Signature
- Games and Windows 7 : Installing and Playing Third-Party Games
Top 10
- Microsoft Sharepoint 2013 : Understanding app patterns (part 5) - Building MVC apps - Introducing MVC4
- Microsoft Sharepoint 2013 : Understanding app patterns (part 4) - Building MVC apps - Understanding web form challenges
- Microsoft Sharepoint 2013 : Understanding app patterns (part 3) - Building MVVM apps - Utilizing promises
- Microsoft Sharepoint 2013 : Understanding app patterns (part 3) - Building MVVM apps - Utilizing promises
- Microsoft Sharepoint 2013 : Understanding app patterns (part 2) - Building MVVM apps - Introducing knockout
- Microsoft Sharepoint 2013 : Understanding app patterns (part 1) - Building MVVM apps - Understanding JavaScript challenges
- Microsoft Access 2010 : Report Properties and Why to Use Them, Basing Reports on Stored Queries or Embedded SQL Statements
- Microsoft Access 2010 : Working with Sorting and Grouping (part 2) - Sorting and Grouping Settings
- Microsoft Access 2010 : Working with Sorting and Grouping (part 1) - Add Sorting and Grouping to a Report
- Microsoft Access 2010 : Building Reports Based on More Than One Table (part 3) - Working with Subreports
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro