Visual Studio Extensions - support multiple versio

2019-07-15 23:46发布

问题:

I've been writing an extension (Editor Classifier project, with some other features chipped in. It works fine on VS2013, but I need to support other versions VS2012 and VS2015(when it is out of Preview).

When I just add supported versions in the vsixmanifest, the problem that I'm facing is, the export of ITestContainerDiscoverer or IClassificationTypeRegistryService fails complaining

ContractName="Microsoft.VisualStudio.Text.Classification.IClassificationTypeRegistryService")' is not assignable to type 'Microsoft.VisualStudio.Text.Classification.IClassificationTypeRegistryService'

My guess is that this is because I am referencing invalid SDK versions. I could always write different versions, but is there a way to share an extension across versions of visual studio?

回答1:

@ErikEJ's tip worked for me. I had to port the extension project to VS2012 and build it with target set to [11.0,12.0] and this ensured that the VSIX that I generated worked for both VS2012 and VS2013. No errors too!