如何以编程方式安装VisualStudio扩展?

时间:2016-01-28 20:51:31

标签: visual-studio envdte

如何获取已安装的VisualStudio扩展列表?不知何故通过require "openssl" KEY = OpenSSL::Cipher::Cipher.new("aes-256-cbc").random_key def encrypt(plaintext) cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") cipher.encrypt iv = cipher.random_iv cipher.iv = iv cipher.key = KEY ciphertext = "" ciphertext << cipher.update(plaintext) unless plaintext.empty? ciphertext << cipher.final [iv, ciphertext] end def decrypt(iv, ciphertext) cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") cipher.decrypt cipher.iv = iv cipher.key = KEY plaintext = cipher.update(ciphertext) plaintext << cipher.final end p decrypt(*encrypt("foo")) # "foo" p decrypt(*encrypt("")) # "" ?只是这些名字是公平的。

2 个答案:

答案 0 :(得分:4)

这有用吗:

System.IServiceProvider serviceProvider = package as System.IServiceProvider;
    Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager em =
       (Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager)serviceProvider.GetService(
            typeof(Microsoft.VisualStudio.ExtensionManager.SVsExtensionManager));

    string result = "";
    foreach(Microsoft.VisualStudio.ExtensionManager.IInstalledExtension i in em.GetInstalledExtensions())
    {
        Microsoft.VisualStudio.ExtensionManager.IExtensionHeader h = i.Header;
        if (!h.SystemComponent)
            result += h.Name + " (by " + h.Author + ") v" + h.Version + " " + h.MoreInfoUrl + System.Environment.NewLine;
    }

https://vlasovstudio.com/visual-commander/commands.html#20复制。

答案 1 :(得分:3)

另一种可能性,如果你不想要DTE,因为你没有在Visual Studio中运行或者关心性能,你可以从文件系统/注册表中查询扩展:

对于用户扩展程序 %LOCALAPPDATA%\微软\ VisualStudio的* .vsix

常规扩展程序 \ Common7 \ IDE \扩展* .vsix

如果你想100%正确,你可以查看路径 \ Common7 \ IDE \ devenv.pkgdef

注意: PkgDefSearchPath 中可以有其他路径。

要检查是否启用了User Extensions,您必须查询注册表: HKEY_CURRENT_USER \ SOFTWARE \微软\ VisualStudio的\ 10.0 \ ExtensionManager \ EnabledExtensions

还有一些适用的规则,您可以在Microsoft的博客中找到: http://blogs.msdn.com/b/visualstudio/archive/2010/02/19/how-vsix-extensions-are-discovered-and-loaded-in-vs-2010.aspx