Search code examples
c#command-linebuildcommandprebuild

How do I suppress the following commands from throwing errors on a pre-build event?


I have tried piping the following two calls to NUL with no luck:

net stop "Logging Service">nul 2>&1
taskkill /IM LogServiceHost.exe /f >nul 2>&1

They will stop my build cycle from going through:

Error   1   The command "
net stop "Logging Service">nul 2>&1
taskkill /IM LogServiceHost.exe /f >nul 2>&1" exited with code 128. LoggingUtilities

Any ideas how I can just fire these prebuild events and not care what they return, and not have it ever suppress my build?


Solution

  • Try adding the following line at the end of your post-build event. This should cause the automatically-generated .bat script to return an ERRORLEVEL 0.

    exit /b 0