GitVersion
GitVersion copied to clipboard
[Improvement] Rebuild should clear the cache (GitVersion.MsBuild)
Is your improvement request related to a problem? Please describe.
I tried to solve a cryptic problem in Visual Studio for the better part of an hour.
The error message was in no way helpful (that is probably the fault of VS).
After some poking around I found that the gitversion cache was outdated or corrupt.
Clearing the cache (deleting the folder .git\gitversion_cache) finally solved the problem.
Detailed Description
All of a sudden (at least to my initial understanding) builds failed with the error error MSB4044: The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion".
I could not explain what was going on, so I do what I always do:
- Close VS
- Clean up the working directory (
git clean -dxf) - Start VS
- Rebuild Solution
This didn't help, the error kept coming back.
- I turned on diagnostic messages in VS and noticed that GitVersion generated output files (
gitversion.json) that had empty or default values for every field. - I executed the gitversion command as printed in the log from my command line, verifying same empty output.
- I found the command line switch
/diagin the docs and noticed a different output - Searching through the issues here i found that
/diaghas implicit/nocache(https://github.com/GitTools/GitVersion/issues/2596) - Further searching through the issues I found an issue that told me where the cache of GitVersion resides (https://github.com/GitTools/GitVersion/issues/798)
It was rather difficult to diagnose the issue. After I found that GitVersion was involved, finding a solution sped up significantly.
Proposed improvements:
- Condition: the error can be detected by GitVersion GitVersion should have thrown an error, empty output is proably never a valid use case together with GitVersion. I don't know why GitVersion behaved like that (empty ouput and no error), because I know that I had issues where GitVersion threw a somewhat helpful error message when it couldn't parse the version.
- Condition: the error cannot be detected by Gitversion There should be a way to invalidate / clear the cache in such situations without interaction from the user. One solution could be to store a hidden file in the work tree, so that when the worktree is cleaned up the cache becomes invalidated. For incremental builds the performance benefit of using cached data remains, but a 'Clean' or a 'Rebuild' trigger a cache refresh.
I agree with your assessments and proposals for improvement. Pull requests are welcome!
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions