Swap Nerdbank.GitVersioning for native versioning - #308
Conversation
…ourceMap ReSharper's solution-wide analysis inspects the JsonSourceMap.Frame.cs partial part in isolation and misses the instantiation in JsonSourceMap.cs, so it claims the class (which has a private constructor and a static factory method) cannot be instantiated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
It starts with the TempGitRepo harness (moved from the versioning tests, where the SDK task tests would otherwise have needed a copy) and a TempHome harness for tests exercising file-based code that resolves paths against a home directory. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e.Versioning
In preparation for replacing the tool-side versioning types:
- VersionSpec gains Stable/Unstable/NextMinor/NextMajor/ApplyChange extension
methods, porting the advance semantics of the tool's version.json-based
VersionSpec (new version lines start as prereleases).
- A new VersionFile type becomes the single reader and writer of the VERSION
file; VersioningService now reads the version specification through it. The
writer only emits the configured prerelease tag as informational text when it
fits the version file grammar, falling back to a bare dash.
- VersioningService computes FileVersion (MAJOR.MINOR.HEIGHT.0).
- GitHeightCalculator can describe the repository state Calculate depends on
as an opaque token, so callers can cache computed versions; its static
constructor points LibGit2Sharp at the runtimes/{rid}/native directory next
to the managed assembly when present, for hosts without a dependency context
(e.g. MSBuild task hosts).
The versioning and task test projects now use the harnesses from
Buildvana.Core.Testing instead of project-local copies.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The new Versioning module is auto-detected by the presence of a VERSION file in the home directory and computes Version, PackageVersion, AssemblyVersion, FileVersion, and InformationalVersion through the new ComputeVersion task, which runs VersioningService in-process using the engine-backed reporter. Computed versions are cached per home directory for the lifetime of the task host, keyed on a fingerprint of the VERSION file, the configuration file, and the repository state, so multi-project builds pay for a single Git graph walk. UseNerdbankGitVersioning remains as a deprecated alias of UseVersioning (warning BVSDK2001); the GetBuildVersion target name is kept, real or stub, for targets that depend on it. Versioned C# projects enable GenerateThisAssemblyClass by default, and the module contributes SimpleVersion, SemVer, IsPublicRelease, IsPrerelease, and GitCommitId constants to the generated class. LibGit2Sharp's managed assembly and native binaries ship in the package's bin directory; the Unix binaries are renamed at pack time (the lib prefix is stripped) because LibGit2Sharp composes the file name without it when probing the explicitly-set native library path, which is the only resolution path available without a deps.json. The SDK's own version props now read PackageVersion, which is set by both the old and the new versioning, instead of NBGV's NuGetPackageVersion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The tool's own versioning types (VersionSpec, VersionSpecChange, VersionFile, VersionIncrement) are deleted in favor of the library's, and the nbgv subprocess is gone: VersionService is now a thin release-flow facade over a recomputable VersioningService (ServerRelease refreshes the version after creating the release commit), keeping the tool-only policy methods (EnsureConsistency, ComputeVersionSpecChange) and the latest-version data from GitService. VersionIncrement survives as a private nested enum of the facade. The release flow reads and rewrites the VERSION file through the library's VersionFile, passing the configured versioning.prereleaseTag as the informational tag text. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The repository gets its own VERSION file and buildvana.json, mirroring the policy in the retained version.json. version.json and the nbgv tool entry stay for now: the repository still self-hosts on the last published (NBGV-based) SDK, and they will be removed after the new SDK is published and the pins rolled (the post-publish tail of the migration). Documentation follows: the Versioning module's diagnostics replace the NerdbankGitVersioning section (BVSDK2000 reworded, BVSDK2001 added), the VERSION file is documented in the directory structure, and the changelog gains the native-versioning feature entries and the breaking changes for the NBGV removal, the UseNerdbankGitVersioning rename, the version.json migration, and the dropped version.json-only features. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude please review this PR. |
|
Claude finished @rdeago's task in 5m 36s —— View job Claude's review
Overall this is a clean, well-scoped swap. The design holds together: A few things worth a look, roughly in priority order: 1. Stale comment referencing Nerdbank.GitVersioning — // Ensure that the release tag doesn't already exist.
// This assumes that full repo history has been checked out;
// however, that is already a prerequisite for using Nerdbank.GitVersioning.This file's imports were already updated for the swap ( 2. Case-insensitive cache key on case-sensitive filesystems — private static readonly ConcurrentDictionary<string, CachedVersion> Cache = new(StringComparer.OrdinalIgnoreCase);The per-task-host cache is keyed by the full home directory path with 3. Design question — versioning constants gated by <Target Name="BV_DefineVersioningThisAssemblyConstants"
BeforeTargets="BV_WriteThisAssemblyConstantsFile"
DependsOnTargets="GetBuildVersion"
Condition="'$(EnableDefaultThisAssemblyConstants)' != 'false'">
Nits (no action needed unless you want them): No correctness issues found in the version computation logic itself ( |
The full-history requirement for the tag-existence check still holds, but it now comes from the native Git height computation, not from NBGV. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Case-insensitive keying could make two case-differing home directories share a cache slot on case-sensitive filesystems. The fingerprint check already keeps that from ever serving stale data, but the collision would thrash the shared entry; ordinal keying gives each directory its own. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude Thanks for the review. Both actionable points are addressed:
Point 3 is as intended: Please take another look. |
|
Claude finished @rdeago's task in 1m 9s —— View job Claude's review (follow-up)
Both fixes check out, and the third point's rationale is sound. 1. Stale comment (b3609e9) — 2. Cache comparer (c551990) — 3. No new issues found. This PR looks good to merge from my side. |
Part of #296 (Phase 7 of #267); the issue stays open until the post-publish tail lands.
This is the atomic swap: the version source flips from Nerdbank.GitVersioning to Buildvana's native versioning in one change, with no PR state carrying two active versioning systems.
Versioningmodule, auto-detected by a repository-rootVERSIONfile, computingVersion/PackageVersion/AssemblyVersion/FileVersion/InformationalVersionvia a newComputeVersiontask that runsVersioningServicein-process (LibGit2Sharp height — nogitCLI). Results are cached per home directory in the task host, keyed on repository state.UseNerdbankGitVersioningremains as a warned alias ofUseVersioning(BVSDK2001); theGetBuildVersiontarget name is preserved.ThisAssemblyby default, now carryingSimpleVersion,SemVer,IsPublicRelease,IsPrerelease, andGitCommitIdalongside the Phase 6 defaults (differences vs NBGV's class are noted in the changelog).bin/; Unix natives are renamed (libprefix stripped) to match LibGit2Sharp's composed probe name, and a one-time bootstrap points it atruntimes/{rid}/native. Spike-verified from the packed layout underdotnet build;msbuild.exeuses the same .NET task host (verification on the dev machine blocked by an SDK/VS version pairing that equally affects all existing tasks).bv releasecomputes versions natively; the nbgv subprocess and the tool's own versioning types are gone. Release policy (consistency checks, bump computation) lives in a thinVersionServiceover the library.VERSION+buildvana.jsonadded;version.jsonand thenbgvtool entry are retained until the new SDK is published (post-publish tail: roll pins, deleteversion.json/nbgv, update CI comments and the.vscodeschema mapping).Buildvana.Core.Testingshared test-harness library, and a false-positive ReSharper inspection suppressed inBuildvana.Core.JsonSchema.Verified: 141 tests (36 new),
dotnet bv packself-hosts end to end, ReSharper inspectcode clean.🤖 Generated with Claude Code