チュートリアル: 複数の Office ソリューションを単一の ClickOnce インストーラーで配置する

複数の Office ソリューションを 1 つのパッケージで配置することで、インストール プロセスと更新プロセスを簡素化できます。 このためには、発行後にアプリケーション マニフェストと配置マニフェストを変更して再署名して、インストールする必要があります。

対象: このトピックの情報は、Microsoft Office 2013 Preview および Microsoft Office 2010 のドキュメント レベルのプロジェクトおよびアプリケーション レベルのプロジェクトに適用されます。詳細については、「Office アプリケーションおよびプロジェクト タイプ別の使用可能な機能」を参照してください。

このチュートリアルでは、次の作業について説明します。

  • 複数の Office ソリューションの作成.

  • アプリケーション マニフェストの変更.

  • マニフェストへの再署名.

注意

次の手順で参照している Visual Studio ユーザー インターフェイス要素の一部は、お使いのコンピューターでは名前や場所が異なる場合があります。これらの要素は、使用している Visual Studio のエディションや独自の設定によって決まります。詳細については、「Visual Studio の設定」を参照してください。

必須コンポーネント

このチュートリアルを実行するには、次のコンポーネントが必要です。

-

Microsoft Office Developer Tools が含まれているエディションの Visual Studio 2012。詳細については、「[Office ソリューションを開発できるようにコンピューターを構成する](https://msdn.microsoft.com/ja-jp/library/bb398242\(v=vs.110\))」を参照してください。
  • Word 2013 プレビュー版

  • Outlook 2013 プレビュー版

  • Excel 2013 プレビュー版

  • Word 2010

  • Outlook 2010

  • Excel 2010

  • テスト コンピューター。

複数の Office ソリューションの作成

まず、3 つの Office プロジェクトを作成します。そのうちの 1 つは、インストーラーに使用します。 残りの 2 つは、エンド ユーザーのコンピューターに配置します。

新しい Word プロジェクト、Outlook プロジェクト、および Excel プロジェクトを作成および開発するには

  1. Wordのドキュメント レベルのプロジェクトを作成します。 プロジェクトに「ContosoInstaller」という名前を付けて、%USERPROFILE%\Documents\Visual Studio 2012\Projects ディレクトリに保存します。

    この ContosoInstaller プロジェクトは、インストーラーとして使用します。 詳細については、「方法: Visual Studio で Office プロジェクトを作成する」を参照してください。

  2. ContosoInstaller ソリューションに、Outlook のアプリケーション レベルのプロジェクトを「ContosoOutlookAddIn」という名前を付けて追加し、コードをこの Outlook プロジェクトに追加します。

  3. ContosoInstaller ソリューションに、Excel のドキュメント レベルのプロジェクトを「ContosoExcelWorkbook」という名前を付けて追加し、コードをこの Excel プロジェクトに追加します。

Office ソリューションの発行

発行ウィザードまたはプロジェクト デザイナープロジェクト ページを使用して、Office ソリューションを開発用コンピューターに発行します。

Word、プロジェクト、Outlook プロジェクト、および Excel プロジェクトを発行するには

  1. ContosoInstaller プロジェクトを c:\publish フォルダーに発行します。 詳細については、「方法: ClickOnce を使用して Office ソリューションを公開する」を参照してください。

  2. ContosoOutlookAddIn プロジェクトを c:\publish フォルダーに発行します。

  3. ContosoExcelWorkbook プロジェクトを c:\publish フォルダーに発行します。

アプリケーション マニフェストの変更

Visual Studio の XML エディターを使用して、インストール依存関係、ファイル、エントリ ポイント、およびアセンブリをアプリケーション マニフェストに追加します。 アプリケーション マニフェストの内容は、製品に含まれる内容すべての一覧を記載した部品表に似ています。アプリケーション マニフェストには、すべての依存アセンブリと必要条件アセンブリのほか、アプリケーションに必要なファイルも記載されています。 Office ソリューションのアプリケーション マニフェストには、アプリケーション レベルのアドインおよびドキュメント レベルのカスタマイズ用に Office アプリケーションから読み込む必要のあるアセンブリの一覧も記載されています。

Dd465290.collapse_all(ja-jp,VS.110).gifインストール依存関係の追加

ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリをインストールするようにアプリケーション マニフェストを変更して、ContosoInstaller アセンブリへの参照を削除します。

アプリケーション マニフェストにインストール依存関係を追加するには

  1. c:\publish\Application Files フォルダーの ContosoOutlookAddIn_1_0_0_0 ディレクトリと ContosoExcelWorkbook_1_0_0_0 ディレクトリの内容を ContosoInstaller_1_0_0_0 ディレクトリに移動します。

  2. ContosoInstaller.dll.manifest ファイル、ContosoOutlookAddIn.dll.manifest ファイル、および ContosoExcelWorkbook.dll.manifest ファイルを XML エディターで開きます。

  3. ContosoOutlookAddIn.dll.manifest ファイルから、すべてのインストール依存関係とファイル依存関係 (ContosoOutlookAddIn.dll など) をコピーします。 つまり、<dependentAssembly dependencyType="install" または <file name="app.config"> で始まるすべての依存関係をコピーします。 コードは次のようになります。: <dsig:DigestValue> の要素のみが異なります。

      <dependency>
        <dependentAssembly 
           dependencyType="install"
           allowDelayedBinding="true" 
           codebase="Microsoft.Office.Tools.Common.v4.0.Utilities.dll" 
           size="30816">
          <assemblyIdentity 
            name="Microsoft.Office.Tools.Common.v4.0.Utilities" 
            version="10.0.0.0"
            publicKeyToken="B03F5F7F11D50A3A"
            language="neutral"
            processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform
                Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod 
              Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>Ki0…</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <dependency>
        <dependentAssembly
          dependencyType="install"
          allowDelayedBinding="true" 
          codebase="Microsoft.Office.Tools.Outlook.v4.0.Utilities.dll"   
          size="47200">
          <assemblyIdentity 
            name="Microsoft.Office.Tools.Outlook.v4.0.Utilities" 
            version="10.0.0.0"
            publicKeyToken="B03F5F7F11D50A3A"
            language="neutral" 
            processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform
                Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod 
              Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>050...</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <dependency>
        <dependentAssembly
          dependencyType="install" 
          allowDelayedBinding="true"
          codebase="ContosoOutlookAddIn.dll"
          size="10240">
          <assemblyIdentity
            name="ContosoOutlookAddIn" 
            version="1.0.0.0" 
            language="neutral" 
            processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform Algorithm=
                "urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod Algorithm=
              "http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>i4e</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <file name="ContosoOutlookAddIn.dll.config" size="77">
        <hash>
          <dsig:Transforms>
            <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
          </dsig:Transforms>
          <dsig:DigestMethod 
             Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
          <dsig:DigestValue>w7W...</dsig:DigestValue>
        </hash>
      </file>
    
  4. ContosoInstaller.dll.manifest ファイルの dependency セクションの最後に、ContosoOutlookAddIn.dll インストール依存関係を貼り付けます。

  5. ContosoExcelWorkbook.dll.manifest ファイルから、すべてのインストール依存関係とファイル依存関係 (ContosoExcelWorkbook.dll、Microsoft.Office.Tools.Common.v4.0.Utilities.dll など) をコピーします。 つまり、<dependentAssembly dependencyType="install" または <file name="app.config"> で始まるすべての依存関係をコピーします。 コードは次のようになります。: <dsig:DigestValue> の要素のみが異なります。

      <dependency>
        <dependentAssembly
          dependencyType="install"
          allowDelayedBinding="true"
          codebase="ContosoExcelWorkbook.dll"
          size="12800">
          <assemblyIdentity
            name="ContosoExcelWorkbook" 
            version="1.0.0.0"
            language="neutral"
            processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform Algorithm=
                "urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod Algorithm=
              "http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>i4e</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <dependency>
        <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="Microsoft.Office.Tools.Common.v4.0.Utilities.dll" size="30816">
          <assemblyIdentity name="Microsoft.Office.Tools.Common.v4.0.Utilities" version="10.0.0.0" publicKeyToken="B03F5F7F11D50A3A" language="neutral" processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>Ki0A9wOpes1YX5NaAvjmUeFSh0g=</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <dependency>
        <dependentAssembly
          dependencyType="install"
          allowDelayedBinding="true" 
          codebase="Microsoft.Office.Tools.Excel.v4.0.Utilities.dll" 
          size="235104">
          <assemblyIdentity 
            name="Microsoft.Office.Tools.Excel.v4.0.Utilities" 
            version="10.0.0.0"
            publicKeyToken="B03F5F7F11D50A3A"
            language="neutral"
            processorArchitecture="msil" />
          <hash>
            <dsig:Transforms>
              <dsig:Transform
               Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod 
              Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>Te/...</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
      <file name=" ContosoExcelWorkbook.dll.config" size="77">
        <hash>
          <dsig:Transforms>
            <dsig:Transform
             Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
          </dsig:Transforms>
          <dsig:DigestMethod 
            Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
          <dsig:DigestValue>w7W...</dsig:DigestValue>
        </hash>
      </file>
    
  6. ContosoInstaller.dll.manifest ファイルの dependency セクションの最後に、インストール依存関係を貼り付けます。

  7. ContosoInstaller.dll.manifest ファイルで、ContosoInstaller.dll および Microsoft.Office.Tools.Word.v4.0.Utilities.dll の各インストール依存関係を削除します。 また、重複する依存関係も削除します。 たとえば、Microsoft.Office.Tools.Common.v4.0.Utilities.dll のインストール依存関係を複数コピーしている可能性があります。

    注意

    Word のドキュメント レベルのソリューションを配置する場合は、最後のマニフェストの Microsoft.Office.Tools.Word.v4.0.Utilities.dll は削除しないでください。

Dd465290.collapse_all(ja-jp,VS.110).gifエントリ ポイントの追加

ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリが <vstav3> 名前空間に読み込まれるように、アプリケーション マニフェストを変更します。

vstav3 名前空間のエントリ ポイントをアプリケーション マニフェストに追加するには

  1. ContosoInstaller.dll.manifest ファイルから <vstav3:entryPointsCollection> 要素と </vstav3:entryPointsCollection> 要素の間のテキストを削除します。

  2. ContosoOutlookAddIn.dll.manifest ファイルから <vstav3:entryPointsCollection> 要素と </vstav3:entryPointsCollection> 要素の間のテキストをコピーします。 コードは次のようになります。

          <vstav3:entryPoints>
            <vstav3:entryPoint
              class="ContosoOutlookAddIn.ThisAddIn">
              <assemblyIdentity
                name="ContosoOutlookAddIn"
                version="1.0.0.0"
                language="neutral"
                processorArchitecture="msil" />
            </vstav3:entryPoint>
          </vstav3:entryPoints>
    

    注意

    Outlook のアプリケーション レベルのアドインでフォーム領域を使用する場合は、Outlook のエントリ ポイントを <vstav3:entryPoints> セクションの最後のエントリ ポイントにする必要があります。

  3. ContosoInstaller.dll.manifest ファイルの <vstav3:entryPointsCollection> 要素の後に、コードを貼り付けます。

  4. 他のこのエントリ ポイントを区別するために <vstav3:entryPoints> の要素に id の属性を追加します。

          <vstav3:entryPoints id="ContosoOutlook">
    
  5. ContosoExcelWorkbook.dll.manifest ファイルから <vstav3:entryPointsCollection> 要素と </vstav3:entryPointsCollection> 要素の間のテキストをコピーします。 コードは次のようになります。

          <vstav3:entryPoints>
            <vstav3:entryPoint 
              class="ContosoExcelWorkbook.ThisWorkbook">
              <assemblyIdentity
                name="ContosoExcelWorkbook"
                version="1.0.0.0"
                language="neutral"
                processorArchitecture="msil" />
            </vstav3:entryPoint>
            <vstav3:entryPoint
               class="ContosoExcelWorkbook.Sheet1">
              <assemblyIdentity
                name="ContosoExcelWorkbook"
                version="1.0.0.0"
                language="neutral"
                processorArchitecture="msil" />
            </vstav3:entryPoint>
            <vstav3:entryPoint
              class="ContosoExcelWorkbook.Sheet2">
              <assemblyIdentity
                name="ContosoExcelWorkbook"
                version="1.0.0.0"
                language="neutral"
                processorArchitecture="msil" />
            </vstav3:entryPoint>
            <vstav3:entryPoint
              class="ContosoExcelWorkbook.Sheet3">
              <assemblyIdentity
                name="ContosoExcelWorkbook"
                version="1.0.0.0"
                language="neutral"
                processorArchitecture="msil" />
            </vstav3:entryPoint>
          </vstav3:entryPoints>
    
  6. ContosoInstaller.dll.manifest ファイルの <vstav3:entryPointsCollection> 要素の後に、コードを貼り付けます。

  7. id 属性を <vstav3:entryPoints> 要素に追加して、このエントリ ポイントと他のエントリ ポイントとを区別します。

          <vstav3:entryPoints id="ContosoExcel">
    

Dd465290.collapse_all(ja-jp,VS.110).gifアセンブリの追加

ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリが <vstov4> 名前空間に読み込まれるように、アプリケーション マニフェストを変更します。

アプリケーション マニフェストの vstov4 名前空間にアセンブリを追加するには

  1. ContosoInstaller.dll.manifest ファイルから <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素と </vstov4:customizations> 要素の間のテキストを削除します。

  2. ContosoOutlookAddIn.dll.manifest ファイルから <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素と </vstov4:customizations> 要素の間のテキストをコピーします。 コードは次のようになります。

            <vstov4:customization>
              <vstov4:appAddIn
                application="Outlook"
                loadBehavior="3"
                keyName="ContosoOutlookAddIn">
                <vstov4:friendlyName>
                  ContosoOutlookAddIn
                </vstov4:friendlyName>
                <vstov4:description>
                  ContosoOutlookAddIn - Outlook add-in created with
                  Visual Studio Tools for Office
                </vstov4:description>
              </vstov4:appAddIn>
            </vstov4:customization>
    
  3. ContosoInstaller.dll.manifest ファイルの <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素の後に、コードを貼り付けます。

  4. id 属性を <vstav3:customization> 要素に追加して、このカスタマイズ部分と他の部分とを区別します。 この id は前の手順で <vstav3:entryPoints> 要素に追加した id と同じです。

            <vstov4:customization id="ContosoOutlook">
    
  5. ContosoExcelWorkbook.dll.manifest ファイルから <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素と </vstov4:customizations> 要素の間のテキストをコピーします。 目的のコードは次のようなコードです。<solutionId> 要素のみが異なります。

            <vstov4:customization>
              <vstov4:document
                solutionId="73e" />
            </vstov4:customization>
    
  6. ContosoInstaller.dll.manifest ファイルの <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素の後に、コードを貼り付けます。

  7. id 属性を <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素に追加して、このカスタマイズ部分と他の部分とを区別します。 この id は前の手順で <vstav3:entryPoints> 要素に追加した id と同じです。

            <vstov4:customization id="ContosoExcel">
    

ドキュメント レベルのプロジェクトの変更

複数プロジェクトの配置では、すべてのドキュメント レベルのプロジェクトに対し、_AssemblyLocation カスタム ドキュメント プロパティに id を追加する必要があります。 ここでは、ContosoExcelWorkbook.xlsx ファイルの _AssemblyLocation プロパティを更新する方法について説明します。すべてのドキュメント レベルのプロジェクトに対してこの手順を繰り返す必要があります。

Excel 2010 または Word 2010 で _AssemblyLocation を変更するには

  1. Excelでは、[ファイル] のタブをクリックします。

  2. [情報] のボタンをクリックします。

  3. [プロパティ] のドロップダウン矢印をクリックし、**[詳細プロパティ]**を選択します。

  4. [カスタム] のタブをクリックします。

  5. [プロパティ] のペインで、**[_AssemblyLocation]**を選択します。

  6. [値] テキスト ボックスに、|vstolocal (テキストがある場合は) を削除し、|id=ContosoInstallerを適用するテキストを編集します。

  7. [OK] を選択します。

マニフェストへの再署名

証明書を使用してアプリケーション マニフェストおよび配置マニフェストに署名します。 これにより、ファイルが改ざんされていないことを保証します。

アプリケーション マニフェストと配置マニフェストに再署名するには

  1. c: \publish\Application Files\ContosoInstaller_1_0_0_0 のディレクトリに %USERPROFILE%\Documents\Visual Studioの2012\Projects\ContosoInstaller\ContosoInstaller のソリューション ディレクトリから ContosoInstaller_TemporaryKey.pfx の証明書ファイルをコピーします。

  2. Visual Studio コマンド プロンプトを開きます。

  3. c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリに移動します。

  4. 次のコマンドを入力し、変更したアプリケーション マニフェストに署名します。

    mage -sign ContosoInstaller.dll.manifest -certfile ContosoInstaller_TemporaryKey.pfx
    

    "ContosoInstaller.dll.manifest 正常に署名されました" というメッセージが表示されます。

  5. c:\publish ディレクトリに移動します。

  6. 次のコマンドを入力し、配置マニフェストを更新して署名します。

    mage -update ContosoInstaller.vsto -appmanifest "Application Files\ContosoInstaller_1_0_0_0\ContosoInstaller.dll.manifest" -certfile "Application Files\ContosoInstaller_1_0_0_0\ContosoInstaller_TemporaryKey.pfx"
    

    "ContosoInstaller.vsto 正常に署名されました" というメッセージが表示されます。

  7. ContosoInstaller.vsto ファイルを c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリにコピーします。

複数プロジェクトの配置のテスト

次の手順を実行して、マニフェストにより Outlook アドインと Excel ブックがインストールされることを確認します。

複数プロジェクトの配置をテストするには

  1. c:\publish ディレクトリをテスト コンピューターにコピーします。

  2. セットアップ プログラムを実行して、複数プロジェクトの配置をインストールします。

    Microsoft Office カスタマイズ インストーラーが表示されます。

  3. **[インストール]**を選択します。

    [Microsoft Office カスタマイズ インストーラー] ダイアログ ボックスに、"Microsoft Office のカスタマイズは正常にインストールされました" というメッセージが表示されます。

  4. Outlook を開き、アドインが機能することを確認します。

  5. Excel ブック ファイルを開き、ドキュメント レベルのカスタマイズが機能することを確認します。

  6. インストールされたアプリケーションの一覧に、この複数プロジェクトの配置が 1 つのアプリケーションとして登録されていることを確認します。

    Windows XP の場合は [プログラムの追加と削除] に、Windows Vista の場合は [プログラムと機能]ContosoInstaller が表示されます。

publish ディレクトリのクリーンアップ

次の手順を実行して、publish ディレクトリから不要なファイルを削除します。

publish ディレクトリをクリーンアップするには

  1. c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリから、次のファイルを削除します。

    • ContosoExcelWorkbook.dll.manifest

    • ContosoExcelWorkbook.vsto

    • ContosoInstaller.dll.deploy

    • ContosoInstaller.docx

    • ContosoInstaller_TemporaryKey.pfx

    • ContosoOutlookAddIn.dll.manifest

    • ContosoOutlookAddIn.vsto

  2. c:\publish ディレクトリから次のファイルを削除します。

    • ContosoExcelWorkbook.vsto

    • ContosoInstaller.docx

    • ContosoOutlookAddIn.vsto

参照

処理手順

方法: アプリケーション マニフェストおよび配置マニフェストに再署名する

概念

ClickOnce アプリケーションのセキュリティ

その他の技術情報

Office ソリューションの配置