Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the build version fails for repositories cloned with --no-tags #1150

Closed
mkaring opened this issue Jan 8, 2025 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@mkaring
Copy link
Contributor

mkaring commented Jan 8, 2025

In case a repository is cloned with the --no-tags flag, Nerdbank.GitVersioning will fail in dotnet builds, due to the attempt to access a directory that does not exist.

Error Message

<snip>\out\nuget\nerdbank.gitversioning\3.7.112\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path '<snip>\.git\refs\tags'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.EnumerateFiles(String path, String searchPattern, SearchOption searchOption)
   at Nerdbank.GitVersioning.ManagedGit.GitRepository.LookupTags(GitObjectId objectId)
   at Nerdbank.GitVersioning.Managed.ManagedGitContext.get_HeadTags()
   at Nerdbank.GitVersioning.VersionOracle..ctor(GitContext context, ICloudBuild cloudBuild, Nullable`1 overrideVersionHeightOffset)
   at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() in D:\a\1\s\src\Nerdbank.GitVersioning.Tasks\GetBuildVersion.cs:line 247
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [<snip>\out\nuget\nerdbank.gitversioning\3.7.112\build\PrivateP2PCaching.proj]

This error was introduced by this pull request: #876

The first affected version is v3.7.112.
v3.6.146 works without issue.

@AArnott
Copy link
Collaborator

AArnott commented Jan 9, 2025

Excellent report and sleuthing. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants