Click here to Skip to main content
13,664,842 members
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 3 Dec 2002

Fast Solution Build Add-in for Visual Studio .NET

, 16 Dec 2002
Rate this:
Please Sign up or sign in to vote.
Performs VC6-style dependency checking for VS .NET multi-project solution builds

New versions of Fast Solution Build may be found on in the Other Add-ins section.


When making the transition from Visual C++ 6 to Visual Studio .NET, it became evident multi-project solution builds were quite a bit slower than their Visual C++ 6 counterpart workspaces. For people working in a single project environment, the difference is negligible. For multi-project solutions, the pain of using the Build Solution command quickly becomes obvious, while waiting for all the "dependency checking" for every project of the solution.

Fast Solution Build emulates the Visual C++ 6 build style. It builds on the concepts from the original Fast Project Build VBScript macro, while providing more ease of use and error checking. In addition, the Debug command is now available.


  • Quickly identifies and builds just those projects that have changed files. Unlike the Build Solution command, no slow per project full solution dependency checks are performed.
  • If an error occurs during the build of a project, the build shuts down immediately. The rest of the solution's projects do not continue building.
  • The equivalent of Debug.Start is available through the Run Active Project command. Unlike Debug.Start, a slow full solution dependency check is not performed.
  • If a debug session is active, the user is prompted to shut down the debug session before the build starts.
  • Also shows an example of "proper" add-in installation/uninstallation.

Installation without the Installer

  1. Unzip the archive.
  2. Close down Visual Studio .NET.
  3. Run regsvr32 FastSolutionBuild.dll.

The installer offers much more ease of use, including an uninstall feature, and should be used where possible.

Setting Up Keyboard Bindings

  1. Reopen Visual Studio .NET.
  2. Choose to either accept or not accept the default Fast Solution Build keyboard bindings.
  3. If desired, you may install a key binding for the macro:
    1. Go to Tools->Options->Keyboard.
    2. If the keyboard-mapping scheme has never had a custom copy made, press the Save As button and name your key bindings.
    3. In Show commands containing:, type FastSolutionBuild.
    4. Click on FastProjectBuild.Connect.BuildActiveProject.
    5. Go to Press shortcut key(s).
    6. Press F7 (or your desired key).
    7. Click Assign.
    8. Click on FastProjectBuild.Connect.RunActiveProject.
    9. Go to Press shortcut key(s).
    10. Press F5 (or your desired key).
    11. Click Assign.
    12. Click OK.


The bold project in the Solution Explorer is the top-level project built by the Fast Solution Build macro. To make a different project the "startup" project, right click on the desired project and choose Set as StartUp Project.

Run Fast Solution Build's BuildActiveProject or RunActiveProject commands from the Tools menu or press the keyboard key assigned to the add-in commands.

Technical Details

Fast Solution Build is a C++/ATL enhanced version of the VBScript Fast Project Build macro. It demonstrates many add-in concepts learned while developing the Workspace Whiz add-in for Visual Studio .NET. Most importantly, it illustrates the steps I have discovered to solidly run an add-in.

First, Fast Solution Build is fully capable of installing and uninstalling itself through just a regsvr32 call. It is far more convenient, especially when debugging, not to run an installer for add-in installations and uninstallations. In AddIn.cpp, DllRegisterServer() handles registering the server and hooking up the add-in's registry entries. The critical registry keys are at HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\AddIns\FastSolutionBuild.Connect and HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\PreloadAddinState. The PreloadAddinState key tells Visual Studio .NET to force creation of the add-in commands. Usually, VS.NET caches the add-in commands and toolbar entries. Unfortunately, it doesn't do a very good job of it and often loses the settings for them.

DllUnregisterServer() illustrates a couple of important functions. First, the add-in registry keys are removed, including GUIDs, typelibs, etc. Finally, Fast Solution Build actually connects with the VS.NET COM object and removes its registered commands. If the add-in created a toolbar (Fast Solution Build just adds commands to the Tools menu), this is an appropriate place to remove the toolbar, too.

The CConnect::OnConnection() code is quite a bit different from the boilerplate AppWizard generated code. It performs the following steps:

  1. m_pDTE and m_pAddInInstance are set to
    . While developing Workspace Whiz, VS.NET called the
    function more than once without calling
    . Setting these values to NULL ensures double OnConnection() calls don't crash.
  2. A test is made to see if this was launched from the command-line. This doesn't work for all command-line cases, but it covers some of them.
  3. During the execution of the function, large blocks of code are wrapped in try-catch blocks. When launching from a command-line build, requesting the CommandBars object, for instance, results in Visual Studio throwing an exception, instead of returning a proper error code. A similar thing happens when trying to add a named command to the Commands object. Even though you can successfully retrieve the Commands object, called AddNamedCommand() also causes Visual Studio to throw an exception.
  4. The Tools menu is scanned for the presence of Fast Solution Build commands. If they aren't there, it recreates them. Some VS .NET crashes don't save out command icon information and don't bother calling
    again with a ConnectMode of 5 (which causes recreation of the toolbar items and add-in commands). This check force recreates the commands, making the assumption they aren't there.
  5. Again, in Workspace Whiz, cases were seen where events weren't properly unregistered, due to OnDisconnection() not being called. Whole VS.NET crashes would result. Fast Solution Build unregisters the event handlers before it registers them.

Fast Solution Build implements two commands, BuildActiveProject and RunActiveProject. CConnect::Exec() identifies the proper command and routes accordingly.

BuildActiveProject works by performing the following steps:

  1. If the application is currently being debugged, a dialog box pops up asking the user if they want to stop debugging. If the answer is no, BuildActiveProject exits.
  2. Like VC6, all files are saved before the build.
  3. The Build output window pane is obtained through the function
    . It is cleared and some text is displayed.
  4. If any of the solution, solution build, build dependency, or other
    objects can't be retrieved, BuildActiveProject exits with an error.
  5. The startup projects are obtained. The startup projects are attached to a CComSafeArray. If you attach a SAFEARRAY to a CComSafeArray and don't intend it to be destroyed, be sure to detach it or CComSafeArray will destroy it!
  6. All the dependencies begin to recurse.
  7. Any project that is not a C/C++ project is ignored.
  8. The solution context's "should build project" setting is used to ignore any projects the developer turned off for the solution configuration.
  9. All required dependencies are traversed. If they haven't been dependency checked yet, it goes back to step 6.
  10. The proper configuration and platform is retrieved for the project's context.
  11. If any of the children dependencies built, then a build is automatically forced for the parent projects.
  12. Finally, the VCConfiguration.UpToDate property is obtained. This is truly where all the magic happens. It seems as if the Build Solution command ignores the UpToDate property and calls Build all the time. In fact, without the check for UpToDate in Fast Solution Build, the macro behaves no different than Build Solution!

RunActiveProject expands on BuildActiveProject by doing the following extra items:

  1. If the debugger is active, no solution build will be performed. However, the command Debug.Start is fired, to simulate the
    menu's Continue behavior when stepping or at a breakpoint.
  2. The active project and all its updated dependencies are built.

Finally, Fast Solution Build wedges itself into a couple of BuildEvents. When OnBuildProjConfigDone is triggered, Fast Solution Build checks for any errors during the current project's build. If it finds any, it aborts the rest of the build through the Build.Cancel command. When OnBuildDone is triggered and no build errors occurred,

is called, causing the debugger to become active.

Known Bugs

  • None at this time.


Please report any comments, bugs, or fixes to - thanks.

Edit History

4 Dec 2002 - Initial Edit

5 Dec 2002 - Version 2.01

  • Made command-line builds not crash under certain circumstances.
  • Stopped a secondary build from overriding a build already in progress.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Joshua Jensen
Web Developer
United States United States
Joshua Jensen is a gamer at heart and as such, creates games for a living. He has the distinct pleasure of creating titles exclusively for the Xbox.

In his spare time, he maintains a Visual C++ add-in called Workspace Whiz! Find it at

You may also be interested in...


Comments and Discussions

QuestionVisual Studio .NET 2003 Version? Pin
Bob Vavrik7-Aug-03 13:06
memberBob Vavrik7-Aug-03 13:06 
AnswerRe: Visual Studio .NET 2003 Version? Pin
Joshua Jensen7-Aug-03 23:05
memberJoshua Jensen7-Aug-03 23:05 
AnswerRe: Visual Studio .NET 2003 Version? Pin
Joshua Jensen7-Aug-03 23:10
memberJoshua Jensen7-Aug-03 23:10 
AnswerRe: Visual Studio .NET 2003 Version is available Pin
Joshua Jensen7-Aug-03 23:11
memberJoshua Jensen7-Aug-03 23:11 
GeneralVersion 2.10 Beta 3 Posted Pin
Joshua Jensen16-Mar-03 22:05
memberJoshua Jensen16-Mar-03 22:05 
QuestionCan you use this outside of VS? Pin
Ralph Walden5-Dec-02 6:00
memberRalph Walden5-Dec-02 6:00 
AnswerRe: Can you use this outside of VS? Pin
Joshua Jensen5-Dec-02 22:36
memberJoshua Jensen5-Dec-02 22:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05-2016 | 2.8.180810.1 | Last Updated 17 Dec 2002
Article Copyright 2002 by Joshua Jensen
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid