Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio c++ force rebuild of a specific file

Is there a way to force Visual studio to rebuild a specific file on every build?

I have a version header with __DATE__ and __TIME__ and I want it automatically updated for each release.

I can do a prebuild event and a batch file to touch the file, just wondered if there was a feature to do this yet?

like image 755
Martin Beckett Avatar asked Mar 26 '14 23:03

Martin Beckett


2 Answers

You can also delete the .obj file with a pre-build step. It will cause the compiler to rebuild your .cpp or .h file. Right click your project > Properties > Build events > Pre-Build Event > Command Line and add the following line:

del $(TargetDir)source.obj
like image 124
Kurt Van den Branden Avatar answered Oct 17 '22 02:10

Kurt Van den Branden


From superuser, try adding a prebuild command:

copy /b filename.ext +,,

Where filename.ext is the path/name of the header you want touched. Caveat: I'm not certain VStudio always executes prebuild events, or only if it detects it actually needs to do a build.

like image 4
Nathan Ernst Avatar answered Oct 17 '22 03:10

Nathan Ernst