Post build event for an entire solution in Visual Studio

While creating the SDK for Reactor, I ran into a need to execute an outside utility after building a solution in Visual Studio. The utility packages up all project outputs in a solution and prepares it for registration with a Reactor server. Obviously, post build events at the project level were not sufficient, and there is no post build event configuration in the VS solution properties. Google didn't produce any good results, either. So, I turned to my new favorite site for answers, stackoverflow.com. I asked the question, and in just minutes, I had the answer.

Basically, you have to handle the OnBuildDone event in a macro. I'm not a fan of VB syntax, but that's what we're limited to in the VS Macro Editor. Anyway, here is the code that was posted to the question on stackoverflow.com:

   1:  Public Sub AfterBuild(ByVal scope As vsBuildScope, ByVal action As vsBuildAction) Handles BuildEvents.OnBuildDone    
   2:      If scope = vsBuildScope.vsBuildScopeSolution Then        
   3:          System.Diagnostics.Process.Start("some file I want to run")   
   4:      End If
   5:  End Sub
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

It works as advertised and saved me from coming up with some crazy hack. I can't take credit for this macro, and wish I knew who it was who answered the question on stackoverflow, but all I know is his/her username is Kyralessa. Thanks, Kyralessa!

Comments

# Registry Cleaner Reviews said:

nice share, good

article, very usefull for me...thank you

Sunday, May 2, 2010 10:33 PM