I have not tried this in Visual Studio 2010, but you can achieve this in Visual Studio 2008 with at least an automation macro. The instructions below work in 2008 and should not be too complicated to translate to 2010 (hopefully).
Open the IDE macro (Tools-> Macros-> MacroIDE), and in the list of Macros you will see the EnvironmentEvents element. Double-click this to get a module containing environment event macros.
Select SolutionEvents drop-down list, and then select QueryCloseSolution from the Declarations list. We make a macro that runs whenever you try to close a solution. We will create a message box to ask the user if they want to do this, and possibly cancel the shutdown - you should get something like this:
Private Sub SolutionEvents_QueryCloseSolution(ByRef fCancel As Boolean) Handles SolutionEvents.QueryCloseSolution If (MsgBox("Close the solution?", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel) Then fCancel = True End Sub
Save the Macro project, try closing the solution, or turn off Visual Studio. If the stars are aligned, you will see a confirmation window. If you click Cancel, the solution will not be closed, and VS will not shut down.
Now, maybe someone can confirm in the comments if this works for VS2010?
icabod
source share