views:

445

answers:

1

Is it possible to run a macro in Visual Studio 2008 the moment a solution is closed? I would like to delete the .suo-files of that solution, so that the current user settings are not presented to me the next time I open the solution.

+1  A: 

(C#)

Use the _applicationObject provided in the Connection class in a new Addin project.

In the OnConnection event, type the code to add new event handers, as below

_applicationObject.Events.SolutionEvents.AfterClosing += _applicationObject.Events.SolutionEvents.BeforeClosing +=

Let the IDE complete the lines and create the methods for you. In the beforeClosing handler, catch the name of the solution file, and store it on class member. (e.g. this._storeSolutionFile = _applicationObject.Solution.FileName;)

Then in the afterClosing handler, simply pick up the solution file name again (from this._storeSolutionFile), change the extension to sou, and delete it.

Hope this helps.

Binary Worrier
This is rather a plugin than a macro, isn't it? Doesn't really matter though, I'm going to try out this approach shortly. Thx.
Grimtron