Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 every file of which the timestamp changed, compare MD5 and rollback timestamp modification if MD5 has not changed?

Thank you for your answers.

like image 650
Benoit Avatar asked Oct 13 '22 17:10

Benoit


1 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..?

like image 80
shoosh Avatar answered Oct 30 '22 01:10

shoosh