翻訳への提案を行います
 
他のユーザーによる提案:

progress indicator
他の提案はありません。
 印刷用ページ       送信     
クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
Visual Studio 2010 Beta 2
Visual Studio
Visual Studio で Office 開発
 チュートリアル: ClickOnce インストール後にエンド ユーザー...
すべて縮小/すべて展開 すべて縮小
コンテンツの表示:   英語と日本語を並べて表示コンテンツの表示: 英語と日本語を並べて表示
このページは、ベータ版用に機械翻訳されたものです。翻訳者による翻訳は、製品の正規版で提供される予定です。詳細についてはよくある質問 を参照してください。またぜひこちら からアンケートにもご協力ください。
Walkthrough: Copying a Document to the End User Computer after a ClickOnce Installation

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Applies to

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • 2007 Microsoft Office system

  • Microsoft Office "14"

Using a ClickOnce post-deployment action, you can install document-level Office solutions, and then copy the document to the end user computer. This requires that you modify the application manifest, and re-sign both the application and the deployment manifests before installation.

This walkthrough illustrates the following tasks:

  • Creating an Office solution to deploy.

  • Implementing a post-deployment action that copies a document to the end user's desktop.

  • Modifying the application manifest of the Office solution to run the post-deployment action.

  • Re-signing the application and deployment manifests.

Note Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Working with Settings.

You need the following components to complete this walkthrough:

  •  

  • Excel 2007 or Excel “14”.

  • A test computer.

First, create an Excel workbook project.

To create a new Excel project

  • Create an Excel document-level project for the .NET Framework 3.5. Name the project ExcelWorkbook, and save the project to the %USERPROFILE%\Documents\Visual Studio 10\Projects directory. For more information, see How to: Create Office Projects in Visual Studio.

    Visual Studio opens the new Excel workbook in the designer and adds the ExcelWorkbook project to SolutionExplorer.

You must define the post-deployment action in a separate class library. The post-deployment action performs copies the document to the end user computer.

To create a class library for the post-deployment action

  1. In the File menu, point to Add, and then click New Project.

  2. In the Add New Project dialog box, in the Installed Templates pane, click Windows.

  3. In the Templates pane, click ClassLibrary.

  4. Ensure that .NET Framework 3.5 remains selected as the target framework.

  5. In the Name field, type FileCopyPDA, and then click OK.

  6. In SolutionExplorer, click FileCopyPDA.

  7. On the Project menu, click AddReference.

  8. In the AddReference dialog box, in the .NET tab, click Microsoft.VisualStudio.Tools.Applications.Runtime and Microsoft.VisualStudio.ToolsApplications.ServerDocument, and then click OK.

  9. In the Class1 code file, add the following using or Imports statements to the top of the code file.

    Visual Basic
                                  Imports Microsoft.VisualStudio.Tools.Applications.Deployment
    Imports Microsoft.VisualStudio.Tools.Applications
    
    C#
                                  using Microsoft.VisualStudio.Tools.Applications.Deployment;
    using Microsoft.VisualStudio.Tools.Applications;
    using System.IO;
    
  10. Rename the class to FileCopyPDA, and then add the following code to the FileCopyPDA class. This code indicates that FileCopyPDA class inherits from IAddInPostDeploymentAction.

    Visual Basic
                                  Public
                                  Class FileCopyPDA
        Implements IAddInPostDeploymentAction
    
    C#
                                  public
                                  class FileCopyPDA : IAddInPostDeploymentAction
    
  11. Add the following code to implement the IAddInPostDeploymentAction.Execute method. This code performs the following tasks:

    • Copies the Excel workbook file to the user's desktop if the solution is installed or updated.

    • Changes the _AssemblyLocation property from a relative path to a fully qualified path for the deployment manifest. This is done using the AddCustomization and RemoveCustomization methods.

    • Deletes the file if the solution is uninstalled.

    Visual Basic
                                  Sub Execute(ByVal args As AddInPostDeploymentActionArgs) Implements IAddInPostDeploymentAction.Execute
        Dim dataDirectory AsString = "Data\ExcelWorkbook.xlsx"Dim file AsString = "ExcelWorkbook.xlsx"Dim sourcePath AsString = args.AddInPath
        Dim deploymentManifestUri As Uri = args.ManifestLocation
        Dim destPath AsString = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
        Dim sourceFile AsString = System.IO.Path.Combine(sourcePath, dataDirectory)
        Dim destFile AsString = System.IO.Path.Combine(destPath, file)
    
        SelectCase args.InstallationStatus
            Case AddInInstallationStatus.InitialInstall, AddInInstallationStatus.Update
                File.Copy(sourceFile, destFile)
                ServerDocument.RemoveCustomization(destFile)
                ServerDocument.AddCustomization(destFile, deploymentManifestUri)
                ExitSelectCase AddInInstallationStatus.Uninstall
                If File.Exists(destFile) Then
                    File.Delete(destFile)
                EndIfExitSelectEndSelectEndSub
    C#
                                  public
                                  void Execute(AddInPostDeploymentActionArgs args) 
    {
        string dataDirectory = @"Data\ExcelWorkbook.xlsx";
        string file = @"ExcelWorkbook.xlsx";
        string sourcePath = args.AddInPath;
        Uri deploymentManifestUri = args.ManifestLocation;
        string destPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
        string sourceFile = System.IO.Path.Combine(sourcePath, dataDirectory);
        string destFile = System.IO.Path.Combine(destPath, file);
    
        switch (args.InstallationStatus)
        {
            case AddInInstallationStatus.InitialInstall:
            case AddInInstallationStatus.Update:
                File.Copy(sourceFile, destFile);
                ServerDocument.RemoveCustomization(destFile);
                ServerDocument.AddCustomization(destFile, deploymentManifestUri);
                break;
            case AddInInstallationStatus.Uninstall:
                if (File.Exists(destFile))
                {
                    File.Delete(destFile);
                }
                break;
        }
    }
    

Use the Publish Wizard or the Project Page to build and publish the Office solutions to your development computer.

To publish the Excel project

  1. In SolutionExplorer, right-click the FileCopyPDA project, and then click Build.

  2. In SolutionExplorer, right-click the ExcelWorkbook project, and then click Build.

  3. In SolutionExplorer, right-click the ExcelWorkbook project, and then click Add Reference.

  4. In the Add Reference dialog box, click the Projects tab.

  5. Click FileCopyPDA, and click OK.

  6. In Solution Explorer, click the ExcelWorkbook project.

  7. On the Project menu, click New Folder.

  8. Type Data and press the Enter key.

  9. In Solution Explorer, click the Data folder.

  10. On the Project menu, click Add Existing Item.

  11. In the Add Existing Item dialog box, browse to the output directory for the ExcelWorkbook project.

  12. Click ExcelWorkbook.xlsx, and click Add.

  13. In SolutionExplorer, click ExcelWorkbook.xlsx.

  14. In the Properties window, change the Build Action property to Content, and the Copy to Output Directory property to Copyif newer.

  15. Publish the ExcelWorkbook project to the c:\publish folder. For more information, see How to: Deploy an Office Solution by Using ClickOnce.

Use the XML editor in Visual Studio to modify the application manifest to run the File Copy post-deployment action.

To add the installation dependencies to the application manifest

  1. Open the c:\publish directory through Windows Explorer.

  2. Open the Application Files folder and then open the ExcelWorkbook_1_0_0_0 folder.

  3. Open the ExcelWorkbook.dll.manifest file in a text editor.

  4. Add following code after the </vstav3:update> element. For the class attribute of the <vstav3:entryPoint> element, use the following syntax: NamespaceName.ClassName. In this example, the namespace and class names are the same, so that the resulting entry point name is FileCopyPDA.FileCopyPDA.

    <vstav3:postActions>
      <vstav3:postAction>
        <vstav3:entryPoint
          class="FileCopyPDA.FileCopyPDA">
          <assemblyIdentity
            name="FileCopyPDA"
            version="1.0.0.0"
            language="neutral"
            processorArchitecture="msil" />
        </vstav3:entryPoint>
        <vstav3:postActionData>
        </vstav3:postActionData>
      </vstav3:postAction>
    </vstav3:postActions>
    

The following procedure signs the application manifest and updates the deployment manifest. This ensures that tampered files are not installed on end user computers.

To re-sign the application and deployment manifests

  1. Copy the ExcelWorkbook_TemporaryKey.pfx certificate file from the %USERPROFILE%\Documents\Visual Studio 10\Projects\ExcelWorkbook\ExcelWorkbook solution directory into the c:\publish\Application Files\ExcelWorkbook_1_0_0_0 directory.

  2. Open the Visual Studio command prompt.

  3. Change to the c:\publish\Application Files\ExcelWorkbook_1_0_0_0 directory.

  4. Sign the modified application manifest with the following command:

    mage -sign ExcelWorkbook.dll.manifest -certfile ExcelWorkbook_TemporaryKey.pfx
    

    The message "ExcelWorkbook.dll.manifest successfully signed" appears.

  5. Change to the c:\publish directory.

  6. Update and sign the deployment manifest with the following command:

    mage -update ExcelWorkbook.vsto -appmanifest "Application Files\Ex
    celWorkbook_1_0_0_0\ExcelWorkbook.dll.manifest" -certfile "Application Files\ExcelWorkbook_1_0_0_0\ExcelWorkbook_TemporaryKey.pfx"
    

    The message "ExcelWorkbook.vsto successfully signed" appears.

  7. Copy the ExcelWorkbook.vsto file to the c:\publish\Application Files\ExcelWorkbook_1_0_0_0 directory.

The following procedure ensures that the updated manifest installs the Excel workbook and copies the workbook to the end user's desktop.

To test the post-deployment action

  1. Copy the c:\publish directory to a test computer.

  2. Run the Setup.exe program, or if the prerequisites are already installed on the test computer, double-click the ExcelWorkbook.vsto deployment manifest.

    The Microsoft Office Customization Installer appears.

  3. Click Install.

    The Microsoft Office Customization Installer dialog box shows the following message: "The Microsoft Office customization was successfully installed." The Excel workbook is copied to the end user's desktop.

  4. Open the ExcelWorkbook.xlsx file from the desktop.

Visual Studio 2010
チュートリアル: ClickOnce インストール後にエンド ユーザーのコンピューターにドキュメントをコピーする

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

対象

プロジェクトの種類

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

  • アプリケーション レベルのプロジェクト

Microsoft Office のバージョン

  • 2007 Microsoft Office System

  • Microsoft Office "14"

ClickOnce 配置後のアクションを使用して、ドキュメント レベル Office ソリューションをインストールでき、エンドユーザーのコンピューターにドキュメントをコピーしできます。 これは、ため、アプリケーション マニフェストを変更し、アプリケーションとインストールの前に、配置マニフェストの両方再署名いる必要があります。

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

  • 展開する Office ソリューションを作成します。

  • エンドユーザーのデスクトップに、ドキュメントをコピーする展開後のアクションを実装します。

  • 展開後の操作を実行する Office ソリューションのアプリケーション マニフェストの変更。

  • マニフェスト、アプリケーションと展開を再署名します。

メモ メモ

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

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

  •  

  • Excel 2007 または Excel "14" します。

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

Excel ブック プロジェクトを最初に、作成します。

新しい Excel プロジェクトを作成するには

  • .NET Framework 3. 5 の Excel ドキュメント レベル プロジェクトを作成します。 プロジェクト を ExcelWorkbook を名前をプロジェクトを付けて保存 %USERPROFILE%\Documents\Visual Studio 10\Projects ディレクトリにします。 詳細については、「方法 : Visual Studio で Office プロジェクトを作成します。」を参照してください。

    Visual Studio opens the new Excel workbook in the designer and adds the ExcelWorkbook project to SolutionExplorer.

定義、展開後の動作する必要があります別のクラス ライブラリ。 展開後のアクションは、コピーを実行する、ドキュメント、エンドユーザーのコンピューターをします。

展開後の動作のクラス ライブラリを作成するには

  1. [で を追加、]、[新しいプロジェクト をクリックします。

  2. 新しいプロジェクトの追加 ダイアログ、 にインストールされたテンプレート ペインでボックス Windows 。

  3. In the Templates pane, click ClassLibrary.

  4. .NET Framework 3. 5 その は、ターゲット フレームワークとして選択したままを確認します。

  5. フィールドで FileCopyPDA を入力して、[OK] の をクリックします。

  6. In SolutionExplorer, click FileCopyPDA.

  7. On the Project menu, click AddReference.

  8. In the AddReference dialog box, in the .NET tab, click Microsoft.VisualStudio.Tools.Applications.Runtime and Microsoft.VisualStudio.ToolsApplications.ServerDocument, and then click OK.

  9. または ステートメントをインポート コード ファイルの先頭を使用して、次 クラス 1 のコード ファイルを追加します。

    Visual Basic
                                  Imports Microsoft.VisualStudio.Tools.Applications.Deployment
    Imports Microsoft.VisualStudio.Tools.Applications
    
    C#
                                  using Microsoft.VisualStudio.Tools.Applications.Deployment;
    using Microsoft.VisualStudio.Tools.Applications;
    using System.IO;
    
  10. FileCopyPDAに、クラスを変更クリックして追加次のコードを FileCopyPDA クラスにします。 このコードから FileCopyPDAIAddInPostDeploymentAction クラスを継承することを示します。

    Visual Basic
                                  Public
                                  Class FileCopyPDA
        Implements IAddInPostDeploymentAction
    
    C#
                                  public
                                  class FileCopyPDA : IAddInPostDeploymentAction
    
  11. IAddInPostDeploymentAction.Execute メソッドを実装する次のコード追加します。 このコードは次のタスクを実行します。

    • Excel ブック ファイルをユーザーのデスクトップにコピー、ソリューションがインストールまたは更新します。

    • _AssemblyLocation プロパティを相対パスから、配置マニフェストの完全修飾パスに変更します。 これは、AddCustomization および RemoveCustomization メソッドを使用します。

    • 場合は、ソリューションがアンインストール ファイルを削除します。

    Visual Basic
                                  Sub Execute(ByVal args As AddInPostDeploymentActionArgs) Implements IAddInPostDeploymentAction.Execute
        Dim dataDirectory AsString = "Data\ExcelWorkbook.xlsx"Dim file AsString = "ExcelWorkbook.xlsx"Dim sourcePath AsString = args.AddInPath
        Dim deploymentManifestUri As Uri = args.ManifestLocation
        Dim destPath AsString = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
        Dim sourceFile AsString = System.IO.Path.Combine(sourcePath, dataDirectory)
        Dim destFile AsString = System.IO.Path.Combine(destPath, file)
    
        SelectCase args.InstallationStatus
            Case AddInInstallationStatus.InitialInstall, AddInInstallationStatus.Update
                File.Copy(sourceFile, destFile)
                ServerDocument.RemoveCustomization(destFile)
                ServerDocument.AddCustomization(destFile, deploymentManifestUri)
                ExitSelectCase AddInInstallationStatus.Uninstall
                If File.Exists(destFile) Then
                    File.Delete(destFile)
                EndIfExitSelectEndSelectEndSub
    C#
                                  public
                                  void Execute(AddInPostDeploymentActionArgs args) 
    {
        string dataDirectory = @"Data\ExcelWorkbook.xlsx";
        string file = @"ExcelWorkbook.xlsx";
        string sourcePath = args.AddInPath;
        Uri deploymentManifestUri = args.ManifestLocation;
        string destPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
        string sourceFile = System.IO.Path.Combine(sourcePath, dataDirectory);
        string destFile = System.IO.Path.Combine(destPath, file);
    
        switch (args.InstallationStatus)
        {
            case AddInInstallationStatus.InitialInstall:
            case AddInInstallationStatus.Update:
                File.Copy(sourceFile, destFile);
                ServerDocument.RemoveCustomization(destFile);
                ServerDocument.AddCustomization(destFile, deploymentManifestUri);
                break;
            case AddInInstallationStatus.Uninstall:
                if (File.Exists(destFile))
                {
                    File.Delete(destFile);
                }
                break;
        }
    }
    

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

Excel プロジェクトを発行するには

  1. In SolutionExplorer, right-click the FileCopyPDA project, and then click Build.

  2. In SolutionExplorer, right-click the ExcelWorkbook project, and then click Build.

  3. In SolutionExplorer, right-click the ExcelWorkbook project, and then click Add Reference.

  4. [参照の追加] ダイアログ ボックスの [プロジェクト] タブをクリックします。

  5. を FileCopyPDA をクリックし、[OK] の をクリックします。

  6. のソリューション エクスプローラー] で ExcelWorkbook プロジェクトをクリックします。

  7. [プロジェクト] メニューの の新しいフォルダー] をクリックします。

  8. のデータを入力し、 を入力してください キーを押します。

  9. のソリューション エクスプローラー] で データ フォルダーをクリックします。

  10. [プロジェクト] メニューの の [既存項目の追加] をクリックします。

  11. 既存項目の追加 ダイアログ ボックスで ExcelWorkbook プロジェクトの出力ディレクトリに参照します。

  12. を ExcelWorkbook.xlsx をクリックし、 の追加をクリックします。

  13. In SolutionExplorer, click ExcelWorkbook.xlsx.

  14. In the Properties window, change the Build Action property to Content, and the Copy to Output Directory property to Copyif newer.

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

Visual Studio の XML エディターを使用して、ファイル コピーの展開後アクションを実行するアプリケーション マニフェストを変更します。

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

  1. Windows エクスプローラーを通じて c:\publish ディレクトリを開きます。

  2. アプリケーション ファイル フォルダーを開き、 ExcelWorkbook_1_0_0_0 フォルダーを開きます。

  3. テキスト エディターで ExcelWorkbook.dll.manifest ファイルを開きます。

  4. </vstav3:update> 要素の後、次のコード追加します。 <vstav3:entryPoint> 要素のクラス属性に関して次の構文を使用します。 NamespaceName.ClassName. この例では、名前空間とクラスの名前は同じ、結果のエントリ ポイント名が FileCopyPDA.FileCopyPDA ようにです。

    <vstav3:postActions>
      <vstav3:postAction>
        <vstav3:entryPoint
          class="FileCopyPDA.FileCopyPDA">
          <assemblyIdentity
            name="FileCopyPDA"
            version="1.0.0.0"
            language="neutral"
            processorArchitecture="msil" />
        </vstav3:entryPoint>
        <vstav3:postActionData>
        </vstav3:postActionData>
      </vstav3:postAction>
    </vstav3:postActions>
    

次のプロシージャ、アプリケーション マニフェストに署名し、配置マニフェストを更新します。 これにより、tampered ファイルがエンドユーザーのコンピューターにインストールされていないこと。

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

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

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

  3. c:\publish\Application Files\ExcelWorkbook_1_0_0_0 ディレクトリに変更します。

  4. 次のコマンドを使って、変更されたアプリケーション マニフェストを署名します。

    mage -sign ExcelWorkbook.dll.manifest -certfile ExcelWorkbook_TemporaryKey.pfx
    

    メッセージ"ExcelWorkbook.dll.manifest しました"表示されます。

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

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

    mage -update ExcelWorkbook.vsto -appmanifest "Application Files\Ex
    celWorkbook_1_0_0_0\ExcelWorkbook.dll.manifest" -certfile "Application Files\ExcelWorkbook_1_0_0_0\ExcelWorkbook_TemporaryKey.pfx"
    

    メッセージ"ExcelWorkbook.vsto しました"表示されます。

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

次の手順により、更新されたマニフェスト、ブックをインストールされエンド ユーザーのデスクトップに、ブックをコピーします。

展開後の操作をテストするには

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

  2. Setup.exe プログラムを実行するか、ExcelWorkbook.vsto 配置マニフェストをダブルクリック、前提条件が既にテスト コンピューターにインストールされている場合、します。

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

  3. [インストール] をクリックします。

    Microsoft Office のカスタマイズのインストーラー ダイアログ ボックスに次のメッセージが表示されます。"Microsoft Office のカスタマイズが正常にインストールします。Excel ブックがエンドユーザーのデスクトップにコピーされます。

  4. デスクトップから ExcelWorkbook.xlsx ファイルを開きます。

© 2009 Microsoft Corporation. All rights reserved. 使用条件 | 商標 | プライバシー
Page view tracker