From a94cefdbad5c9a07ac04f77b7174cc643ce80028 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Mon, 6 Feb 2023 23:21:41 +0000 Subject: [PATCH] Properly detect branch changes for incremental builds When the current HEAD (branch/tag/commit) is changed within VS, we currently don't surface any changes and the IDE thinks there's nothing to update. But obviously GitInfo would need to calculate again all the info. This commit takes the ideas from #186 by @brunom, integrates into GitInfo and surfaces it to VS seamlessly so users don't have to customize anything and it Just Works. Closes #186 --- readme.md | 7 +++++++ src/GitInfo/build/GitInfo.targets | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/readme.md b/readme.md index 022fbf9..ceb8c28 100644 --- a/readme.md +++ b/readme.md @@ -235,6 +235,13 @@ Available [MSBuild properties](https://learn.microsoft.com/en-us/visualstudio/ms performance reasons. Defaults to empty value (no ignoring). + $(GitCachePath): where to cache the determined Git information + gives the chance to use a shared location + for different projects. this can improve + the overall build time. + has to end with a path seperator + Defaults to empty value ('$(IntermediateOutputPath)'). + $(GitNameRevOptions): Options passed to git name-rev when finding a branch name for the current commit (Detached head). The default is '--refs=refs/heads/* --no-undefined --alwas' diff --git a/src/GitInfo/build/GitInfo.targets b/src/GitInfo/build/GitInfo.targets index 0093075..6281822 100644 --- a/src/GitInfo/build/GitInfo.targets +++ b/src/GitInfo/build/GitInfo.targets @@ -969,6 +969,27 @@ + + + <_GitCacheFullPath>$([System.IO.Path]::Combine($(MSBuildProjectDirectory), $(GitCachePath))) + + <_GitHeadPath Condition="Exists('$(_GitCacheFullPath)GitHead.cache')">$([System.IO.File]::ReadAllText('$(_GitCacheFullPath)GitHead.cache').Trim()) + + + + + + + + + + + +