Tuesday, 16 April 2013

Deploying a Visual Studio 2010 Tools for Office Solution Using Windows Installer



A VSTO2010  Deployed For Office Solution Windows Installer Setup Project

a) By using a Visual Studio 2010 Setup project to create a Windows Installer package 
    (deploys application-level add-ins to All Users.) ( uses ClickOnce to secure the solution.)
b) By using a ClickOnce deployment using the publish option in visual studio.
    (deploys application-level add-ins only to current Users.)( uses ClickOnce to secure the
     solution.)

Let us create a pptVivoAddIns named project and solution name same as project name,we 
create the Addins for power point office 2010(it can also use for 2007 office).

Build it,after build successfully. create setup project ,here i named as pptVivo_Addins 

To add the ExcelAddIn project output:-
      1.In the Solution Explorer, right-click pptVivo_AddIn, click Add and then
         Project Output.
      2.In the Add Project Output Group dialog box, and the Primary Output option is
        selected.
      3.Click OK to add the project output to the setup project.
Again we need to add file in project:-
     1.In the Solution Explorer, right-click pptVivo_AddIn, click Add, and click File.
     2.In the Add Files dialog box, navigate to the pptVivoAddIns output directory. Usually the
       output directory is the bin\release subfolder of the project root directory, depending on
       the selected build configuration.
    3.Select the pptVivoAddIns.vsto and pptVivoAddIns.dll.manifest files and click Open to 
       add hese two files to the setup project.
                                         
Requisites for setup project
 a) Primary output (.dll)
 b) application manifest(dll.manifest) 
 c) deployment manifest (vsto)
 d) utilities assemblies referenced by projects 
 e) Registry Entries
After add file we need to exclud some dependency in pptVivoAddIns :-

   1.In the Solution Explorer, in the pptVivo_AddIn node, select all dependency items beneath
     the Detected Dependencies item except for Microsoft .NET Framework or any assembly 
     that ends with *.Utilities.dll. The Utilities assembly is only present when your Office solution 
     targets .NET 4 and the assembly is meant to be deployed along with your application.

   2.Right-click the group and select Properties.

   3.In the Properties window, change the Exclude property to True to exclude the dependent 
     assemblies from the setup project. Make sure to not exclude any Utilities assemblies.

   4. If *.Utilities.dll not present  ,you can add it from right click on pptVivo_AddIn -->Add-->
      Assembly-->.Net tab-->select require  *.Utilities.dll--> Ok.

Configure Office Solution Prerequisites for Setup:-
    1.right click on pptVivo_AddIn-->Properties.

    2.properties dialog box appear select   Prerequisites select the options given below-


       a.first you select Create setup program to install prerequisite components written on top.

       b..net framework.
       c.Microsoft Visual Studio Tool for Office 2010 Runtime (x86 and x64).
       d.The primary interop assemblies (PIAs) for the version of Office that is installed.The PIAs 
          are optional for solutions that target the .NET Framework 4. (In your computer you can 
          add Microsoft Office 2007 Primary Interrop Assemblies for offic 2007 ).  
       e.Windows installer(given below).       

Registry Keys for Application-Level Add-Ins
You must create a specific set of registry entries when you deploy add-ins that are created by 
using Visual Studio 2010. These registry entries provide information that enables the Microsoft 
Office application to discover and load the add-in.

When you build your project, Visual Studio creates these registry entries on the development 

computer so that you can easily run and debug the add-in.
If you use ClickOnce to deploy your add-in, the registry entries are automatically created on 
the end user computer.If you use Windows Installer to deploy your add-in, you must configure 
the Setup project to create the registry entries on the end user computer.

When an add-in is installed, it can be registered in two ways:

a) For the current user only : In this case, the registry entries are created under the
    HKEY_CURRENT_USER.
b) For all users: In this case, the registry entries are created under HKEY_LOCAL_MACHINE.

Microsoft Office 2010 applications can load add-ins that are registered under HKEY_LOCAL_MACHINE 

or HKEY_CURRENT_USER.
By default, applications in the Microsoft Office 2007 can only load add-ins that are registered under HKEY_CURRENT_USER. To load add-ins that are registered under HKEY_LOCAL_MACHINE, 
computers that have these applications installed must also have hotfix package 976477 installed.

If you use ClickOnce to deploy an add-in, the add-in can be registered only for the current user. 

This is because ClickOnce only supports creating keys under HKEY_CURRENT_USER. If you 
want to register an add-in to all users on a computer, you must use Windows Installer to deploy the
add-in.
The required add-in registry entries are located under the following registry key for all applications ,
where Root is HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.
Root\Software\Microsoft\Office\application name\Addins\add-in ID

To Configure the Registry:-

 1.click the  pptVivo_AddIn, some icons shown above the solution explorer select registry editor 
    as shown in figure, to know name of these icons,just hold mouse over the icon.
  2.To add registry keys for  the add-in installation right-click the User/Machine Hive key, 
     select New and then Key. Use the text Software for the name of the new key. Right-click 
     on the newly created Software key and create a new key with the text Microsoft.

  3.Similarly you create a folder hierarchy ,shown in figure-

Registry Entries for Outlook Form Regions


If you create a custom form region in an add-in for Outlook, additional registry entries are used to register the form region with Outlook. These entries are created under a different registry key for each message class that the form region supports. These registry keys are in the following location, where Root is HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.
Root\Software\Microsoft\Office\Outlook\FormRegions\message class

Installing on 64-bit Operating Systems
Unlike the HKCU registry hive, the HKLM registry hive for Office add-ins is redirected on a 64-bit Windows OS. So if you are trying to register an add-in with 32-bit version of Office running on a 64-bit OS, the add-ins registry will be under the WOW6432 Node. The 32-bit Office running on 64-bit OS will always load the add-ins listed under this key.
e.g. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\application name\Addins\add-in ID

A 64-bit version of Office 2010 on 64-bit OS will always load the add-ins under this key:
e.g. HKEY_LOCAL_MACHINE\Software\Microsoft\Office\application name\Addins\add-in ID
  1. Select the  pptVivo_AddIn project in solution explorer.
  2. Go to Properties window and set TargetPlatform property to x64/x86.
You cannot have a single MSI that will install for 32-bit as well as 64-bit Office versions. You must create two
separate MSI packages that target the 32-bit and 64-bit versions of Office separately.

Configure Launch Conditions-
To configure launch conditions for Visual Studio 2010 Tools for Office Runtime-

1.Right click on pptVivo_AddIn-->view-->launch conditions.



2.In launch conditions-->Requirements on Target Machine-->Add Registry Launch Condition
   This search condition searches the registry for a key the Visual Studio Tools for Office runtime
   installs.The value of the key is then available to the various pieces of the installer through a named 
   property The launch condition uses the property defined by the search condition to check for a certain 
   value.

3.In  the launch conditions-->right click on Search for RegistryEntry1-->Properties Window.

         a.Set the value of (Name) to Search for VSTO 2010 Runtime.
         b.Change the value of Property to VSTORuntimeRedist.
         c.Set the value of RegKey to SOFTWARE\Microsoft\VSTO Runtime Setup\v4R.
         d.Leave the Root property set to vsdrrHKLM.
         e.Change the Value property to Version.
4.In  the launch conditions-->right click on Condition1-->Properties Window.
         a.Set (Name) to Verify VSTO 2010 Runtime availability.
         b.Change the value of the Condition property to the following 
            VSTORUNTIMEREDIST>="10.0.30319"
         c.Leave the InstallURL property blank.
         d.Change the value of the Message property to The Visual Studio 2010 Tools for Office
            Runtime is not installed. Please run Setup.exe.


To configure launch conditions for Visual Studio 2010 Tools for Office Runtime-


   1.In the Launch Conditions(OfficeAddInSetup) editor, right-click Search Target Machine.

   2.click Add Registry Search. Configure this additional search condition to search for the VSTO 

      Runtime installed through Office 2010. The launch condition can use the property defined by the 
      search condition in addition to the property for the RUNTIMEREDIST to check whether an 
      appropriate VSTO Runtime is present on the end users system.

   3.Select the Search for RegistryEntry1 search condition, right-click the condition and select 
      Properties Window and set the values.
      a.Set the value of (Name) to Search for Office 2010 VSTO Runtime.
      b.Change the value oProperty to OfficeRuntime.
      c.Set the value of RegKey to SOFTWARE\Microsoft\VSTO Runtime Setup\v4
      d.Leave the Root property set to vsdrrHKLM.
      e.Change the Value property to Version.



  4.In the Launch Conditions(pptVivo_AddIn) editor, select the Verify VSTO 2010 Runtime
     availability launch condition defined earlier, right-click the condition and 


     select Properties Window
  5.Change the value of the Condition property to the following 
     VSTORUNTIMEREDIST>="10.0.30319" OR OFFICERUNTIME>=”10.0.21022”.


To configure launch conditions for Office 2010 Shared PIA-

    1.In the Launch Conditions(ExcelAddInSetup) editor, right-click Requirements on
       Target Machine, and then click Add Windows Installer Launch Condition.
       This launch condition searches for the Microsoft Office 2010 Shared Primary Interop Assembly
       by searching for the specific component ID.

    2.Right-click Search for Component1 and click PropertiesWindow to show the properties of
       the launch condition In the PropertiesWindow, change the values of the following properties:
         a. Set the value of the (Name) property to Search for Office 2010 Shared PIA
         b. Set the value of the ComponentID property to
             {64E2917E-AA13-4CA4-BFFE-EA6EDA3AFCB4}.
         c. Set the value of the Property property to HASSHAREDPIA.

   4.In the Launch Conditions(ExcelAddInSetup) editor, right-click Condition1 and click 
      Properties Window to show the properties of the launch condition.

   5.Set the properties of Condition1 using the following information:
          a. Set (Name) to Verify Office 2010 Shared PIA availability.
          b. Set Condition to HASSHAREDPIA.
          c. Leave InstallUrl blank.
          d. Set Message to A required component for interacting with PowerPoint is not available.
              Please run setup.exe.

You can explore more component id for verify   the actual target.
for information about MS office 2007 click this link.

Finally the Launch Condition should be resembled as this image-

Now we need to build the project for create  the setup file-
   1.right click on  pptVivo_AddIn and click on Build.
   2.For navigate to target directory ,where your setup file is located.right click on pptVivo_AddIn
     and click 'Open Folder In Window Explorer'.
   3.Here click on 'Setup.exe' for install the application.

Discussion on import part of  this application- 

Deploying to all users


 Starting in Visual Studio 2010, you can use Windows Installer to deploy Office 2010 

 application-level add-ins to AllUsers. Installing and uninstalling add-ins requires administrator
 privileges. The security model still relies on ClickOnce. Therefore, the certificatethat is used 
 to sign the application and deployment manifests should be trusted at thmachine or enterprise
 level. Otherwise, each user may be prompted to verify that the add-in is trusted.

 An all user add-in cannot be deployed through ClickOnce and must be deployed through a 
 Windows Installer MSI.

Trusting the Add-In for all users

 If you are developing your solution with Visual Studio 2010 and targeting .NET 4, an alternative to

 signing with a Trusted Publisher certificate is to install the add-in into the machine Program 
 Files location. This location also needs administrative privilege to write to and will be inherently
 trusted by VSTO, Because the Office solutions were already granted FullTrust permissions during
 installation, VSTO 2010 Runtime will no longer check the inclusion list to verify if the certificate is
 trusted and there will be no trust prompt even if the solution is not signed with a Trusted Publisher 
 certificate.


      
  



No comments:

Post a Comment