You're looking for the VsShellUtilities.IsSolutionBuilding
method. An example of using it can be found the Managed Package Framework for Visual Studio 2010 (MPFProj10) in the ProjectNode
class:
protected internal virtual bool IsCurrentStateASuppressCommandsMode()
{
if (VsShellUtilities.IsSolutionBuilding(this.Site))
{
return true;
}
DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask;
if (dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break)
{
return true;
}
return false;
}