Is there way to automatically maximize the output window on hitting build and then to automatically restore to previous state when the build completes?
You could create a macro that builds the solution then activates the output window. For example:
DTE.ExecuteCommand("Build.BuildSolution")
DTE.Windows.Item(Constants.vsWindowKindOutput).Activate()
You could then replace the Build button or the build keyboard shortcut to execute that macro.
I could implement a solution using a combination of macros.
Part of the solution is in this SO question:
OnBuildBegin does not fire in Visual Studio Macro until I run it from Macro Explorer
And the other part is to use 2 exported window settings and to toggle them on build events.
Something like:
Public Sub BuildEvents_OnBuildBegin() Handles BuildEvents.OnBuildBegin
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\Development\VsSettings\build_inprocess.vssettings")
End Sub
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) _
Handles BuildEvents.OnBuildDone
DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\Development\VsSettings\Two_Screen.vssettings")
End Sub
Related
I have an application that interacts with another one, suspending it while not used. If I end the debugging abruptly the suspended process will stay alive in the background and needs to be terminated.
I did some research and looks like none of the people found a solution that is applicable to Visual Studio 2015, in particular the macro solution will not work since looks like a dropped feature since VS2010...
My current solution is to run the proper taskkill command as a post-build action and within the startup code of the program.
I'm looking for a more elegant way of killing it, so a "post-debug" event like the one portrayed by the macro below would be perfect:
Private Sub DebuggerEvents_OnEnterBreakMode(
ByVal Reason As EnvDTE.dbgEventReason,
ByRef ExecutionAction As EnvDTE.dbgExecutionAction) Handles DebuggerEvents.OnEnterBreakMode
If (Reason = dbgEventReason.dbgEventReasonStopDebugging) Then
KillLeftoverProgram()
End If
End Sub
So is there any way to execute a cleanup shell command after using the stop button?
I am looking to create a Visual Studio AddIn which can help me launch my own debugging process. I want to keep the original F5 based debugging intact and hence i do not want to intercept that call and need a separate AddIn.
Any suggestions
The easiest way is to capture the system events/macros using an addin. It is really easy to override what vs does in these events. All the events are automatically fired when using the standard visual studio commands such as F5. This includes all of the standard visual studio shortcut keys, menus and tool bar buttons.
Create a new vs addin project and it will automatically add the code to attach the OnBeforeCommandEvent. In vb the event handler will look like the code below.
Friend Sub OnBeforeCommandEvent(sGuid As String, ID As Integer, CustomIn As Object, CustomOut As Object, ByRef CancelDefault As Boolean)
The event passes you sGuid and ID. You can resolve these two items to a macro string name (sCommandName) as follows:-
Dim objCommand As EnvDTE.Command
Try
objCommand = _applicationObject.Commands.Item(sGuid, ID)
Catch ex As Exception
'unknown guids can be ignored
Exit Sub
End Try
If objCommand Is Nothing Then Exit Sub
Dim sCommandName As String
sCommandName = objCommand.Name
nb: The _applicationObject is passed to your code when the addin starts. A new addin project will automatically inlude the following code for the OnConnection event, the first argument is the _applicationObject shown above.
OnConnection(ByVal application As Object
Once you have the sCommandName variable it will contain the name of a Visual Studio macro such as Debug.Start.
To override the Debug.Start functions then you would add some of your own code and remember to set CancelDefault to True before you exit the handler.
When you set CancelDefault to true Visual Studio will not run the standard macro which means you can run your own debugger when F5 is pressed.
These are Visual Studio macro names that are used during the build process. You can override as many or as few as you like. I have grouped them into their related functionality but you can handle them in any combination.
Select Case sCommandName
Case "Debug.Start", _
"Debug.StartWithoutDebugging"
System.Windows.Forms.MessageBox.Show("You clicked F5, we are overriding the debug process")
CancelDefault=true
Exit Sub
Case "ClassViewContextMenus.ClassViewProject.Rebuild", _
"ClassViewContextMenus.ClassViewProject.Build", _
"Build.RebuildOnlyProject", _
"Build.RebuildSelection", _
"Build.BuildOnlyProject", _
"Build.BuildSelection"
Case "Build.RebuildSolution", _
"Build.BuildSolution"
Case "ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance", _
"ClassViewContextMenus.ClassViewProject.Debug.StepIntonewinstance"
Case "Build.CleanSelection", _
"Build.CleanSolution", _
"ClassViewContextMenus.ClassViewProject.Clean"
Case "Build.SolutionConfigurations"
I have assigned a new Global hotkey to
VS 2010/Options/Environment/Keyboard/OtherContextMenus.FSIConsoleContext.ResetSession
But it seems to work only in the FSI window. How can I make the hotkey work globally?
I don't think you can do it the way you describe it (the hotkey will only work within the context of the FSI window), but you can use a VS Macro to change the focus to the FSI console, reset the session and move back;
the following worked for me: (needs additional error handling etc)
Sub ResetFSharpMacro()
Dim WindowName As String
WindowName = DTE.ActiveDocument.Name
DTE.ExecuteCommand("View.F#Interactive")
DTE.ExecuteCommand("OtherContextMenus.FSIConsoleContext.ResetSession")
DTE.Windows.Item(WindowName).Activate()
End Sub
You can then use Macros.MyMacro.... to assign a global hotkey
I know this might not sound very useful to most people, but i really like having all my code collapsed in VS and it's getting kinda annoying having to ctrl+m ctrl+o everytime i'm closing a document.
Is there some add-in that does this, or can someone give me general tips to create the add-in? thanks
You can achieve the functionality you desire by creating a macro in visual studio that executes the CollapsetoDefinitions command when ever the DocumentClosing event is raised.
Simply go: Tools -> Macros -> Macros IDE.
Then add the following code to the EnvironmentEvents module.
Private Sub DocumentEvents_DocumentClosing(ByVal Document As EnvDTE.Document) Handles DocumentEvents.DocumentClosing
Dim thread As New System.Threading.Thread(AddressOf CollapsToDefinition)
thread.Start()
End Sub
Public Sub CollapsToDefinition()
Try
If DTE.ActiveDocument Is Nothing Then Exit Sub
DTE.ExecuteCommand("Edit.CollapsetoDefinitions")
Catch
'Ignore any error
End Try
End Sub
Does anyone know of any kind of plugin or alert system which will let me know when my compiles are completed? Some of the solutions I work with are gigantic and sometimes the compiles can take 5-20 minutes (depending on the PC). Thus I would like to do something else in the meantime, but I don't want to keep checking back to see if the compile is done. Is there any way to have a windows alert, or flash the screen when the compile is done?
It would let me browse the internet whilst waiting for the compile to finish without worrying that its been complete and I'm just wasting time.
Another way is a sound cue. Control Panel + Sound, Sound tab. In the Program Events list, locate the "Microsoft Visual Studio Macros" group, assign sounds to "Build Failed" and "Build Succeeded".
OnBuildDone
Private Sub BuildEvents_OnBuildDone( _
ByVal Scope As EnvDTE.vsBuildScope, _
ByVal Action As EnvDTE.vsBuildAction) _
Handles BuildEvents.OnBuildDone
'Alert that we finished building!
System.Windows.Forms.MessageBox.Show("Build is complete!")
End Sub
http://visualstudiohacks.com/general/customize-your-project-build-process/
Growl
http://www.growlforwindows.com
+ visual studio plugin
http://www.growlforwindows.com/gfw/plugins/visualstudio
All the power of a notification system, including history, network broadcast, etc.
The same exits for snarl, another notification system on pc, same capabilities I guess
You could use the Post Build Event Commands.
Here's a tutorial