Share via


Upgrading VS 2005 Packages to VS 2008: A Basic Guide

Today, I heard several developers in the community experiecncing some trouble upgrading the VS 2005 package projects to VS 2008. So I took a look at what's going on and decided to blog about it here.

Note that I am blogging about all the things that you need to do to migrate a very basic package project. If you use things like ProjectAggregator2, there will be additional steps involved. You can see Quan's blog entry here which discusses more about that issue.

There are several things you need to be aware of when you are porting a VS 2005 package to VS 2008. This blog post will guide you through the process, step-by-step.

If you like things in bullet points and less step-by-step, here is a summary of steps you need to take to upgrade your VS Package project from VS 2005 to VS 2008.

  1. Update build targets in project file
  2. Remove <TargetRegistryRoot> element
  3. Add Shell 9.0 references
  4. Update project debug properties.

Note on version compatibilities

Sometimes I get asked whether the VS 2008 SDK works for developing VS 2005 packages. The answer is probably. While theoretically, it should work, I would advise you against it. The reason is that we didn't do a lot of testing for VS 2008 SDK targeting VS 2005, and you are much better off sticking to using VS 2005 SDK for creating VS 2005 extensions and using VS 2008 SDK for creating VS 2008 extensions. Clean. Simple.

Steps to Upgrading to VS 2008

Step 1. The first thing you want to do is to make a copy of your VS 2005 Project file. For the purpose of this blog, I have just created a default VS Package project called VSPackage1. Go ahead, make a copy of it.

Step 2. Then, on machine where you have both VS 2008 and VS 2008 SDK installed, use VS 2008 to open up the package's solution. The VS Conversion Wizard will ask you to upgrade.

ProjectConversion

Click Next and decide whether you want a backup or not. I would suggest you do that. Then click Next and then Finish. Depending on whether you have VS 2005 SDK installed on that machine, the conversion may or may not fail. If the conversion, you will see an error message like the following:

ConversionError

Either way, you should proceed with the same steps below.

Step 3. Unload the project file if it is not already unloaded. Right-click and choose "Edit VSPackage1.csproj". Update the build targets by

Comment out the following line:

<!--<Import Project="C:\Program Files\Visual Studio 2005 SDK\2007.02\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" />-->

Add the following in its place:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\VSSDK\Microsoft.VsSDK.targets" />

Step 4. Update the target registry root by commenting out the following:

<!--<TargetRegistryRoot>Software\Microsoft\VisualStudio\8.0Exp</TargetRegistryRoot>-->

We will automatically pick the right target registry root for you.

Step 5. Add Shell 9.0 references by commenting out the following:

<!--<Reference Include="Microsoft.VisualStudio.Shell" />-->

And then adding the following snippet in its place.

<Reference Include="Microsoft.VisualStudio.Shell.9.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />

This is needed because the VS 2008 SDK determines whether your project needs to create a .pkgdef file at build time depending on whether you have include this reference in your project. .pkgdef files are automatically produced when you build your package in VS 2008. They contain similar information as what regpkg.exe produced for you before for package registration. In fact, we have updated regpkg.exe so that it supports outputting .pkgdef files. Anyway, we can talk more about what .pkgdef file is in another post. But for now, just include these references. If you don't add this reference into your project file, you will get the following error when you try to build your project.

NoRegError

When you reload your project, the VS Conversion Wizard will show up again. This time, your conversion should be successful.

Step 6. Update the Debugging properties of the project. You can do this by right-clicking the project file and choose Properties.

Click on the Debug tab and update the Start external program field to point to VS 2008 instead of VS 2005. Then add " /RANU" to the command line arguments.

ProjectProperties

Congratulations! Now, you should be able to hit F5 and run your package in VS 2008!

Common Question: Why is there no 9.0Exp hive under HKEY_LOCAL_MACHINE?

In VS 2008 SDK, we have enabled package development for normal users. What that means is that you don't need to be an administrator to develop and test VS packages. That also means you don't need to elevate to admin privilege for your instance of VS if you are running Vista.

We accomplished that by detouring all the calls to read/write from the normal VS registry hive under HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER. So with the VS 2008 SDK, you won't find an experimental hive under HKEY_LOCAL_MACHINE. Instead, it's created under your own current user hive.

There are 2 caveats I have:

1. If you are doing VS Shell isolated mode development, you should still run VS as admin for now. There is a bug in VS Shell isolated mode development scenarios in which the detouring does not work properly, so you should run VS as admin for now if you are creating your own shell-based application.

2. You will need to manually create the Exp hive under current user if another user who did not install the SDK logs onto the machine. During setup, the Exp hive is only created for the user running the setup. If a new user logs into the machine, that hive won't be there. You can easily do this by running "Reset the Microsoft Visual Studio 2008 Experimental hive" under Start > All Programs > Microsoft Visual Studio 2008 SDK > Tools.

 

That's it for now. I hope you find this post useful in helping you upgrade to VS 2008!

thanks,
James

Comments

  • Anonymous
    January 21, 2008
    That is really useful information. I have shared the link to this post at VSX Forum: http://forums.microsoft.com/msdn/showpost.aspx?postid=2720838 Thank you, Dmitry Pavlov

  • Anonymous
    January 22, 2008
    James has a great post about updating a project that was building with the Visual Studio 2005 SDK to

  • Anonymous
    January 22, 2008
    James has a great post about updating a project that was building with the Visual Studio 2005 SDK to

  • Anonymous
    February 04, 2008
    My VsPackage inherits Microsoft.TeamFoundation.Common.PluginHostPackage, which, in turn, inherits Microsoft.VisualStudio.Shell.Package. The Microsoft.VisualStudio.Shell.Package however seems to be only available in Microsoft.VisualStudio.Shell.dll. But in your guide, you said that we must comment out the reference to Microsoft.VisualStudio.Shell, and replace it with Microsoft.VisualStudio.Shell.9.0. After we comment out reference to Microsoft.VisualStudio.Shell, the compiler complains that we are missing a reference to the Microsoft.VisualStudio.Shell, and the build fails. You can easily verify what I said by using the VS2008 package creation wizard to create a VsPackage, and manually modify it to let it inherit PluginHostPackage. I would appreciate it very much if you could shed some light in this issue. Thanks Jason

  • Anonymous
    February 12, 2008
    Since I made the last blog post on upgrading , I have received some good feedback that it was useful

  • Anonymous
    February 12, 2008
    Hey Jason, please see my most recent post at http://blogs.msdn.com/jameslau/archive/2008/02/13/upgrading-vs-2005-packages-to-vs-2008-a-more-advanced-guide.aspx. I hope you will find it helpful. Thanks! James

  • Anonymous
    February 20, 2008
    If you like to read the MSDN Forums like I do, you’ve probably seen quite a few questions about how to