Can Visual Studio remember a MD5 of my source files in order to avoid rebuilding them when the timestamp changed but not the content?
Most of the time I am doing several distinct developments on the same project and, in order to have some logical separation between them, I use a personal version control system on a project (namely fossil but this is mabye too much detail).
This allows me to commit my work in different branches in order to merge them afterwards. Meanwhile I maintain a trunk branch in which I commit work by coworkers.
But when I switch from a branch to another one (in order to perform some merge action for instance) and go back to where I came from, Visual studio will detect timestamp modifications and rebuild files that have not really be modified.
Is there a way to ask Visual Studio to consider that a source file has changed when only some hash of its contents has changed?
As the answer seems to be “no” here is another way of achieving what I would like, for which I am starting a bounty. Still read the above please.
Do you know of a simple way to have a snapshot of the timestamps and MD5 hashes of my source files, and then, for ever开发者_如何学Cy file of which the timestamp changed, compare MD5 and rollback timestamp modification if MD5 has not changed?
Thank you for your answers.
I'm afraid this is not really possible.
The issue here is that this is not just a thing for VS but actually for the entire build system which is quite separate from the actual IDE.
In order to decide if and .obj
should be compiled, VS compares its timestamp to that of the source file. Doing what you suggest will require the .obj
file to include the MD5 of the file. This also goes for .exe
and .dll
files. Changing the binary format of these files and unlikely to happen for such a rarely needed feature.
Edit - I take it back, this is probably is possible in theory. One way to go is to write a VS plugin. The plugin would save the MD5s to some file in the output directory and the just before the build starts will update the modified dates of the appropriate files.
Thinking further, this might be possible using a pre-build step..?
A simple workaround may be to write a script which looks at a file that Visual Studio isn't aware of and, if it has changed, copies it to overwrite the file that Visual Studio is aware of. The file Visual Studio sees is then excluded from source control, so it's timestamps shouldn't get touched.
The copying decision might be based on a hash, but it could just as easily compare the source and destination files directly.
Visual Studio definitely has the ability to include code generators in the build - which is what this script would be, in Visual Studios eyes. I don't know the details though - I get cmake to manage these things for me.
精彩评论