Visual Studio 2008 插件/加载项开发 - 入门
关于此 stackoverflow 问题 ,我将如何创建自己的 Visual Studio 2008 插件?
我查看了 MSDN 上的 Visual Studio 开发人员中心,但信息量巨大。 项目类型繁多,我什至不知道从哪里开始。
如果我想编写满足以下要求的内容,我应该从哪里开始寻找:
- 一个在 Visual Studio 中像“服务”一样运行的插件,并且能够轮询 Visual Studio 获取信息,并且处理 Visual Studio 事件。
- 我想从 VS 访问的信息包括当前打开的项目、谁打开的项目以及其他基于解决方案/项目文件的信息。
- 我希望能够处理的事件包括打开/关闭/编辑/创建/删除解决方案/项目/单个文件。
- 我还希望能够在每个解决方案的基础上处理与 VS 的任何交互。 因此,我想处理与文件的任何交互,甚至是代码编辑,而且还可以处理其他交互,例如与菜单的交互,或者只是 IDE 本身的交互。
除了这些之外,我还希望能够在某个地方存储数据。 这通常在哪里完成? 我可以将元数据添加到解决方案文件中吗? 或者,将此信息保存到以某种方式附加到解决方案的小型本地数据库实例是否有意义?
我只需要朝着正确的方向推动,这一切可能吗? 我应该关注 Visual Studio 开发人员中心的哪一部分? 我应该检查哪些 API?
干杯!
In relation to this stackoverflow question, how would I go about creating my own Visual Studio 2008 plug-in?
I've checked the Visual Studio Developer Centre on MSDN, but the amount of info is overwhelming. There are loads of project types, and I don't even know where to start.
Where should I start looking if I want to write something which meets the following requirements:
- A plug-in that runs like a "service" in Visual Studio, and is able to poll Visual Studio for information, and handle Visual Studio events.
- The info I'd like to access from VS are things like, what projects are currently open, who has them open, and other solution/project file based info.
- The events I'd like to be able to handle are things like, the opening/closing/editing/creating/deleting of Solutions / Projects / individual files.
- I'd also like to be able to handle any interaction with VS on a per solution basis. So, I'd like to handle any interaction with files, even code editing, but also, just other interaction, like with the menus, or just the IDE itself.
As well as these, I'd also like to be able to store data somewhere. Where is this usually done? Can I add Metadata to the Solution file? Or, does it make sense to save this info to a small local instance of a database, that is somehow attached to the solution..?
I just need a push in the right direction, is any of this possible? What part of the Visual Studio Developer Centre should I focus on? What APIs should I check out?
cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
加载项可以完成大部分工作。 VS2008 中有一个用于创建基本加载项的模板。
我有一个插件,您可以下载该插件,它可以连接到解决方案/项目加载事件等 - 它是免费的,并附带源代码( http://www.huagati.com/projectloader/download/huagatiprojectloader.zip )。 这个特定的加载项会检测项目/解决方案何时加载并预加载引用的程序集,以解决可能导致 VS2008 崩溃的 CLR 错误。 不管怎样,它的源代码展示了如何检测您正在寻找的一些事件。
除此之外,有关插件开发以及涉及的所有小怪癖和技巧的权威资源是 Carlos Quintero 的博客 ( http ://msmvps.com/blogs/carlosq/ )及其网站上的“howto”文章系列( http://www.mztools.com/resources_vsnet_addins.aspx)。
Craig Skibo 的博客 ( http://blogs.msdn.com/craigskibo/ ) 也提供了一些有用的提示。
An add-in can do most of that. There's a template in VS2008 for creating a base add-in.
I have an add-in that you can download that hooks into the solution/project load events etc - it is free and comes with source code ( http://www.huagati.com/projectloader/download/huagatiprojectloader.zip ). This particular add-in detects when projects/solutions are loaded and pre-loads referenced assemblies to work around a CLR bug that can cause VS2008 to crash. Anyway, the source code for it shows how to detect some of the events you're looking for.
Other than that, the definitive resource on add-in development and all the little quirks and tricks involved is Carlos Quintero's blog ( http://msmvps.com/blogs/carlosq/ ) and the "howto" article series on his website ( http://www.mztools.com/resources_vsnet_addins.aspx ).
Craig Skibo's blog ( http://blogs.msdn.com/craigskibo/ ) also has some useful tips.
您需要:
购买这本书,如果没有别的的话。
You want:
Buy the book, if nothing else.