In one cpp-file I use the __DATE__ macro to get the compile-date.
It gives me the date of the last compile of that file. But as the file is not changed very often, the date is old in most cases, sometimes several months.
What I actually want is the date of the last build of the project.
Is there an setting to force VS2010 to rebuild that single cpp-file on every compile of the project?
Regardless of changes in the file?
The only way I found until now is to modify the file or delete the created obj-file by an script before the build, I would prefer an solution inside VS if that is possible.
You could probably add a
Pre-Build Stepthattouch(see this thread) the file?To add a
Pre-Build Step, open yourProject Properties, thenConfiguration Properties > Build Events > Pre-Build Eventthen add the command line you want to have executed inCommand Line.Following the suggestion from Amitd, apparently you can also
touchthe file using PowerShell, see this for explanations.As suggested by Adrian McCarthy in the comments below, deleting the
.objfile would be preferable in the context where source control is used and you want to keep the.cppread-only. Using the “macros” exposed by Visual Studio, deleting them can be made easy:Quoted from Cheers and hth. – Alf as another way to achieve this