如何以编程方式启用 Visual Studio 扩展
问题描述:
我创建了一个 Visual Studio 扩展并将其打包在 Visual Studio 设置中.现在,当我安装安装程序时,vsix 被安装并且也在扩展管理器窗口中看到,但它处于禁用状态.我尝试过为扩展添加注册表项等方法......但同样没有用.
I have created a visual studio extension and have packaged it in visual studio setup. Now, when i install the setup, the vsix gets installed and is also seen in the Extension manager window, but its in disabled state. I have tried methods like adding registry entry for the extension and etc... but same was not useful.
答
您应该将 ProvideAutoLoad
属性添加到您的包类中,并在加载时指定 UI 上下文.对于自动加载 vsix,你应该这样写:
You should add ProvideAutoLoad
attribute to your package class and specify UI context when it's going to load. For auto-load vsix you should write sthm like this:
[ProvideAutoLoad(VSConstants.UICONTEXT.NotBuildingAndNotDebugging_string)]
public sealed class MyVSIX : Package