Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:26:38+00:00 2026-05-22T19:26:38+00:00

I have a simple batch file that calls MSBuild to build my Visual Studio

  • 0

I have a simple batch file that calls MSBuild to build my Visual Studio solution, then runs the solution’s NUnit tests, and then uses Wix to create an MSI. However I can’t figure out how to stop the build process if any of the unit tests fail.

I tried the following:

nunit-console ../test.nunit
echo %ERRORLEVEL%

But regardless of whether unit tests passed or failed, %ERRORLEVEL% is always 0. Is there another way to easily determine whether any of the tests failed? I am using NUnit 2.5.9.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:26:39+00:00Added an answer on May 22, 2026 at 7:26 pm

    After a while of searching it turns out the problem was that somewhere in my development process, the ERRORLEVEL variable was assigned a value. Thus when I wrote echo %ERRORLEVEL% it was reporting the ERRORLEVEL variable, not the actual ERRORLEVEL exit code.

    I fixed this simply by closing the console and reopening it. Now when unit tests fail, the exit code is greater than 0. If all tests pass, the exit code is equal to 0.

    EDIT:
    I completely removed this from my script. Now instead I put nunit-console $(TargetPath) in my test project’s post-build events. That way, when I build the solution with MSBuild, it will automatically run unit tests and report an error when tests fail. When building in Visual Studio, this approach also causes an error to be added to the error list when unit tests fail, which is nice for identifying new bugs even more quickly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple little batch file program that I wrote but it fails
I'm running Windows 2003 Service Pack 2. I have a batch file that runs
I have a simple batch file that executes BTSTask ImportBindings on a previously exported
I have a service that sometimes calls a batch file. The batch file takes
i have a simple batch file that i would like to be able to
I have a very simple batch file that lauches a Java app (Saxon) with
In Autosys, I have a job that executes a fairly simple DOS batch file
I am trying to create a simple batch file that will replace a line
I have a batch file which starts multiple instances of simple console application (Hello
I have the following batch file that when run asks the user for input.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.