문제

When you write a VS addin that proffers menu items to VS, it calls your QueryStatus implementation to check whether your menu items should be visible, enabled, etc.

My menu items are not appropriate to run during certain situations, e.g. when a build is happening. How do I detect whether there's a build running?

도움이 되었습니까?

해결책

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top