简体   繁体   English

如何为多个Visual Studio版本创建单个VSIX扩展?

[英]How to create single VSIX extension for multiple Visual Studio version?

Need to create common VSIX extensions which need to support all versions of Visual Studio(2010 to 2017). 需要创建需要支持所有Visual Studio版本(2010年至2017年)的通用VSIX扩展。

I referred to the below link to achieve the above requirement. 我提到了以下链接来实现上述要求。

https://msdn.microsoft.com/en-us/magazine/mt493251.aspx https://msdn.microsoft.com/en-us/magazine/mt493251.aspx

In that, they told to add the package(go to the Visual Studio C# Items | Extensibility | VSPackage node, select the Visual Studio Package template and name it MyPackage.cs) to the VSIX project by using the Visual Studio Package template in VSIX project but my visual studio didn't have the Visual Studio Package item template. 在那里,他们告诉在VSIX项目中使用Visual Studio包模板将包(转到Visual Studio C#Items | Extensibility | VSPackage节点,选择Visual Studio包模板并将其命名为MyPackage.cs)添加到VSIX项目但是我的visual studio没有Visual Studio Package项目模板。 It only has the Visual Studio AsyncPackage template. 它只有Visual Studio AsyncPackage模板。 I have added my visual studio details below. 我在下面添加了我的视觉工作室详情。

在此输入图像描述

Visual studio old version only have “Visual Studio Package” option and also they suggest to use the AsyncPackage now to create a common package for multiple Visual Studio versions. Visual Studio旧版本只有“Visual Studio Package”选项,他们还建议现在使用AsyncPackage为多个Visual Studio版本创建一个通用包。 Kindly find that details here. 请在此处找到详细信息。

https://developercommunity.visualstudio.com/content/problem/293478/visual-studio-package-template-not-available-on-sd.html https://developercommunity.visualstudio.com/content/problem/293478/visual-studio-package-template-not-available-on-sd.html

If I have added the Visual Studio AsyncPackage in VSIX project, then followed the procedure, am facing below compilation error while VSIX project compilation. 如果我在VSIX项目中添加了Visual Studio AsyncPackage,那么按照该过程,在VSIX项目编译时面临编译错误。

在此输入图像描述

Kindly suggest any solution to resolve that or else kindly suggest any other way to achieve my requirement. 请提出解决方案的任何解决方案,或者以其他方式建议达到我的要求。

Note: I have created a project with VS2012 with Visual Studio supported versions in vsixmanifest file. 注意:我在vsixmanifest文件中使用VS2012和Visual Studio支持的版本创建了一个项目。 It's working only in VS2012 installed machine alone. 它仅在VS2012安装的机器上工作。 Kindly advise on this. 请就此提出建议。

I am the author of the MSDN Magazine article. 我是MSDN杂志文章的作者。 It was written before Visual Studio Package project template was replaced by the Visual Studio Async Package project template. 它是在Visual Studio包项目模板被Visual Studio Async Package项目模板替换之前编写的。

Even if you could get the template (from an old VS version), it is not possible to target from VS 2010 to VS 2017 with a single VSIX, due to the three different versions of the manifest, as explained in the article. 即使您可以获得模板(来自旧的VS版本),由于清单的三个不同版本(如文章中所述),因此无法使用单个VSIX从VS 2010定位到VS 2017。 At most, you could target from VS 2012 to VS 2017. 最多,您可以从VS 2012定位到VS 2017。

But given Microsoft's push to use async packages (at least for auto-load packages) in VS 2017 15.8 and future VS 2019 16.0 and 16.1 (see Improving the responsiveness of critical scenarios by updating auto load behavior for extensions ) the best future-proof approach is to develop a non-async package for VS 2010-2013 and another async package for VS 2015-2017. 但鉴于微软推动在VS 2017 15.8和未来的VS 2019 16.0和16.1中使用异步软件包(至少对于自动加载软件包)(请参阅通过更新扩展的自动加载行为来提高关键方案的响应性 ),这是最好的面向未来的方法是为VS 2010-2013开发非异步软件包,为VS 2015-2017开发另一个异步软件包。 Because maybe your package doesn't require autoload today (async package would not be required), but maybe in the future it requires autoload (and then you would be forced to async package), or maybe Microsoft decides in VS 2019 16.2 that even non-autoload packages must be async too... 因为今天您的软件包可能不需要自动加载(不需要异步软件包),但未来它可能需要自动加载(然后您将被迫异步软件包),或者微软可能会决定在VS 2019 16.2甚至非-autoload包也必须是异步的...

Note: you can try even async package on VS 2013 and higher with the sample Visual Studio 2013 backwards compatible async package but it is not worth if you need to target also VS 2010 and 2012. 注意:您可以使用示例Visual Studio 2013向后兼容的异步软件包在VS 2013及更高版本上尝试使用异步软件包,但如果您还需要定位VS 2010和2012,则不值得。

Bottom line: focus your time on reusing as much code as possible between the two package projects that you must create to target VS 2010-2019. 底线:将时间集中在在必须创建的目标VS 2010-2019的两个软件包项目之间重用尽可能多的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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