更新 : 2010 年 9 月
複数の Office ソリューションを 1 つのパッケージで配置することで、インストール プロセスと更新プロセスを簡素化できます。 このためには、発行後にアプリケーション マニフェストと配置マニフェストを変更して再署名して、インストールする必要があります。
対象: このトピックの情報は、Microsoft Office 2010 および 2007 Microsoft Office system のドキュメント レベルのプロジェクトおよびアプリケーション レベルのプロジェクトに適用されます。 詳細については、「Office アプリケーションおよびプロジェクト タイプ別の使用可能な機能」を参照してください。
このチュートリアルでは、次の作業について説明します。
配置する Office ソリューションを 2 つ作成し、インストーラー プロジェクトとしての Office ソリューションを 1 つ作成します。
インストーラー プロジェクトのアプリケーション マニフェストを、2 つの Office ソリューションをインストールするように変更します。
アプリケーション マニフェストと配置マニフェストに再署名します。
注意
お使いのマシンで、Visual Studio ユーザー インターフェイスの一部の要素の名前や場所が、次の手順とは異なる場合があります。 これらの要素は、使用している Visual Studio のエディションや独自の設定によって決まります。 詳細については、「Visual Studio の設定」を参照してください。
必須コンポーネント
このチュートリアルを実行するには、次のコンポーネントが必要です。
-
Microsoft Office 開発者ツールを含むエディションの Visual Studio 2010。 詳細については、「[Office ソリューションを開発できるようにコンピューターを構成する](bb398242\(v=vs.100\).md)」を参照してください。
Word 2007 または Word 2010
Outlook 2007 または Outlook 2010
Excel 2007 または Excel 2010
テスト コンピューター。
複数の Office ソリューションの作成
まず、3 つの Office プロジェクトを作成します。そのうちの 1 つは、インストーラーに使用します。 残りの 2 つは、エンド ユーザーのコンピューターに配置します。
新しい Word プロジェクト、Outlook プロジェクト、および Excel プロジェクトを作成および開発するには
.NET Framework 4 用の Word のドキュメント レベルのプロジェクトを作成します。 プロジェクトに「ContosoInstaller」という名前を付けて、%USERPROFILE%\Documents\Visual Studio 2010\Projects ディレクトリに保存します。
この ContosoInstaller プロジェクトは、インストーラーとして使用します。 詳細については、「方法: Visual Studio で Office プロジェクトを作成する」を参照してください。
ContosoInstaller ソリューションに、Outlook のアプリケーション レベルのプロジェクトを「ContosoOutlookAddIn」という名前を付けて追加し、コードをこの Outlook プロジェクトに追加します。
ContosoInstaller ソリューションに、Excel のドキュメント レベルのプロジェクトを「ContosoExcelWorkbook」という名前を付けて追加し、コードをこの Excel プロジェクトに追加します。
Office ソリューションの発行
発行ウィザードまたはプロジェクト デザイナーのプロジェクト ページを使用して、Office ソリューションを開発用コンピューターに発行します。
Word、プロジェクト、Outlook プロジェクト、および Excel プロジェクトを発行するには
ContosoInstaller プロジェクトを c:\publish フォルダーに発行します。 詳細については、「方法: ClickOnce を使用して Office ソリューションを配置する」を参照してください。
ContosoOutlookAddIn プロジェクトを c:\publish フォルダーに発行します。
ContosoExcelWorkbook プロジェクトを c:\publish フォルダーに発行します。
アプリケーション マニフェストの変更
Visual Studio の XML エディターを使用して、インストール依存関係、ファイル、エントリ ポイント、およびアセンブリをアプリケーション マニフェストに追加します。 アプリケーション マニフェストの内容は、製品に含まれる内容すべての一覧を記載した部品表に似ています。アプリケーション マニフェストには、すべての依存アセンブリと必要条件アセンブリのほか、アプリケーションに必要なファイルも記載されています。 Office ソリューションのアプリケーション マニフェストには、アプリケーション レベルのアドインおよびドキュメント レベルのカスタマイズ用に Office アプリケーションから読み込む必要のあるアセンブリの一覧も記載されています。
インストール依存関係の追加
ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリをインストールするようにアプリケーション マニフェストを変更して、ContosoInstaller アセンブリへの参照を削除します。
アプリケーション マニフェストにインストール依存関係を追加するには
c:\publish\Application Files フォルダーの ContosoOutlookAddIn_1_0_0_0 ディレクトリと ContosoExcelWorkbook_1_0_0_0 ディレクトリの内容を ContosoInstaller_1_0_0_0 ディレクトリに移動します。
ContosoInstaller.dll.manifest ファイル、ContosoOutlookAddIn.dll.manifest ファイル、および ContosoExcelWorkbook.dll.manifest ファイルを XML エディターで開きます。
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>
ContosoInstaller.dll.manifest ファイルの dependency セクションの最後に、ContosoOutlookAddIn.dll インストール依存関係を貼り付けます。
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>
ContosoInstaller.dll.manifest ファイルの dependency セクションの最後に、インストール依存関係を貼り付けます。
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 は削除しないでください。
エントリ ポイントの追加
ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリが <vstav3> 名前空間に読み込まれるように、アプリケーション マニフェストを変更します。
vstav3 名前空間のエントリ ポイントをアプリケーション マニフェストに追加するには
ContosoInstaller.dll.manifest ファイルから <vstav3:entryPointsCollection> 要素と </vstav3:entryPointsCollection> 要素の間のテキストを削除します。
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> セクションの最後のエントリ ポイントにする必要があります。
ContosoInstaller.dll.manifest ファイルの <vstav3:entryPointsCollection> 要素の後に、コードを貼り付けます。
id 属性を <vstav3:entryPoints> 要素に追加して、このエントリ ポイントと他のエントリ ポイントとを区別します。
<vstav3:entryPoints id="ContosoOutlook">
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>
ContosoInstaller.dll.manifest ファイルの <vstav3:entryPointsCollection> 要素の後に、コードを貼り付けます。
id 属性を <vstav3:entryPoints> 要素に追加して、このエントリ ポイントと他のエントリ ポイントとを区別します。
<vstav3:entryPoints id="ContosoExcel">
アセンブリの追加
ContosoOutlookAddin アセンブリと ContosoExcelWorkbook アセンブリが <vstov4> 名前空間に読み込まれるように、アプリケーション マニフェストを変更します。
アプリケーション マニフェストの vstov4 名前空間にアセンブリを追加するには
ContosoInstaller.dll.manifest ファイルから <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素と </vstov4:customizations> 要素の間のテキストを削除します。
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>
ContosoInstaller.dll.manifest ファイルの <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素の後に、コードを貼り付けます。
id 属性を <vstav3:customization> 要素に追加して、このカスタマイズ部分と他の部分とを区別します。 この id は前の手順で <vstav3:entryPoints> 要素に追加した id と同じです。
<vstov4:customization id="ContosoOutlook">
ContosoExcelWorkbook.dll.manifest ファイルから <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素と </vstov4:customizations> 要素の間のテキストをコピーします。 目的のコードは次のようなコードです。<solutionId> 要素のみが異なります。
<vstov4:customization> <vstov4:document solutionId="73e" /> </vstov4:customization>
ContosoInstaller.dll.manifest ファイルの <vstov4:customizations xmlns:vstov4="urn:schemas-microsoft-com:vsto.v4"> 要素の後に、コードを貼り付けます。
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 を変更するには
Excel で、[ファイル] タブをクリックします。
[情報] をクリックします。
[プロパティ] のドロップダウン矢印をクリックし、[詳細プロパティ] をクリックします。
[カスタム] タブをクリックします。
プロパティ ペインで、[_AssemblyLocation] をクリックします。
[値] ボックスで、テキストを編集して、|vstolocal を削除し (テキストが存在する場合)、|id=ContosoInstaller を追加します。
[OK] をクリックします。
Excel 2007 または Word 2007 で _AssemblyLocation を変更するには
Excel で、Microsoft Office ボタンをクリックします。
[配布準備] をポイントし、[プロパティ] をクリックします。
[ドキュメントのプロパティ] のドロップダウン矢印をクリックし、[詳細プロパティ] をクリックします。
[カスタム] タブをクリックします。
プロパティ ペインで、[_AssemblyLocation] をクリックします。
[値] ボックスで、テキストを編集して、|vstolocal を削除し (テキストが存在する場合)、|id=ContosoInstaller を追加します。
[OK] をクリックします。
マニフェストへの再署名
証明書を使用してアプリケーション マニフェストおよび配置マニフェストに署名します。 これにより、ファイルが改ざんされていないことを保証します。
アプリケーション マニフェストと配置マニフェストに再署名するには
ContosoInstaller_TemporaryKey.pfx 証明書ファイルを %USERPROFILE%\Documents\Visual Studio 2010\Projects\ContosoInstaller\ContosoInstaller ソリューション ディレクトリから c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリにコピーします。
Visual Studio コマンド プロンプトを開きます。
c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリに移動します。
次のコマンドを入力し、変更したアプリケーション マニフェストに署名します。
mage -sign ContosoInstaller.dll.manifest -certfile ContosoInstaller_TemporaryKey.pfx
"ContosoInstaller.dll.manifest 正常に署名されました" というメッセージが表示されます。
c:\publish ディレクトリに移動します。
次のコマンドを入力し、配置マニフェストを更新して署名します。
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 正常に署名されました" というメッセージが表示されます。
ContosoInstaller.vsto ファイルを c:\publish\Application Files\ContosoInstaller_1_0_0_0 ディレクトリにコピーします。
複数プロジェクトの配置のテスト
次の手順を実行して、マニフェストにより Outlook アドインと Excel ブックがインストールされることを確認します。
複数プロジェクトの配置をテストするには
c:\publish ディレクトリをテスト コンピューターにコピーします。
セットアップ プログラムを実行して、複数プロジェクトの配置をインストールします。
Microsoft Office カスタマイズ インストーラーが表示されます。
[インストール] をクリックします。
[Microsoft Office カスタマイズ インストーラー] ダイアログ ボックスに、"Microsoft Office のカスタマイズは正常にインストールされました" というメッセージが表示されます。
Outlook を開き、アドインが機能することを確認します。
Excel ブック ファイルを開き、ドキュメント レベルのカスタマイズが機能することを確認します。
インストールされたアプリケーションの一覧に、この複数プロジェクトの配置が 1 つのアプリケーションとして登録されていることを確認します。
Windows XP の場合は [プログラムの追加と削除] に、Windows Vista の場合は [プログラムと機能] に ContosoInstaller が表示されます。
publish ディレクトリのクリーンアップ
次の手順を実行して、publish ディレクトリから不要なファイルを削除します。
publish ディレクトリをクリーンアップするには
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
c:\publish ディレクトリから次のファイルを削除します。
ContosoExcelWorkbook.vsto
ContosoInstaller.docx
ContosoOutlookAddIn.vsto
参照
処理手順
方法: アプリケーション マニフェストおよび配置マニフェストに再署名する
概念
履歴の変更
日付 |
履歴 |
理由 |
---|---|---|
2010 年 9 月 |
%USERPROFILE%\Documents\Visual Studio 10\Projects を %USERPROFILE%\Documents\Visual Studio 2010\Projects に変更しました。 |
コンテンツ バグ修正 |