Share via


How to: Build and Run the ShapeAppClickOnceCSharp Sample

The ShapeAppClickOnceCSharp sample extends the ShapeAppCSharp sample host application by adding support for ClickOnce deployment.

For more information, see Securing and Deploying Add-Ins.

The procedures in this topic show how to build and run the ShapeAppClickOnceCSharp sample. These tasks appear in the following order:

  1. Extract the ShapeAppClickOnceCSharp sample.

  2. Open the ShapeAppClickOnceCSharp sample in Visual Studio and build it.

  3. Register the ShapeAppClickOnceCSharp sample. Doing this lets you build and debug the sample add-ins, and use the project templates that are included with the ShapeAppClickOnceCSharp sample to create your own add-ins.

  4. Build the sample add-in.

  5. Create a test certificate to sign the application and deployment manifests.

  6. Create the application and deployment manifests.

  7. Install and load the add-in.

  8. (Optional) Unregister ShapeAppClickOnceCSharp. Doing this removes the registry entries that let you build and debug the sample add-in, and also removes the entries that let you use the project templates that are included with ShapeAppClickOnceCSharp.

To extract ShapeAppClickOnceCSharp

  1. Create a folder named ShapeAppSamples at the root of the Windows system drive (%SystemDrive%), and then create a subfolder named ShapeAppClickOnceCSharp. For example, if the system drive is C, the path would be C:\ShapeAppSamples\ShapeAppClickOnceCSharp.

    Note

    Although you can extract ShapeAppClickOnceCSharp to any folder, the following procedures assume that you extract it to the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp folder.

  2. Open the Visual Studio Tools for Applications samples folder.

    By default, the samples folder is located at %ProgramFiles%\Visual Studio Tools for Applications 2.0 SDK\build number\Visual Studio Tools for Applications\Samples on 32-bit versions of Windows, or at %ProgramFiles(x86)%\Visual Studio Tools for Applications 2.0 SDK\build number\Visual Studio Tools for Applications\Samples on 64-bit versions of Windows.

  3. Right-click the ShapeAppClickOnceCSharp.zip file, and then click Extract All.

    Note

    This step assumes that the system is set to open .zip files by using Compressed (zipped) Folders. If the system is set to open .zip files by using another program, follow the instructions of that program to extract the contents of ShapeAppClickOnceCSharp.zip.

  4. Follow the instructions in the Extract Compressed (Zipped) Folders wizard to extract the contents of ShapeAppClickOnceCSharp.zip to the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp folder.

To build ShapeAppClickOnceCSharp

  1. Start Visual Studio 2008. If you are using Windows Vista as the operating system, start Visual Studio 2008 by using the Run as Administrator option.

  2. On the File menu, point to Open, and then click Project/Solution.

  3. In the Open Project dialog box, locate the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp folder.

  4. Select the ShapeAppClickOnceCSharp.sln file, and then click Open.

  5. On the Build menu, click Build Solution. Verify that the solution builds without errors.

To register ShapeAppClickOnceCSharp

  1. Open a Command Prompt window. If you are using Windows Vista as the operating system, open a Command Prompt window by using the Run as Administrator option.

  2. Run the following command.

    cd "%SystemDrive%\ShapeAppSamples\ShapeAppClickOnceCSharp"
    

    Note

    If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that registers ShapeAppClickOnceCSharp can be run only in a 32-bit Command Prompt window.

  3. Type the following command to run the SetupShapeAppClickOnceCSharp.js script file. This script file registers ShapeAppClickOnceCSharp with Visual Studio Tools for Applications and configures the project templates so that they can be used in Visual Studio 2008.

    cscript SetupShapeAppClickOnce.js
    

    For more information about how to register host applications, see Registering the Host Application.

    Note

    Each version of the ShapeAppCSharp sample provides a setup script. All setup scripts write to the same location in the registry. Therefore, you can only use the setup script to register one version of the ShapeAppCSharp sample application at a time.

To build the sample add-in

  1. On the File menu, point to Open, and then click Project/Solution.

  2. In the Open Project dialog box, locate the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp\sample addIns\CSharp folder.

    Note

    The following instructions assume that you are building the Visual C# version of the add-ins. For Visual Basic versions of the add-ins, see the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp\sample addIns\VisualBasic folder.

  3. Select the ShapeAppCSharpAddIns.sln file, and then click Open.

  4. On the Build menu, click Build Solution. Verify that the solution builds without errors.

    When you build the solution, the add-in assemblies are automatically copied as follows:

    • (For Windows XP and Windows Server 2003) ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\My Documents\ShapeAppCSharp\AppAddIns\ShapeAppCSharpAppAddIn.

    • (For Windows Vista) ShapeAppCSharpAppAddIn.dll is copied to %UserProfile%\Documents\ShapeAppCSharp\AppAddIns\ShapeAppCSharpAppAddIn.

To create a certificate

  1. On the File menu, point to Open, and then click Project/Solution.

  2. In the Open Project dialog box, locate the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp folder.

  3. Select the ShapeAppClickOnceCSharp.sln file, and then click Open.

  4. On the Project menu, click ShapeAppClickOnceCSharp Properties.

  5. On the Signing tab, select Sign the ClickOnce manifests.

  6. Click Create Test Certificate.

  7. In the Create Test Certificate dialog box, type test in the Enter Password for new file ShapeAppClickOnceCSharp_TemporaryKey.pfx and Confirm your password boxes.

  8. Clear Sign the ClickOnce manifests.

  9. In the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp\core folder, copy ShapeAppClickOnceCSharp_TemporaryKey.pfx, and then paste it in the drive:\ShapeAppSamples\ShapeAppClickOnceCSharp\Sample AddIns\CSharp\AppLevel\Bin\Debug folder.

To create the ClickOnce application and deployment manifests for the add-in

  1. In Visual Studio 2008, open the Command Window. If you are using Windows Vista as the operating system, open the Command Window by using the Run as Administrator option.

  2. Run the following command.

    cd "%SystemDrive%\ShapeAppSamples\ShapeAppClickOnceCSharp\sample addIns\CSharp\Applevel\bin\debug"
    
  3. Run the following command to create an application manifest.

    mage -New Application -ToFile ShapeAppCSharpAppAddIn.dll.manifest -Name "Shape App CSharp Add-in with ClickOnce manifests" -Version "1.0.0.0" -FromDirectory .
    

    The ShapeAppCSharpAppAddIn.dll.manifest file is created.

  4. Open ShapeAppCSharpAppAddIn.dll.manifest in the Visual Studio XML editor.

  5. Add the following text to the end of the file but before the last </asmv1:assembly> element:

    <vstav2:addIn xmlns:vstav2="urn:schemas-microsoft-com:vsta.v2">
      <vstav2:entryPoints>
        <vstav2:entryPoint class="ShapeAppCSharpAppAddIn.AppAddIn">
                <assemblyIdentity 
                  name="ShapeAppCSharpAppAddIn" 
                  version="1.0.2897.25791" 
                  language="neutral" 
                  processorArchitecture="msil" />
                </vstav2:entryPoint>
      </vstav2:entryPoints>
      <vstav2:update enabled="true">
        <vstav2:expiration maximumAge="7" unit="days" />
      </vstav2:update>
    </vstav2:addIn>
    
  6. Save and close ShapeAppCSharpAppAddIn.manifest.

  7. In the Command Window, run the following command to sign the application manifest. Type your password for the certificate at the end of this command.

    mage -sign ShapeAppCSharpAppAddIn.dll.manifest -CertFile ShapeAppClickOnceCSharp_TemporaryKey.pfx -Password test
    
  8. Run the following command to create a deployment manifest.

    mage -New Deployment -ToFile ShapeAppCSharpAppAddIn.vsta -Name "Shape App CSharp Add-in with ClickOnce manifests" -Version "1.0.0.0" -AppManifest ShapeAppCSharpAppAddIn.dll.manifest
    
  9. Run the following command to sign the deployment manifest. Type your password for the certificate at the end of this command.

    mage -sign ShapeAppCSharpAppAddIn.vsta -CertFile ShapeAppClickOnceCSharp_TemporaryKey.pfx -Password test
    

To install and load the ClickOnce add-in

  1. In Visual Studio, on the Project menu, click ShapeAppClickOnceCSharp Properties.

  2. On the Debug tab, in the command-line arguments, type the following command.

    /clickonce:"C:\ShapeAppSamples\ShapeAppClickOnceCSharp\sample addIns\CSharp\Applevel\bin\debug\ShapeAppCSharpAppAddIn.vsta"
    
  3. Press F5.

    The ShapeApp application starts.

  4. Verify that ShapeApp displays two sets of messages. The first set of messages is displayed by the add-in that you installed and loaded by using ClickOnce. The second set of messages is displayed by the add-in that you created by building the ShapeAppCSharpAddIns solution.

  5. Exit ShapeApp.

To unregister ShapeAppClickOnceCSharp

  1. Open a Command Prompt window. If you are using Windows Vista as the operating system, open a Command Prompt window by using the Run as Administrator option.

  2. Run the following command.

    cd "%SystemDrive%\ShapeAppSamples\ShapeAppClickOnceCSharp"
    

    Note

    If your development computer has a 64-bit operating system, make sure that you open a 32-bit Command Prompt window. The script file that unregisters ShapeAppClickOnceCSharp can be run only in a 32-bit Command Prompt window.

  3. Type the following command to run the RemoveShapeAppCSharp.js script file. This script file removes registry entries that let you build and debug the sample add-in, and also removes entries that let you use the project templates that are included with ShapeAppClickOnceCSharp.

    cscript RemoveShapeAppCSharp.js
    

    Note

    This command might require several minutes to be completed.

See Also

Tasks

How to: Build and Run the ShapeAppCSharp Sample

How to: Build and Run the ShapeAppBasicCSharp Sample

How to: Build and Run the ShapeAppMacroRecordingCSharp Sample

How to: Build and Run the ShapeAppDynamicProgrammingModelCSharp Sample

How to: Build and Run the ShapeAppBasicMFC Sample

Walkthrough: Integrating Visual Studio Tools for Applications with ShapeApp

Concepts

ShapeApp Samples (Visual Studio Tools for Applications)