在我的扩展中,我还具有构建器功能,可以在 Visual Studio 构建当前解决方案之后或之前构建其他项目和解决方案。因此,当我构建其他项目时,我必须阻止用户意外构建当前解决方案或任何项目的任何尝试。它必须等待。
以下代码运行良好,但当我在解决方案资源管理器中右键单击项目并从该弹出菜单中单击“构建”或“重建”时,它似乎不会阻止构建。
private void OverrideBuildCommands()
{
/* this I can cancel/restart */
BuildCommandEvents = DTE.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 882];
BuildCommandEvents.BeforeExecute += BuildCommandEvents_BeforeExecute;
BuildCommandEvents.AfterExecute += BuildCommandEvents_AfterExecute;
BuildEvents = DTE.Events.BuildEvents;
DTE.Events.BuildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
DTE.Events.BuildEvents.OnBuildDone += BuildEvents_OnBuildDone;
DTE.Events.BuildEvents.OnBuildProjConfigBegin += BuildEvents_OnBuildProjConfigBegin;
DTE.Events.BuildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone;
/* this I can cancel/restart */
RebuildCommandEvents = DTE.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 883];
RebuildCommandEvents.BeforeExecute += RebuildCommandEvents_BeforeExecute;
RebuildCommandEvents.AfterExecute += RebuildCommandEvents_AfterExecute;
DTEEvents = DTE.Events.DTEEvents;
DTE.Events.DTEEvents.OnBeginShutdown += DTEEvents_OnBeginShutdown_CancelBuild;
}
任何帮助或指针将不胜感激。