Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Failed grunt tasks not failing MSBuild target #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamiegaines
Copy link

I've been using Ncapsulate today to convert a convoluted gruntfile run from the command line into delicious MSBuild awesomeness. This library has been a huge help to me today, so thanks!

I encountered two problems while using the library today. First, when a grunt task fails, the environment exit code is set to 3, but the CmdTask.ExecAsync class kept returning a 0. I finally figured out that the final call in grunt.cmd, echo on, was overwriting the %errorlevel% variable.

So the first change in the pull requests just removes that call from the grunt.cmd file generated by the nuget install script. I don't think it affects anything to remove that line from the batch file.

Once I got that straightened out, the task still wasn't failing because of the line in CmdTask.ExecWithOutputResultAsync that was evaluating the process result. If the error code was 0 OR the stdError was empty, then it assumed that the process was successful.

I changed it so that if the error code does not equal 0, then it assumes there is an error. Then it tries to return stdError as the error message, and then stdOut if stdError is empty. This was the case with grunt, where the exit code was 3 because the task failed, but stdError was empty.

Anyway, I'm not sure if you want to use this or not. This is my first pull request ever so I'm not sure I'm doing it right. Let me know if you have questions/comment, and thanks again for such a helpful library.

…alled taks is not equal to zero, regardless of what is in stderr
… overwriting %ERRORLEVEL% variable generated by grunt
@david-driscoll
Copy link
Contributor

At first glance I don't see any problems, I'll attempt to take a look at test again on the weekend.

@adamvoss
Copy link

What is the status of this? Gulp has the same problem of not failing the build and it would be great to see that remedied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants