简体   繁体   English

如何使Visual Studio扩展中的构建失败

[英]How to fail the build from a Visual Studio Extension

I'm building a package manager, and I need to restore packages before each build. 我正在构建一个包管理器,我需要在每次构建之前恢复包。

I have hooked the DTE.OnBuildBegin to achieve this, which works fine, However if there is an error I need to fail the build. 我已经连接了DTE.OnBuildBegin来实现这一点,这很好,但是如果有错误我需要使构建失败。

I have discovered that I can add to the error list using the ErrorListProvider, which works great however the build still continues and succeeds. 我发现我可以使用ErrorListProvider添加到错误列表,它工作得很好但是构建仍然继续并成功。 Even worse is that if you click run rather than build, the restore fails but the code still runs. 更糟糕的是,如果单击“运行”而不是“构建”,则还原将失败,但代码仍会运行。 And because Visual Studio uses a different view while running you don't see the error list while it is running. 并且因为Visual Studio在运行时使用不同的视图,所以在运行时看不到错误列表。

在此输入图像描述

How can I fail the build? 我怎么能失败?

The following code will cancel the build. 以下代码将取消构建。

DTE dte = (DTE)GetService(typeof(DTE));
dte.ExecuteCommand("Build.Cancel");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单元测试失败后如何强制visual studio build失败 - How to force visual studio build fail after unit tests failed 如何从 VS 扩展中引发 Visual Studio 错误(破坏构建过程)? - How to raise Visual Studio errors (that break the build process) from a VS extension? 如何从扩展代码中获取 Visual Studio 扩展版本 - How ot get Visual studio extension version from the extension code 如何构建安装在已安装的扩展程序之上的Visual Studio扩展程序 - How to build Visual studio extension which install on top of an already installed extension 如何防止GridView保存数据在Visual Studio中生成 - How to prevent GridView saving data from build to build in Visual Studio 如何从Visual Studio扩展和新的csproj格式获取IntermediateOutputPath - How to get IntermediateOutputPath from Visual Studio extension and new csproj format 如何从Visual Studio Bitbucket扩展获取开发分支 - How to get a development branch from Visual Studio Bitbucket extension 如何使用Visual Studio Extension从当前解决方案中收集类型? - How to collect types from current solution using Visual Studio Extension? 如何显示Visual Studio扩展中的“添加连接”窗口? - How to show the window “Add connection” from the extension for Visual Studio? 如何从 Visual Studio 扩展显示弹出 window(不是工具窗口)? - How to display popup window (not tool window) from Visual Studio extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM