Sub-issue of #267. Depends on Phases 4 (#293), 5 (#294), 6 (#295). The atomic swap: this is the single point where the version source flips from NBGV to native, so it lands as one change — no PR may ship with two active versioning systems. The repo's own migration completes in a post-publish tail (below) so self-hosting never breaks.
Scope
SDK — native build-time versioning
- New
Versioning SDK module at src/Buildvana.Sdk/Modules/Versioning/Module.targets, replacing NerdbankGitVersioning. Auto-detected by the presence of a VERSION file; projects without one build unchanged (stub/opt-out target). Rename UseNerdbankGitVersioning → UseVersioning, keeping a warned alias for the old property.
- New build-time task in
Buildvana.Sdk.Tasks: reads VERSION + buildvana.json (via Buildvana.Core.Configuration), runs VersioningService in-process (hand-wired ctor injection, no container) using the engine-backed IReporter from Phase 5, and sets $(Version), $(AssemblyVersion), $(FileVersion), $(AssemblyInformationalVersion) honoring versioning.assemblyVersionPrecision. Uses the single LibGit2Sharp height calculator — no git CLI dependency, no "git absent" error.
SDK — ThisAssembly version constants
- The
Versioning module enables GenerateThisAssemblyClass and contributes default ThisAssemblyConstants for the version fields we consume (at minimum AssemblyVersion, FileVersion, informational/semver/simple strings, IsPublicRelease, IsPrerelease), feeding the Phase 6 generator. This replaces NBGV's ThisAssembly end-to-end. (EnableDefaultThisAssemblyConstants=false still suppresses them.)
Tool — rewire onto the library
- Delete the tool's own versioning types (
VersionSpec, VersionSpecChange, VersionFile, VersionIncrement, VersionService) and route the existing version consumers (the release flow) through Buildvana.Core.Versioning. Remove the nbgv subprocess + JSON-parsing path; the tool reads VERSION.
- Git height stays in the library, not
GitService; GitService keeps pure git-access concerns (identity, credentials, URL, current branch). Decide how the tool hands a repo/branch to the calculator.
- (The standalone
bv version show/advance command stays Phase 8; here we only rewire existing consumers and keep VERSION read/write available via the library.)
NBGV removal
- Delete
Modules/NerdbankGitVersioning/, remove the NBGV BV_PackageVersion injection from PackageVersions.props, and drop pathFilters (warn if non-empty).
Packaging spike (do first)
- Verify the build-time task loads LibGit2Sharp + its native assets inside the MSBuild task host under both
dotnet build and .NET-Framework msbuild.exe (out-of-proc task host); package LibGit2Sharp's managed + runtimes/<rid>/native assets into Buildvana.Sdk, cribbing NBGV's layout. A surprise here reshapes the phase, so de-risk before building on it.
Self-host transition (in this PR)
- Add the repo's own
VERSION (+ any remaining versioning keys in buildvana.json), kept in sync with the retained version.json. version.json and nbgv are retained for now because the repo still self-hosts on the last published (NBGV) SDK.
Post-publish tail (follow-up, after the new SDK is published)
- Roll the self-host SDK pin to the newly published version; then remove
version.json, the nbgv entry from .config/dotnet-tools.json, and any transitional NBGV scaffolding. Must land after publish so the build never lacks what its SDK expects.
Acceptance criteria
- A C# project using
Buildvana.Sdk with a VERSION file gets correct $(Version)/$(AssemblyVersion)/$(FileVersion)/$(AssemblyInformationalVersion) via plain dotnet build (not just bv); precision honors assemblyVersionPrecision; a generated ThisAssembly carries the version constants.
- Height increases monotonically within a version line and resets at each
VERSION change; the overall version never regresses. No system git required; detached HEAD ⇒ non-public-release.
- NBGV no longer appears in the SDK package, its injection, or the tool;
UseNerdbankGitVersioning still works with a deprecation warning; projects without a VERSION build as before.
bv's release flow computes versions natively without nbgv.
- The packaging spike passes under both MSBuild hosts.
dotnet bv build self-hosts throughout (old published SDK + retained version.json), and again after the post-publish tail.
- CHANGELOG: Unreleased with
**BREAKING CHANGE** entries for NBGV removal, the UseNerdbankGitVersioning→UseVersioning rename, the version.json→VERSION migration, and pathFilters removal; plus the migration note.
Sub-issue of #267. Depends on Phases 4 (#293), 5 (#294), 6 (#295). The atomic swap: this is the single point where the version source flips from NBGV to native, so it lands as one change — no PR may ship with two active versioning systems. The repo's own migration completes in a post-publish tail (below) so self-hosting never breaks.
Scope
SDK — native build-time versioning
VersioningSDK module atsrc/Buildvana.Sdk/Modules/Versioning/Module.targets, replacingNerdbankGitVersioning. Auto-detected by the presence of aVERSIONfile; projects without one build unchanged (stub/opt-out target). RenameUseNerdbankGitVersioning→UseVersioning, keeping a warned alias for the old property.Buildvana.Sdk.Tasks: readsVERSION+buildvana.json(viaBuildvana.Core.Configuration), runsVersioningServicein-process (hand-wired ctor injection, no container) using the engine-backedIReporterfrom Phase 5, and sets$(Version),$(AssemblyVersion),$(FileVersion),$(AssemblyInformationalVersion)honoringversioning.assemblyVersionPrecision. Uses the single LibGit2Sharp height calculator — nogitCLI dependency, no "git absent" error.SDK — ThisAssembly version constants
Versioningmodule enablesGenerateThisAssemblyClassand contributes defaultThisAssemblyConstants for the version fields we consume (at minimumAssemblyVersion,FileVersion, informational/semver/simple strings,IsPublicRelease,IsPrerelease), feeding the Phase 6 generator. This replaces NBGV'sThisAssemblyend-to-end. (EnableDefaultThisAssemblyConstants=falsestill suppresses them.)Tool — rewire onto the library
VersionSpec,VersionSpecChange,VersionFile,VersionIncrement,VersionService) and route the existing version consumers (the release flow) throughBuildvana.Core.Versioning. Remove thenbgvsubprocess + JSON-parsing path; the tool readsVERSION.GitService;GitServicekeeps pure git-access concerns (identity, credentials, URL, current branch). Decide how the tool hands a repo/branch to the calculator.bv version show/advancecommand stays Phase 8; here we only rewire existing consumers and keepVERSIONread/write available via the library.)NBGV removal
Modules/NerdbankGitVersioning/, remove the NBGVBV_PackageVersioninjection fromPackageVersions.props, and droppathFilters(warn if non-empty).Packaging spike (do first)
dotnet buildand .NET-Frameworkmsbuild.exe(out-of-proc task host); package LibGit2Sharp's managed +runtimes/<rid>/nativeassets intoBuildvana.Sdk, cribbing NBGV's layout. A surprise here reshapes the phase, so de-risk before building on it.Self-host transition (in this PR)
VERSION(+ any remaining versioning keys inbuildvana.json), kept in sync with the retainedversion.json.version.jsonandnbgvare retained for now because the repo still self-hosts on the last published (NBGV) SDK.Post-publish tail (follow-up, after the new SDK is published)
version.json, thenbgventry from.config/dotnet-tools.json, and any transitional NBGV scaffolding. Must land after publish so the build never lacks what its SDK expects.Acceptance criteria
Buildvana.Sdkwith aVERSIONfile gets correct$(Version)/$(AssemblyVersion)/$(FileVersion)/$(AssemblyInformationalVersion)via plaindotnet build(not justbv); precision honorsassemblyVersionPrecision; a generatedThisAssemblycarries the version constants.VERSIONchange; the overall version never regresses. No systemgitrequired; detached HEAD ⇒ non-public-release.UseNerdbankGitVersioningstill works with a deprecation warning; projects without aVERSIONbuild as before.bv's release flow computes versions natively withoutnbgv.dotnet bv buildself-hosts throughout (old published SDK + retainedversion.json), and again after the post-publish tail.**BREAKING CHANGE**entries for NBGV removal, theUseNerdbankGitVersioning→UseVersioningrename, theversion.json→VERSIONmigration, andpathFiltersremoval; plus the migration note.