12/17/2004

ReBuild and Run .NET Macro

by @ 10:37 am. Filed under .NET, ASP, VB

Here’s a useful little re-build and run macro the 4Guys came up with for the .NET IDE.

If you’ve been developing any ASP.NET applications, you may have run into the same frustration that we have with the Application cache. We’ve discovered that the Application cache is not cleared until you rebuild your application (which when you think about it is kind of what you should expect) so often when you are expecting the cache to be empty, it isn’t, leaving you scratching your head until you once again remember, Oh, that’s right I have to rebuild before I run to make sure the Application cache has been cleared.

So since no button exists to rebuild a solution and run in just one single click and we could not find anyone else out there who had already done this work, we created our own Macro in VB.NET and assigned it to a button on our toolbar.

Just add this code to a Macro Module and then add it to a button on the toolbar in .NET and enjoy the one button click to re-build and run a project!


Imports EnvDTE
Imports System.Diagnostics

Public Module UserCreated
    Public Sub ReBuildAndRun()
        ‘Add an event so that we can detect when the solution has completed the rebuild process
        AddHandler DTE.Events.BuildEvents.OnBuildDone, AddressOf AfterBuild
        ‘Rebuild the entire Solution
        DTE.ExecuteCommand(”Build.RebuildSolution”)
    End Sub

        ‘This sub is called once the solution has completed the rebuild process
    Public Sub AfterBuild(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction)
        ‘The Event Handler must be removed to prevent eternal looping since
        ‘the Debugger.Go call causes another build which would then raise the event again and again and again….
        RemoveHandler DTE.Events.BuildEvents.OnBuildDone, AddressOf MyMacros.UserCreated.AfterBuild
        ‘Run the project
        DTE.Debugger.Go(True)
    End Sub
End Module

[powered by WordPress.]

-->

Search blog:

categories:

archives:

general links:

internal links:

other:

18 queries. 0.138 seconds