locked
VCProject interface targeting multiple versions RRS feed

  • Question

  • In my package I use VCProject/VCProjectEngine assemblies and target both VS2012/VS2013.

    What is the recommended approach here, create separate VSIX packages for each Visual Studio version?

    Maybe is better to abstract VCProject/VCProjectEngine bits used by project to some interfaces in a common assembly and then provide the implementations for each version in a separate assembly?

    Monday, March 23, 2015 10:04 PM

Answers

  • If you need two different reference sets for VS 2012 and 2013 then you need two output package assemblies and therefore two .vsix files (technically you can include two packages in the same .vsix, but it doesn't make sense because currently when installing you can't select the payload depending on the target Visual Studio, I opened a User Voice request for this scenario).

    There are several approaches for this scenario:

    - A solution with two source projects, reusing as much code as possible through partial classes, conditional compilation, etc. The drawback is that each time you add a file, you have to add it to both projects. I have been there and it's somewhat painful.

    - A solution with one common project for the core and two "adapters" projects for VS 2012/2013. While more complex, it's the best in the long run if your extension needs to support multiple VS versions for years, and it is the one that I use. See why in my post: Strategies migrating from Visual Studio add-ins to packages

    - A solution with a single project that uses Project Configurations (ex: "Debug - VS 2012", "Debug - VS 2013", "Release - VS 2012", "Release - VS 2013") to generate a different output assembly depending on the select project configuration. This works because:

    1) You can define a conditional compilation symbol (Project properties, Build tab) for each project configuration (ex: "VS2012", "VS2013")

    2) You can use conditional references for each conditional compilation symbol. So, you reference VS2012 VCProject*.dll assemblies in one project configuration, and VS 2013 VCProject*.dll assemblies in the other project configuration

    3) If required, you can use conditional compilation (#if) using a variable defined on each project configuration.



    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Tuesday, March 24, 2015 10:31 AM