5

In my solution I have a project with an attached pre-build event to check if certain files need to be regenerated. This all works fine if something changed in the project (or dependent projects). However, if nothing changed the pre-build event is not triggered.

Is there a way to run the pre-build event everytime VS tries to build a project (even if it is clean from a code file standpoint)?

Alternatively, is there any other way to run a script first before building a project so that I can regenerate my files first?

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181

1 Answers1

3

For a Visual C++ project you may specify Command Line in the Custom build step (Configuration Properties - Custom build step) and leave the field Outputs empty. It will be executed even if the project has no changes.


Here is the similar question.

Community
  • 1
  • 1
Evgeny Timoshenko
  • 3,119
  • 5
  • 33
  • 53
  • As of VS2019 this no longer works. Visual studio issues a warning "No outputs specified for item "...". Its custom build command will be skipped." Edit: just realized this answer was for custom build step, not custom build tool. I haven't tried custom build tools. – Eddie Parker Jan 14 '20 at 13:29
  • 1
    Amending my previous comment further: looks like there's a setting to "Verify Inputs and Outputs Exist" that you can disable to get the above working. – Eddie Parker Jan 14 '20 at 13:47