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

GetBuildVersion fails with NotSupportedException when version is a simple number #251

Closed
the-ress opened this issue Nov 8, 2018 · 2 comments
Milestone

Comments

@the-ress
Copy link

the-ress commented Nov 8, 2018

GetBuildVersion fails with NotSupportedException when version is a simple number (e.g. "16") even when it's in an older commit.

Expected result:
When it's the latest commit, I'd expect an informative error message.
Otherwise there shouldn't be any errors.

Actual result:

The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
System.NotSupportedException: Specified method is not supported.
   at Nerdbank.GitVersioning.SemanticVersionJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\SemanticVersionJsonConverter.cs:line 30
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, TypeobjectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Nerdbank.GitVersioning.VersionFile.TryReadVersionJsonContent(String jsonContent) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionFile.cs:line 314
   at Nerdbank.GitVersioning.VersionFile.GetVersion(Commit commit, String repoRelativeProjectDirectory) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionFile.cs:line 72
   at Nerdbank.GitVersioning.GitExtensions.CommitMatchesMajorMinorVersion(Commitcommit, Version expectedVersion, String repoRelativeProjectDirectory) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 409
   at Nerdbank.GitVersioning.VersionOracle.<>c__DisplayClass101_0.<CalculateVersionHeight>b__0(Commit c) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionOracle.cs:line 457
   at Nerdbank.GitVersioning.GitExtensions.GetCommitHeight(Commit commit, Dictionary`2 heights, Func`2 continueStepping) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 506
   at Nerdbank.GitVersioning.GitExtensions.<>c__DisplayClass25_0.<GetCommitHeight>b__0(Commit p) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 511
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Max(IEnumerable`1 source)
   at Nerdbank.GitVersioning.GitExtensions.GetCommitHeight(Commit commit, Dictionary`2 heights, Func`2 continueStepping) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 511
   at Nerdbank.GitVersioning.GitExtensions.<>c__DisplayClass25_0.<GetCommitHeight>b__0(Commit p) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 511
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Max(IEnumerable`1 source)
   at Nerdbank.GitVersioning.GitExtensions.GetCommitHeight(Commit commit, Dictionary`2 heights, Func`2 continueStepping) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 511
   at Nerdbank.GitVersioning.GitExtensions.GetHeight(Commit commit, Func`2 continueStepping) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\GitExtensions.cs:line 114
   at Nerdbank.GitVersioning.VersionOracle.CalculateVersionHeight(String relativeRepoProjectDirectory, Commit headCommit, VersionOptions committedVersion, VersionOptions workingVersion) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionOracle.cs:line 457
   at Nerdbank.GitVersioning.VersionOracle..ctor(String projectDirectory, Repository repo, Commit head, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionOracle.cs:line 86
   at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) in c:\Code\Nerdbank.GitVersioning\src\NerdBank.GitVersioning\VersionOracle.cs:line 40
   at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()
   at MSBuildExtensionTask.ContextAwareTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
@AArnott AArnott added the wontfix label Nov 8, 2018
@AArnott
Copy link
Collaborator

AArnott commented Nov 8, 2018

This is by design. NB.GV walks git history to determine the "version height" which is a core part of how the automated versioning works.

You should rebase to scrub commits with mistakes in your version.json authoring.

The only other alternative is to author a commit which entirely removes version.json from your tree, then author a new commit that reintroduces it. Then do not merge or squash these commits back with the other faulty ones. You must push them as a single history line.

@AArnott AArnott closed this as completed Nov 8, 2018
@the-ress
Copy link
Author

the-ress commented Nov 8, 2018

Can the error message include this explanation and which commit id is causing it?

@AArnott AArnott reopened this Nov 8, 2018
@AArnott AArnott added this to the 2.3 milestone Nov 25, 2018
AArnott added a commit that referenced this issue Nov 26, 2018
AArnott pushed a commit that referenced this issue Apr 1, 2024
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.8.0 to 17.9.0.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](microsoft/vstest@v17.8.0...v17.9.0)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants