Freigeben über


Migrating a Legacy Language Service

You can migrate a Visual Studio 2008 language service to a later version by updating the project and adding a source.extension.vsixmanifest file to the project. The language service itself will continue to function as before, because the Visual Studio editor adapts it.

Note

We recommend that you begin to use the new editor API as soon as possible. This will improve the performance of your language service and let you take advantage of new editor features.

Migrating a Visual Studio 2008 Language Service Solution to a Later Version

The following steps show how to adapt a Visual Studio 2008 sample named RegExLanguageService. You can find this sample in a Visual Studio 2008 SDK installation, in the Visual Studio SDK installation path\VisualStudioIntegration\Samples\IDE\CSharp\Example.RegExLanguageService\ folder.

Important

If your language service does not define colors, you must explicitly set RequestStockColors to true on the VSPackage:

[Microsoft.VisualStudio.Shell.ProvideLanguageService(typeof(YourLanguageService), YourLanguageServiceName, 0, RequestStockColors = true)]

To migrate a Visual Studio 2008 language service to a later version

  1. Install Visual Studio 2012 and the Visual Studio 2012 SDK.

  2. Edit the RegExLangServ.csproj file (without loading it in Visual Studio.

    In the Import node that refers to the Microsoft.VsSDK.targets file, replace the value with the following text.

    $(MSBuildExtensionsPath)\Microsoft\VisualStudio\v11.0\VSSDK\Microsoft.VsSDK.targets
    
  3. Save the file, and then close it.

  4. Open the RegExLangServ.sln solution.

  5. The Visual Studio Conversion Wizard is displayed. Click Finish.

    You will see a Project Target Framework Not Installed dialog box asking you to retarget the project. Select the Retarget the project to .NET Framework 4 option.

  6. When the conversion is finished, click Close to load the solution.

  7. Update the project properties:

    • On the Debug tab, in the Start external program box, type <Visual Studio installation path>\Common7\IDE\devenv.exe /rootsuffix Exp.
  8. Update the following references:

    • Remove the reference to Microsoft.VisualStudio.Shell.9.0.dll, then add references to Microsoft.VisualStudio.Shell.11.0.dll and Microsoft.VisualStudio.Shell.Immutable.11.0.dll.

    • Remove the reference to Microsoft.VisualStudio.Package.LanguageService.9.0.dll, then add a reference to Microsoft.VisualStudio.Package.LanguageService.11.0.dll.

    • Add a reference to Microsoft.VisualStudio.Shell.Interop.11.0.dll.

  9. Open the VsPkg.cs file and change the value of the DefaultRegistryRoot attribute to

    "Software\\Microsoft\\VisualStudio\\11.0Exp"
    
  10. The original sample does not register its language service, so you must add the following attribute to VsPkg.cs.

    [ProvideLanguageService(typeof(RegularExpressionLanguageService), "RegularExpressionLanguage", 0, RequestStockColors=true)]
    
  11. You must add a source.extension.vsixmanifest file.

    • Copy this file from an existing extension to your project directory. (One way to get this file is to create a VSIX project (under File, click New, then click Project. Under Visual Basic or C# click Extensibility, then select VSIX Project.)

    • Add the file to your project.

    • Open the file with the VSIX Manifest Editor.

    • Change the following fields:

    • ID: RegExLangServ

    • Product Name: RegExLangServ

    • Description: A regular expression language service.

    • Under Content, click Add Content, select the VS Package content type, and then select the RegExLangServ project.

    • Save and close the file.

  12. Build the solution. The built files are deployed to %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\11.0Exp\Extensions\MSIT\ RegExLangServ\.

  13. Start debugging. A second instance of Visual Studio opened.

See Also

Other Resources

Language Services