none
return value set by devenv.com? RRS feed

  • Question

  • Hi,

    I know with the /Out option I can log what devenv.com does when trying to build the solution.  However, I'd like to know if there is a way that I can capture a return value that it might set.  For example:

    1. I call devenv.com from the command line with the solution file and a log file specified.
    2. One or more of the projects fail to build
    3. Some variable, either the return value of the devenv.com or maybe an environment variable gets set so that I know whether or not to bother inspecting the log file.  If this variable says no problems, I start using the .exe.  If it says problems, instead of looking for .exe I look at the log and try to find what didn't build.

    Is there a variable that would tell me this?  Like, can I say, maybe in a bat file, x = devenv.com ...., and then look at the value of x?

    Wednesday, June 20, 2012 10:02 PM

Answers

  • At least for Visual Studio 2008, devenv does set the errorlevel to nonzero when any project in the solution fails to compile.  I have just confirmed this.

    To answer your final question, you can always redirect the output to a file and write a little program to parse the that file for success. Another alternative might be

    devenv <solution> /build | find ", 0 failed,"

    find tends to set the error level to 0 when it finds the string and 1 when it fails to.

    • Marked as answer by msnhelpsme Monday, July 16, 2012 9:12 PM
    Friday, July 6, 2012 5:43 PM

All replies

  • You could try checking the ERRORLEVEL in a batch file. See this link for details...

    http://www.robvanderwoude.com/errorlevel.php

    Thursday, June 21, 2012 12:45 AM
  • Yeah, I have that in the batch file but it is always 0 no matter what happens with the build.  His website explains a lot otherwise, but I had read this a while ago and saw it wasn't accurate.
    Thursday, June 21, 2012 2:45 PM
  • Like, when you build a solution with say, 10 projects, and you build it with the IDE, at the bottom it will say "10 successful, 0 failed, 0 up-to-date".  Is there any way to capture that information when I call the tool from a batch file?

    Friday, July 6, 2012 5:22 PM
  • At least for Visual Studio 2008, devenv does set the errorlevel to nonzero when any project in the solution fails to compile.  I have just confirmed this.

    To answer your final question, you can always redirect the output to a file and write a little program to parse the that file for success. Another alternative might be

    devenv <solution> /build | find ", 0 failed,"

    find tends to set the error level to 0 when it finds the string and 1 when it fails to.

    • Marked as answer by msnhelpsme Monday, July 16, 2012 9:12 PM
    Friday, July 6, 2012 5:43 PM
  • Oh, I must be getting the return value from the start command.  I do this in my bat file:

    START /w devenv.com /BUILD release mySol.sln

    and so ERRORLEVEL is getting set to the return value of devenv.com and then the return value of START.  I think I used START so that the batch file waits for devenv.com to finish.  Is this a good idea?
    Friday, July 6, 2012 6:09 PM
  • You are mixing up devenv.com and devenv.exe.  devenv.exe is the gui version and will return immediately.  devenv.com is a console app and will run to completion before proceeding on in your batch file.
    Friday, July 6, 2012 7:43 PM
  • In VS2012, I have seen the following:

    ....

    ========== Build: 5 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    "0"

    The "0" is the echo of "%errorlevel%".

    The .cmd file looks like this:

        echo devenv.com %py_sln_dir%\pcbuild.sln /%%A %devenv_build_type% /project %%P
        call devenv.com %py_sln_dir%\pcbuild.sln /%%A %devenv_build_type% /project %%P
        echo "%errorlevel%"

    Is there something wrong doing it this way?

     
    Tuesday, February 19, 2013 7:06 PM
  • the problem is the the call command before devenv.com is what is setting the ERRORLEVEL. don't use call, there really is no reason, just run devenv.com ...

    then you'll capture the return value of devenv.com (not call)

    schleprock

    Tuesday, July 16, 2013 2:07 PM
  • Thanks, It is working for me.
    Tuesday, October 10, 2017 9:14 AM