New versions of Fast Solution Build may be found on
http://workspacewhiz.com/ in the Other
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
Debug command is now available.
- Quickly identifies and builds just those projects that have changed files.
Build Solution command, no slow per project full solution dependency checks
- 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
Debug.Start, a slow full solution dependency check is
- 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
- Unzip the archive.
- Close down Visual Studio .NET.
The installer offers much more ease of use, including an uninstall feature, and should be used
Setting Up Keyboard Bindings
- Reopen Visual Studio .NET.
- Choose to either accept or not accept the default Fast Solution Build
- If desired, you may install a key binding for the macro:
- Go to Tools->Options->Keyboard.
- If the keyboard-mapping scheme has never had a custom copy made, press
the Save As button and name your key bindings.
- In Show commands containing:, type FastSolutionBuild.
- Click on FastProjectBuild.Connect.BuildActiveProject.
- Go to Press shortcut key(s).
- Press F7 (or your desired key).
- Click Assign.
- Click on FastProjectBuild.Connect.RunActiveProject.
- Go to Press shortcut key(s).
- Press F5 (or your desired key).
- Click Assign.
- 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.
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
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.
CConnect::OnConnection() code is quite a bit different from
the boilerplate AppWizard generated code. It performs the following steps:
m_pAddInInstance are set to
NULL. While developing Workspace Whiz, VS.NET called the
OnConnection() function more than once without calling
OnDisconnection(). Setting these values to
OnConnection() calls don't crash.
- 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.
- During the execution of the function, large blocks of code are wrapped in
try-catch blocks. When launching from a command-line build, requesting
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
object. Even though you can successfully retrieve the
AddNamedCommand() also causes Visual Studio to
throw an exception.
- 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
OnConnection() again with a
(which causes recreation of the toolbar items and add-in commands). This
check force recreates the commands, making the assumption they aren't there.
- 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,
identifies the proper command and routes accordingly.
BuildActiveProject works by performing the following steps:
- 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,
- Like VC6, all files are saved before the build.
- The Build output window pane is obtained through the function
GetOutputWindowPane(). It is cleared and some text is displayed.
- If any of the solution, solution build, build dependency, or other
EnvDTE objects can't be retrieved,
exits with an error.
- The startup projects are obtained. The startup projects are attached
CComSafeArray. If you attach a
CComSafeArray and don't intend it to be destroyed, be sure to detach it
CComSafeArray will destroy it!
- All the dependencies begin to recurse.
- Any project that is not a C/C++ project is ignored.
- The solution context's "should build project" setting is used to ignore
any projects the developer turned off for the solution configuration.
- All required dependencies are traversed. If they haven't been
dependency checked yet, it goes back to step 6.
- The proper configuration and platform is retrieved for the project's
- If any of the children dependencies built, then a build is automatically
forced for the parent projects.
- Finally, the
VCConfiguration.UpToDate property is obtained.
This is truly where all the magic happens. It seems as if the
Build Solution command
UpToDate property and calls
the time. In fact, without the check for
UpToDate in Fast
Solution Build, the macro behaves no different than
RunActiveProject expands on
doing the following extra items:
- If the debugger is active, no solution build will be performed.
However, the command
Debug.Start is fired, to simulate the
Continue behavior when stepping or at a
- The active project and all its updated dependencies are built.
Finally, Fast Solution Build wedges itself into a couple of BuildEvents.
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
OnBuildDone is triggered and no build errors occurred,
Debug.Start is called, causing the debugger to become active.
Please report any
comments, bugs, or fixes to
email@example.com - thanks.
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.
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 http://workspacewhiz.com/.