通过MSI注册解压缩的VSIX扩展,而无需使用devenv/setup [英] Registering an unpacked VSIX extension via MSI without using devenv /setup

查看:116
本文介绍了通过MSI注册解压缩的VSIX扩展,而无需使用devenv/setup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Visual Studio扩展,当前与MSI一起安装,因为我们需要在安装后执行某些任务(ngen,注册某些COM服务器等).在安装结束时,我们运行devenv.exe /setup(更具体地说,使用devenv.exe /setup /nosetupvstemplates使其更快一点)在Visual Studio 2012及更高版本中注册扩展(在2010年,不需要此步骤,因为VS2010会重建扩展会在每次启动时进行缓存.)

We have a Visual Studio extension, currently installed with MSI, since we need to perform certain tasks after the installation (ngen, registering certain COM servers, etc). In the end of the installation, we run devenv.exe /setup (more specifically, devenv.exe /setup /nosetupvstemplates to make it a bit faster) to register the extension in Visual Studio 2012 and above (in 2010 this step was not required, since VS2010 would rebuild the extensions cache on every startup).

我们目前正在寻求移至VSIX的部分安装,但是存在某些问题:

We're currently looking to move to a partial VSIX installation, but there are certain issues:

  1. 我们有一定的文件夹结构(其他捆绑工具).我找不到在VSIX包中包含任意文件夹和文件的选项.这可能吗?

  1. We have a certain folder structure (additional bundled tools). I wasn't able to find an option to include arbitrary folders and files with in VSIX package. Is this possible?

我们正尝试避免使用devenv.exe /setup,因为在极少数情况下,这可能会导致扩展程序无法加载(如Remco Mulder在

We're trying to avoid using devenv.exe /setup, since in rare cases, this may cause extensions not to load (as detailed by Remco Mulder on the MSDN forums).

我们仍然需要执行安装后"操作,这在VSIX中是目前无法实现的.

We still need to perform "post-installation" operations, currently not possible with VSIX.

由于先前的罪过",我们对一些路径进行了硬编码,以使用VSIX软件包 遵循的CompanyName\ProductName\Version格式,但是VSIX似乎随机生成了一个文件夹现在命名(如杰森在下面的回答中提到的那样).

Due to previous 'sins', we hardcoded some of the paths to use the CompanyName\ProductName\Version format that the VSIX packages used to follow, but it seems that VSIX randomy generate a folder name now (as Jason mentions in his answer below).

所以我本质上想要的是能够安装未包装的" VSIX软件包-让MSI安装程序在磁盘上(在正确的位置,%VSInstallDir%\Common7\IDE\Extensions\Company\Product\Version)创建文件结构,然后以某种方式使VSIX使用.vsixmanifest文件在Visual Studio中注册扩展.

So what I'd essentially like is to be able to install an "unpacked" VSIX package - have the MSI installer create the file structure on disk (in the correct location, %VSInstallDir%\Common7\IDE\Extensions\Company\Product\Version), and then somehow to have VSIX consume the .vsixmanifest file to register the extension in Visual Studio.

(最初深入研究Extension Manager API,发现ExtensionManagerService中有一个名为CreateInstalledExtension的方法,该方法在程序集Microsoft.VisualStudio.ExtensionManager.Implementation.dll中采用了vsixmanifest的路径,但很遗憾,它是内部的).

(Initial digging into the Extension Manager API shows there's a method called CreateInstalledExtension in ExtensionManagerService that takes in a path to vsixmanifest, in assembly Microsoft.VisualStudio.ExtensionManager.Implementation.dll, but unfortunately it is internal).

因此,在不使用API​​黑客的情况下,是否有任何其他方法可以在不使用devenv /setup的情况下在Visual Studio(2012及更高版本)中安装扩展?

So, without resorting to API hackery, is there any alternative way to essentially install an extension in Visual Studio (2012 and above), without using devenv /setup?

推荐答案

正如Jason(和其他所有人)所建议的-是的,从外部注册Visual Studio软件包的正确"(受支持)方法是运行devenv.exe /setup,大部分情况下-它可以正常工作(尽管速度很慢,因为要重建整个Visual Studio配置).

As Jason (and everyone else) suggests - yes, the "correct" (supported) way of registering a Visual Studio package externally is by running devenv.exe /setup, and for the most part - it works without problems (albeit slow, due to entire Visual Studio configuration being rebuilt).

这是一种商业产品,偶尔我们会收到一个支持案例,抱怨说在安装我们的扩展程序后,Visual Studio中发生了一些不好的事情-其他扩展程序无法加载,解决方案资源管理器出现问题等.很少见,但确实会发生.

This is a commercial product, and every once in a while we get a support case, complaining that after installing our extension, something bad happened in Visual Studio - other extensions failed to load, problem with Solution explorer, etc. Those cases are rare, but they do happen.

为了最小化安装扩展程序对用户计算机的影响,我试图找到一种合适的方式来使用不使用devenv.exe /setup的VSIX安装机制,但不幸的是,没有支持解决我在上述问题中提出的所有问题的方案.

In an attempt to minimize the impact installing our extension does to the user's machine, I was trying to find a suitable way to use the VSIX installation mechanism that does not use devenv.exe /setup, but unfortunately, there isn't a supported scenario that handles all the issues I've raised in the question above.

在对该问题进行了广泛研究之后,我 touched 软件包已安装或卸载,导致Visual Studio在下次重新启动时刷新其软件包缓存(仅!).通过修改此文件的最后修改日期",实质上将导致Visual Studio像刚安装或卸载VSIX程序包一样工作.

After extensive research into the problem, I found an undocumented, unsupported solution that solves the problem completely! An empty file, called extensions.configurationchanged, located under %VSInstallDir%\Common7\IDE\Extensions gets touched every time a VSIX package is installed or uninstalled, causing Visual Studio to refresh it's package cache (only!) on next restart! With modifying this file's "last modified date", it will essentially cause Visual Studio to act as if a VSIX package was just installed or uninstalled.

一些快速实验,将扩展文件复制到一个空的配置单元中,然后触摸extensions.configurationchanged,将导致Visual Studio在下次重新启动时加载扩展(并处理其所有.pkgdef文件)-无需devenv /setup

A few quick experiments of copying the extension files to an empty hive, and then touching the extensions.configurationchanged will cause Visual Studio to load the extension (and process all its .pkgdef files) on next restart - no devenv /setup necessary!

几种商业产品在其联机帮助的疑难解答"部分中提供了该解决方案,用于处理扩展程序的加载失败,因此,该解决方案可能是我一直在寻找的小祸害".

Several commercial products offer this solution in the Troubleshooting section of their online help, dealing with loading failure of their extension, so this solution might be the "lesser evil" I was looking for.

使用后果自负.

这篇关于通过MSI注册解压缩的VSIX扩展,而无需使用devenv/setup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆