How to force pre-build event to occur - Programmer

This is a discussion on How to force pre-build event to occur - Programmer ; I am using Visual Studio 2005 and have a script that needs to execute prior to doing a build. This script generates files that are compiled in as resources, so it's important that the script runs before resources are compiled. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to force pre-build event to occur

  1. How to force pre-build event to occur

    I am using Visual Studio 2005 and have a script that needs to execute
    prior to doing a build. This script generates files that are compiled
    in as resources, so it's important that the script runs before
    resources are compiled.

    I have tried setting the script to run as a "pre-build event".
    Unfortunately, the pre-build event does not run if Visual Studio
    thinks all my project files are up to date. Is there a way to force
    this step to always occur?

    I also tried setting it as a "Custom Build Step". In this case, it
    always executes my script (even if all files are up to date), but only
    after the resources have been compiled. This appears to be different
    than the "Custom Build Tool" option in the tool execution order
    dialog, as the custom build step executes even when "Custom Build
    Tool" is unchecked.

    Any suggestions?

    Thanks,
    Matt


  2. Re: How to force pre-build event to occur

    Well, I'll answer my own question.

    It turns out the custom build step specified under project settings
    always runs after everything else, as I was noticing. But, you can
    specify a custom build step for a particular file in your project.
    This custom build step will run before the other stuff. So, in my
    case I was able to specify a custom build step for my resource.h file
    which runs my script, and it appears this always runs before compiling
    the resources, regardless of whether files are up-to-date or not.

    Very hacky, but it works!

    --Matt


+ Reply to Thread