Visual Studio SDK - Handle File Save Event

柔情痞子 提交于 2020-01-31 03:10:26

问题


I would like to run a script after files with certain extensions are saved in visual studio. I am wondering where the event handler for saving a file is located in the Visual Studio SDK API.

Can anyone point me in the right direction in terms of API documentation for visual studio extensions. I have found the Visual Studio SDK Reference but some direction or sample examples would be helpful.

I want to create partial designer files that are usually generated when the project is built (Mono for Android Project), my files will have temporary values, but are only intended to enable intellisense without building the entire project. I can run the process manually right now, but I would like to trigger the script when .xml or .axml files are saved.

It think I need to work with IVsRunningDocTableEvents.OnAfterSave method, but I'm not sure about how I get the handle on the running doc table, or how I filter the files I want to run the event for. This is my first attempt at using the Visual Studio SDK.


回答1:


The event handler for saving files is:

Dte.Events.DocumentEvents.DocumentSaved

Note you need to keep a reference to Events and DocumentEvents in order for it to actually work. Here is some information on that: http://social.msdn.microsoft.com/Forums/br/vsx/thread/0857a868-e650-42ed-b9cc-2975dc46e994

Here is a link to 30 sample projects that illustrate all kinds of functionality for Visual Studio Add-Ins:

http://code.msdn.microsoft.com/Visual-Studio-2010-SDK-ddfe1372

You can find some getting started informatin here:

http://msdn.microsoft.com/en-us/vstudio/ff677564.aspx



来源:https://stackoverflow.com/questions/9844900/visual-studio-sdk-handle-file-save-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!