Dependencies modified by pre-build event

I have a custom tool that scans all .c files in my project, and then, if any of them have changed, rebuilds a single auto-generated .c file, also included in the project. I run this tool as a pre-build event. This all works fine. The problem is that when I change a .c file and compile, the pre-build event runs, runs my tool, and modifies the auto-generated .c file. But the dependencies have already been checked, and VC has already decided that the autogenerated file does not need to be recompiled. So I then have to compile _again_, in order to get the autogenerated file to recompile.

Is there any way to force a re-checking of dependencies after the pre-build event Alternatively, is there a way to force my auto-generated C file to be compiled every time, regardless of dependencies (Could I set it to depend on every other .c and .h file in the project, for instance )

thanks



Answer this question

Dependencies modified by pre-build event

  • Michael Barbu

    Feal free to create a suggestion for this. Post the link I will vote for it.

    http://connect.microsoft.com/feedback/default.aspx SiteID=210



  • Christopher Ireland

    Hi Alex,

    Currently we have no support for forcing a recheck of the dependencies during build. Also, build events are not designed to affect the dependency graph. But Custom Build Steps and Custom Build Rules do that.

    You may achieve the intended behavior by creating a custom build step for one dummy file in the project, specify its output as the auto-generated .c file and set as additional dependencies all the .c files in your project.

    Hope this helps.

    Marian Luparu
    Visual C++ IDE


  • Dependencies modified by pre-build event