Share via


Targeting VS 2008 with the Visual Studio 2010 SDK

Recently, a customer asked us if it was possible to develop and debug a VB/C# extension with Visual Studio 2010 (and the 2010 SDK), but still have a binary that also works with VS 2008. This is indeed possible, but it requires some hacking of your project file to get it set up.

One nice thing about this solution is that you can easily switch between targeting 2008 and 2010 by simply changing the startup project between the package project and the VSIX project.

Setup machine with VS 2008 SP1 + VS2008 SDK 1.1 + VS2010 Beta 2 + VS2010 Beta 2 SDK

  1. In VS 2008 : create a VB or C# VSPackage

    • (optionally) Build/F5 to verify that it builds/loads as expected in 2008 Experimental Hive
    • Close VS 2008 Instances
  2. Launch VS 2010, open the solution, and proceed with project upgrade wizard

  3. Unload the VSPackage project, edit the project file, and add the following target after the Imports statements at the bottom:

    <Target Name="PkgdefProjectOutputGroup" Outputs="@(PkgdefOutputGroupOutput)">
      <RegPkg ItemToRegister="$(TargetPath)"
        ProductVersion="$(TargetVSVersion)"
        RegistrationRoot="$(__InternalTargetRoot)"
        SDKVersion="$(VsSDKVersion)"
        UseCodebase="true"
        OutputFile="$(IntermediateOutputPath)$(TargetName)_.pkgdef"
        Unregister="false"
        UseVS2005MPF="$(__InternalUseMPF80)" />     
      <ItemGroup> 
        <_PkgdefOutputGroupOutput Include="$(IntermediateOutputPath)$(TargetName)_.pkgdef" />
      </ItemGroup> 
      <ItemGroup> 
        <PkgdefOutputGroupOutput Include="@(_PkgdefOutputGroupOutput->'%(FullPath)')" />
      </ItemGroup> 
    </Target>

  4. Reload the VSPackage project

  5. Add a VSIX Project to the solution (From Visual C#\Extensibility or Visual Basic\Extensibility in the New Project Dialog)

    • Note: You do not have to distribute your package in a VSIX container. This is simply a requirement for registering and debugging in the VS 2010 Experimental Instance.
  6. Add a Project Reference from the VSIX Project to the VSPackage project

  7. Unload the VSIX project, edit the project file, and add the following inside the <ProjectReference> node:

    <IncludeOutputGroupsInVSIX>
      BuiltProjectOutputGroup;
      PkgdefProjectOutputGroup
    </IncludeOutputGroupsInVSIX> 
    <IncludeOutputGroupsInVSIXLocalOnly> 
      DebugSymbolsProjectOutputGroup
    </IncludeOutputGroupsInVSIXLocalOnly>

  8. Reload the VSIX Project

  9. Right-click the VSIX Project node and “Set as Startup Project” (if you wish to run/debug the package under VS2010)

  10. F5 to debug the package running in the VS2010 Experimental Instance with VS2010

Comments

  • Anonymous
    January 03, 2010
    The comment has been removed