Visual Studio插件开发基础

Visual Studio插件主要有两种:Add-inVSX(Visual Studio eXtensibility)

两者区别可参考这篇文章:Visual Studio Extensions - from Add-in to VSPackage

安装了相应的SDK后,在创建工程时,就能看到插件工程的模板

Visual Studio插件开发基础

Visual Studio插件开发基础

vs2005vs2008只支持Add-In插件(下文以vs2008为例)

安装:将插件dll和AddIn文件拷贝到%USERPROFILE%\Documents\Visual Studio 2008\Addins目录

卸载:手动删除插件dll和AddIn文件来卸载Add-in插件,然后启动一下vs2008来清空残余的注册表信息

调试:在插件工程的属性框中,将插件dll直接输出到%USERPROFILE%\Documents\Visual Studio 2008\Addins目录中

选择“启动外部程序”,并填写D:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe

命令行参数:/resetaddin XXXXXX.Connect     注:XXXXXX一般为插件工程名    XXXXXX.Connect定义在AddIn文件中

启用:Tools -- Add-in Manager...

Visual Studio插件开发基础

某个vs2008的Addin文件示例:

<?xml version="1.0" encoding="gbk" standalone="no"?>
<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
<HostApplication>
<Name>Microsoft Visual Studio</Name>
<Version>9.0</Version>
</HostApplication>
<HostApplication>
<Name>Microsoft Visual Studio Macros</Name>
<Version>9.0</Version>
</HostApplication>
<Addin>
<FriendlyName>MyToolsAddIn - No Name provided.</FriendlyName>
<Description>MyToolsAddIn - No Description provided.</Description>
<Assembly src="file">C:\Users\user\Documents\Visual Studio 2008\Addins\TGameTools.dll</Assembly>
<FullClassName>MyToolsAddIn.Connect</FullClassName>
<LoadBehavior>0</LoadBehavior>
<CommandPreload>1</CommandPreload>
<CommandLineSafe>0</CommandLineSafe>
</Addin>
</Extensibility>

vs2010同时支持Add-in和VSX两种插件

Add-in:vs2010不再支持手动的安装和卸载Add-in插件,因此,开发者需要使用一个安装项目将插件项目的dll输出和AddIn文件打包到msi文件来安装插件

与vs2005、vs2008一样,插件会被安装到%USERPROFILE%\Documents\Visual Studio 2010\Addins目录中

如果不再需要插件,可到控制面板中卸载

vs2012及之后的版本只支持VSX插件

VSX(以vs2015为例)

① 安装:双击vsix插件即可安装   会被安装到%appdata%\..\Local\Microsoft\VisualStudio\14.0\Extensions\xxxxxxxx.xxx目录中  注:xxxxxxxx.xxx为随机生成的字母数字

Visual Studio插件开发基础

② 卸载和启用:在vs的Tools菜单下的Extensions and Updates...弹出的对话框中管理所有VSX

Visual Studio插件开发基础

③ 调试:选择“启动外部程序”:D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe    命令行参数:/rootsuffix Exp

调试时插件会被输出到%appdata%\..\Local\Microsoft\VisualStudio\14.0Exp\Extensions中

VSX插件使用vsct文件来编写插件界面,vsct中xml标签及相关用法可以参考VSCT XML schema reference

Mads Kristensen开发了Extensibility Tools插件,使得编写vsct时能Snippets(自动完成)

VSX参考网站

Visual Studio Extensibility (VSX)

Dynamically add menu items

Add a most recently used list to a submenu

VSX github代码

https://github.com/visualstudioextensibility/VSX-Samples

https://github.com/Microsoft/VSSDK-Extensibility-Samples

https://github.com/onlyutkarsh/VisualStudioStatusBarDemo

https://github.com/onlyutkarsh/SolutionEventsMonitor

https://github.com/zeroc-ice/ice-builder-visualstudio

https://github.com/Foliotek/vs2015BuildOnSave

https://github.com/michaelscodingspot/CodyDocs

https://github.com/tafuji/VsExtensibility-ContextMenu

https://github.com/deloitte-solvas/VSX-sample

https://github.com/ryanmolden/AutohideToolbarExample

一些有用的Visual Studio插件

Extensions for Visual Studio

Increase productivity with Visual Studio extensions

Top Ten Free Extensions for Visual Studio 2008

Top Ten Free Extensions for Visual Studio 2010

Top 14 Must Have Free Extensions For Visual Studio 2015

在Visual Studio Market中搜索更多的插件

https://marketplace.visualstudio.com/

上一篇:vue-9-动画


下一篇:漏洞利用查询工具sandi