Skip to content

Replace GitVersion with Nerdbank.GitVersioning for unified local + CI versioning#91

Merged
mkrueger merged 3 commits into
mainfrom
dev/sevoku/Nerdbank.GitVersioning
May 21, 2026
Merged

Replace GitVersion with Nerdbank.GitVersioning for unified local + CI versioning#91
mkrueger merged 3 commits into
mainfrom
dev/sevoku/Nerdbank.GitVersioning

Conversation

@sevoku
Copy link
Copy Markdown
Collaborator

@sevoku sevoku commented May 20, 2026

Summary

Adopt Nerdbank.GitVersioning (NBGV) as the single source of truth for version computation, replacing both the abandoned GitVersion tool and the CI-only patch-bump script introduced in #90.

NBGV is a Microsoft / .NET Foundation project (MIT-licensed) that derives the patch component from git history (commit count since version.json last changed) at MSBuild time. This means local developer builds and CI builds now produce identical, deterministic versions — no more 1.0.0 placeholders when building outside the pipeline.

Why

#90 dropped GitVersion in favor of a custom patch-bump script that runs only in CI. Local builds therefore lost meaningful versioning. We needed a replacement that:

  • Computes the patch automatically from git history starting at the last major/minor bump.
  • Lets us pin a baseline major.minor in source.
  • Works the same way locally and in CI.
  • Is maintained by a trustworthy upstream (we ruled out devlooped/GitInfo for OSMF license reasons).

NBGV satisfies all of the above and is already widely used across .NET Foundation repos.

Changes

New: version.json

  • Baseline 1.1-preview — bumping major/minor is a one-line edit; patch resets automatically because the file changed.
  • publicReleaseRefSpec covers main, rel/*, and PR merge refs. Other branches (including dev/*) get a -g<sha> suffix to prevent collisions on feeds.
  • nugetPackageVersion.semVer = 2.
  • cloudBuild.* variable injection disabled — we emit the version explicitly in our pipelines instead.

Removed: GitVersion.yml

Build infrastructure

  • Directory.Build.props: replaced the old VersionSuffix block with a single <PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" VersionOverride="3.9.50" />. VersionOverride is required because CosmosDBShell.Fuzzer opts out of central package management.
  • Directory.Packages.props: added Nerdbank.GitVersioning 3.9.50 for the central-PM consumers.
  • .config/dotnet-tools.json: gitversion.toolnbgv 3.9.50.

CI

Both pipelines now fetch full git history (already required by NBGV), restore tools, and call nbgv get-version once for the package version. The redundant /p:Version, /p:FileVersion, /p:InformationalVersion, and /p:PackageVersion overrides on dotnet build, the per-RID dotnet publish loop, and dotnet pack were removed — NBGV stamps those automatically.

  • .github/workflows/validate-and-package.yml
  • .pipelines/CosmosDB-Shell-Official.yml

Verification

  • dotnet restore, dotnet build CosmosDBShell.sln -c Release, and dotnet test CosmosDBShell.sln -c Release all pass (1074/1074).
  • The built CosmosDBShell.dll carries the expected attributes:
    • AssemblyVersion = 1.1.0.0
    • FileVersion = 1.1.0.<commit-hash-short> (NBGV embeds the first 16 bits of the commit SHA into the revision component for per-commit uniqueness)
    • AssemblyInformationalVersion = 1.1.0-preview+808048fc14
    • NuGetPackageVersion = 1.1.0-preview
  • CosmosDBShell --versionCosmosDBShell 1.1.0-preview (808048fc14)
  • version shell command → 1.1.0-preview (existing parser splits on +, unchanged).
  • Existing VersionCommand_UsesInformationalVersion test still passes.

Operational notes

  • Bumping major/minor: edit version.json and commit. Patch resets to 0 and increments per commit afterwards.
  • Cutting a stable release: drop -preview from version.json's version (or branch to rel/1.1).
  • Feature/PR branches that don't match publicReleaseRefSpec get a -g<sha> suffix on the package version, so they cannot collide with official packages on a feed.

Adopt NBGV so local and CI builds share a single, git-history-driven version computation, replacing the CI-only patch script introduced in #90.

- Add version.json with baseline 1.1-preview, public-release refspecs (main, rel/*, PR merges), SemVer 2 package version, and disabled cloudBuild auto-variables.
- Add Nerdbank.GitVersioning 3.9.50 PackageReference via Directory.Build.props (with VersionOverride so CosmosDBShell.Fuzzer still works without central package management) and a corresponding entry in Directory.Packages.props.
- Replace gitversion.tool with nbgv in .config/dotnet-tools.json.
- Delete GitVersion.yml.
- Update GitHub Actions workflow and OneBranch pipeline to fetch full git history, restore .NET tools, compute the package version via nbgv get-version, and stop overriding /p:Version, /p:FileVersion, /p:InformationalVersion, /p:PackageVersion on build/publish/pack.
@sevoku sevoku requested review from a team and Copilot May 20, 2026 20:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the repository’s versioning system from GitVersion + CI-only patch scripting to Nerdbank.GitVersioning (NBGV), making version computation deterministic and consistent across local builds and CI.

Changes:

  • Introduces version.json as the repo’s version baseline and configuration for NBGV.
  • Wires NBGV into MSBuild via Directory.Build.props and updates central package/tool manifests accordingly.
  • Updates GitHub Actions and OneBranch pipelines to rely on NBGV instead of manually overriding MSBuild version properties.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.json Adds NBGV configuration and establishes the baseline version and release ref specs.
GitVersion.yml Removes the legacy GitVersion configuration.
Directory.Packages.props Adds central package version entry for Nerdbank.GitVersioning.
Directory.Build.props Adds NBGV PackageReference to enable MSBuild-time version stamping.
.github/workflows/validate-and-package.yml Switches CI version computation to nbgv get-version and removes MSBuild version overrides.
.pipelines/CosmosDB-Shell-Official.yml Switches OneBranch version computation to nbgv get-version and removes MSBuild version overrides.
.config/dotnet-tools.json Replaces GitVersion tool with nbgv in the local tool manifest.

Comment thread Directory.Build.props Outdated
sevoku added 2 commits May 20, 2026 22:31
Address PR feedback: VersionOverride was applied unconditionally, shadowing the central entry in Directory.Packages.props for every consumer. Use a conditional PackageReference instead so central-PM projects pull the version from Directory.Packages.props and only CosmosDBShell.Fuzzer (which sets ManagePackageVersionsCentrally=false) pins it directly.
Copilot AI review requested due to automatic review settings May 20, 2026 20:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@mkrueger mkrueger merged commit a445f94 into main May 21, 2026
9 checks passed
@mkrueger mkrueger deleted the dev/sevoku/Nerdbank.GitVersioning branch May 21, 2026 04:36
mkrueger added a commit that referenced this pull request May 21, 2026
Converts the `Unreleased — since v1.0.273` section to `1.1.4 —
2026-05-21` (first release on the 1.1 line) and adds entries for the PRs
that landed after #86 (the last CHANGELOG update):

- **Highlights / New features:** multi-line REPL input with `\`
continuation and parser-driven incomplete-input detection
([#88](#88)); parser & query
diagnostics with line, column, source caret, and "Did you mean…"
suggestions ([#87](#87)).
- **Documentation:** notes that [docs/navigation.md](docs/navigation.md)
and [README](README.md) now document multi-line input.
- **Build & pipeline:** versioning moved to
[Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning);
local builds now produce the same versions as CI
([#90](#90),
[#91](#91)).

PR #89 was a stepping stone superseded by the NBGV migration, so it
isn't called out separately.

Docs-only change — no code touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants