问题描述
我的解决方案有一堆项目,其中一个是 Windows 服务;我有一个停止服务的预构建步骤和一个重新启动它的后构建步骤(这样当 VS 构建/覆盖它时,windows 服务 exe 不会被锁定).
My solution has a bunch of projects one of which is a windows service; I have a prebuild step to stop the service and a postbuild step to restart it (this way the windows service exe is not locked when VS is building/overwriting it).
on pre-build:
net stop myservice
on post-build:
net start myservice
如果在我开始构建时服务没有运行,net stop 命令将失败并阻止构建继续进行.
If the service is not running while I'm starting the build, the net stop command fails and that prevents the build from proceeding.
即使预构建步骤失败,我能做些什么来仍然强制构建?
What can I do to still force the build even if the pre-build step failed?
推荐答案
我想通了——你只需要在最后添加以下语句:
I figured it out - you simply need to add the following statement at the end:
SET ERRORLEVEL = 0
或者简单地说:
EXIT 0
这篇关于在 Visual Studio 2010 中的预构建步骤中吞咽错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!