locked
Custom tool error does not cause build process to fail RRS feed

  • Question

  • This is using VS 2010 and C# on Windows 7 Premium.

    I grabbed the GeneratorSample and am quite happy so far. Seems that these custom tools do exactly what I want. However, there is a behavior that puzzles me:

    When I start the build process and the Custom Tool returns VSConstants.E_FAIL, the build simply continues. As I intend to use the tool more or less unattended to create some convenience wrappers from files, I would rather prefer to get a clean failure then an "incomplete" assembly that misses a few wrappers.

    Digging through the code and looking at the output a little closer, it seems to me that the IVsGeneratorProgress object used to communicate the failures does not cause the build to stop. Instead, it only adds the failures to the Error List.

    So what could I do to tell VS that my Custom Tool has failed so critically that the build process should fail also?

    • Edited by Marcus Riemer Saturday, October 2, 2010 10:27 AM Looked at wrong place, the generator itself retunrs VSConstants.E_FAIL
    Saturday, October 2, 2010 10:13 AM

Answers

  • Not irrelevant at all. I should have mentioned/suggested using a custom build task here. If you need to generate the code during the build operation, then a custom msbuild task is definitely the right way to do this.

    Sincerely,


    Ed Dore
    Monday, October 25, 2010 10:29 PM

All replies

  • Hi Marcus,

    Generally speaking Single File Generators generate their code when the parent file is saved. So the generator doesn't necessarily get invoked during the build process. What exactly are you returning from the Generate method? Based on the sample you linked to, you should probably be returning a null value from the Generate function to flag that an error has occured.

    Thanks,


    Ed Dore
    Thursday, October 21, 2010 7:24 PM
  • Like Ed said, custom tool works on file save. Using whole lot of imagination to assume that you might be doing something like I did recently.

    I had a scenario where I used TemplatedCodeGenerator using a template, stored as an embedded resource, during the build process. Later created a msbuild task to invoke the code generation. If this is what you are trying as well you can try is to set the ContinueOnError attribute to false in the <Task> target. 

    http://msdn.microsoft.com/en-us/library/77f2hx1s.aspx

    If this is completelt irrelevant to what you are doing, do excuse me :)

    Monday, October 25, 2010 12:37 PM
  • Not irrelevant at all. I should have mentioned/suggested using a custom build task here. If you need to generate the code during the build operation, then a custom msbuild task is definitely the right way to do this.

    Sincerely,


    Ed Dore
    Monday, October 25, 2010 10:29 PM