Microsoft Installer Project

Another approach to deploying your VSTO solutions is to use a Visual Studio Setup project. The Visual Studio Setup project creates a Microsoft installer file, which has the extension .msi. The MSI files are standard Microsoft installer files. MSI files display an Install Wizard and add an entry to the Add And Remove Programs feature in the Control Panel to allow you to repair and uninstall the application.

Earlier in this chapter you learned about some of the shortcomings of the Publish Wizard, such as not checking for or installing client prerequisites and not configuring the client's security policy. Out of the box, the Visual Studio Setup project is missing a few features that you need to install your projects. The Setup project is extensible, but doing so is complicated and beyond the scope of this book. Microsoft has provided an article that explains in depth how to modify the Setup program. Following the steps outlined in the article will get your development machine configured correctly to create MSIs to install your VSTO projects. You can locate this article on MSDN at http://msdn.microsoft.com/library/ en-us/odc_vsto2005_ta/html/OfficeVSTOWindowsInstallerOverview.asp or by searching for the title "Deploying Visual Studio 2005 Tools for Office Solutions Using Windows Installer (Part 1 of 2)."

The Setup project does not check for prerequisites needed by VSTO. These checks are done as part of the Visual Studio bootstrapper, the setup.exe that is created by the Setup project to check for and optionally install the required software (see Figure 11.23). The bootstrapper is extensible using XML files, which you can copy from the deployment article.

Setup Property Pages

Configuration: [ÄctivefDebüg) Platform: |n/A

I H Configuration Properties Build

Output file name: | Debug\5etup.msi

Jjxj

Configuration Manager... |

W Create setup program to install prerequisite components Choose which prerequisites to install:

Check Microsoft Update for more redistributable components

Specify the install location for prerequisites -

C Download prerequisites from the component vendor's web site i* Download prerequisites from the same location as my application C Download prerequisites from the following location:

W Create setup program to install prerequisite components Choose which prerequisites to install:

n Microsoft Data Access Components 2.8

El jTnFT Framework 2.0

□ jpCrystal Reports for .NET Framework 2.0

□ jpMicrosoft Visual J# .NET Redistributable Package 2.0

El jp Microsoft Office 2003 Primary Interop Assemblies

□ jp Microsoft Visual Studio 2005 Report Viewer

El ^Microsoft Visual Studio 2005 Tools for Office Runtime

<1

Prerequisites... |

Apply

Figure 11.23. Setting prerequisites in the Setup Property Pages dialog box

Next, you update the application manifest that is embedded in the document by using the ServerDocument API (discussed in Chapter 13) in a custom action. As you can see in Figure 11.24, the UpdateManifest custom action is called from the Custom Actions tab of the Setup project. You use the CustomActionData property to pass parameters that are required by the custom action. The custom action is called when the user is doing an install, repair, or uninstall.

Now you update the CASPOL security on the client machine to give the code permission to run. You do this using a custom action. You can find an example of how to write the UpdateManifest custom action project and the SetSecurity custom action project that is added to your VSTO

Invoice - Microsoft Visual Studio

File Edit View Project Build Debug Data Tools | Test | Window

Custom Actions B"D Install

Primary output from UpdateManifest (Active) Primary output from SetSecurity (Active) B-Ca Commit

Primary output from UpdateManifest (Active) Primary output from SetSecurity (Active) B-Ca Rollback

Primary output from UpdateManifest (Active) Primary output from SetSecurity (Active) 0-D Uninstall

Primary output from UpdateManifest (Active) Primary output from SetSecurity (Active)

Community Help

Primary output from UpdateManifest (Active) Custom Actio A

(Name) Primary output from UpdateManifest (Active)

Condition

/targetDir="[TARGETDIR] f /documentName=1

EntryPoint

InstallerClass True

SourcePath C: documents and Settings V^stubbspesktop pi

Cu stom Action Data

Specifies custom data to be passed to an installer fci

Fi] Outoutj ^ Error Listjf^l Immediate Window | Ready

Figure 11.24. Custom action to update the manifest solution in the deployment article described earlier. Figure 11.25 shows that the SetSecurity custom action is called from the Custom Actions tab of your Setup project.

Invoice - Microsoft Visual Studio

File Edit View Project iai^tijii

UpdateManifest (Active)

Primary output from SetSecurity (Active)

Custom Actions (Setup)

Custom Actions B-Ca Install

Primary output from

B-Ca Commit

Primary output from Primary output from B Ca Rollback

Primary output from Primary output from B-Ca Uninstall

| ^ Primary output from

Primary output from

Build Debug Data Tools Test Action Window Community Help

* % * | Wk I l i J "J: c-. v| ► H ■ C? ^ I ^ & aS.» $ b

UpdateManifest (Active) SetSecurity (Active)

UpdateManifest (Active) SetSecurity (Active)

UpdateManifest (Active) SetSecurity (Active)

Primary output from SetSecurity (Active) Custom Action Pro A

(Name) Primary output from SetSecurity (Active) Condition

Custom ActionData /assemblyName="Invoice. dll" /targetDir=*[TARi EntryPoint

InstallerClass True

SourcePath C: documents and SettingsV^stubbspesktopp

Cu stom Action Data

Specifies custom data to be passed to an installer

■h m Output IError List| Immediate Window | Ready

Figure 11.25. Custom action to set the security

After you have added the prerequisite checks, updated the application manifest, and set the security permissions, you are ready to build the Setup project. The build from the Setup project produces an .msi file and a setup.exe file. Normally you run setup.exe to install your solution. Although you can run the .msi directly, the setup may stop if the client dependencies are not met.

0 0

Post a comment