简体   繁体   中英

How do I build a Visual Studio Extension (VSIX) that targets Visual Studio 2010-2017

Our build environment is VS 2015 (ideally) targeting .net 4.0

We have just re-worked our visual studio plugins based on the Visual Studio extensibility project template in VS 2015. The resulting VSIX works great on VS 2015 & 2017 RC1.

However I would like to target the VSIX at VS 2010 (and ideally 2012). This is where the problems start....

  • VS 2010 uses .net 4.0.
  • I drop the compiler to .net 4.0
  • The VS 2015 (4.5) assemblies wont load (ie Microsoft.VisualStudio.Shell.14.0).
  • Thats OK as I don't use anything in them, so I drop the references to them in favour of the version 10.0 (2010) ones.
  • Great the code compiles.
  • But the VSIX package does not

1>C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3274: The primary reference "Microsoft.VisualStudio.Imaging, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".

So the problem seems to be that if I target VS 2010 I need it to build as .net 4.0, but the VS 2015 build script requires .net 4.5.

I'm wondering if its possible to use the VS 2010 build tools in a VS 2015 project? Or must I convert my VS 2015 project back to VS 2010?

UPDATE

Starting to think this is not possible for other reasons...

https://docs.microsoft.com/en-us/visualstudio/extensibility/faq-2017

The new VSIX v3 format is backward compatible with VSIX v2, so you'll still be able to have a single VSIX with a single VSIX ID that supports Visual Studio 2012 and later. The new VSIX v3 format does not support Visual 2010 and earlier. To support Visual Studio 2010 onward, you will need to create a separate extension (with a separate VSIX ID).

Create a seperate project and VSIX for VS 2010 and another for VS 2012 and later. You can have a look at my source here: https://github.com/ErikEJ/SqlCeToolbox

Notice that I require .NET 4.5.1 for my VS 2010 extension also (simply requires that .NET 4.5.1 is present/installed on the PC, and it is built in to Windows 8.1 and later)

我遇到了类似的问题,因此我创建了一个名为VsixUpdater的Nuget程序包,如果将其添加到VSIX项目中,它可以自动进行VSIX迁移,添加后甚至可以与旧版本的Visual Studio(我在2012年测试过)一起使用该软件包生成的VSIX软件包将与V3和2017兼容,有关详细信息,请参见https://github.com/axodox/VsixUpdater

In the end I ended up with 2 projects

  • A project targeting VS 2010 compiled under .Net 4.0 using a version 2.0 manifest (built using VS 2015).
  • A project targeting VS 2012 + compiled under .Net 4.5 using a version 3.0 manifest (built using VS 2015).

There has been a certain amount of faffing around with references, but it all seems to work. Our only outstanding issue is the code signing, as VS 2015 will not accept anything below SHA256 and VS 2012 will not accept SHA256....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM