-
Notifications
You must be signed in to change notification settings - Fork 329
Consolidate package version specification and computation #4336
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
Draft
paulmedynski
wants to merge
3
commits into
main
Choose a base branch
from
dev/paul/canonical-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
...ructions/package-versions.instructions.md → ...rd-party-package-versions.instructions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
.github/instructions/sqlclient-package-versions.instructions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| --- | ||
| applyTo: "**/Versions.props,build.proj,eng/pipelines/**/*.yml" | ||
| --- | ||
| # SqlClient Package Version Resolution | ||
|
|
||
| How package versions are determined across different build scenarios for the packages in this repository. | ||
|
|
||
| ## Version Properties (per package) | ||
|
|
||
| Each package has a `Versions.props` file declaring: | ||
|
|
||
| | Property | Purpose | Example | | ||
| |----------|---------|---------| | ||
| | `*NextVersion` | Version being developed; used for the next release | `7.1.0-preview1` | | ||
| | `*PublishedVersion` | Last version shipped to NuGet | `7.0.0` | | ||
|
|
||
| ## Resolution Logic | ||
|
|
||
| Each `Versions.props` uses a 3-tier `<Choose>` block: | ||
|
|
||
| | Priority | Condition | PackageVersion | FileVersion | | ||
| |----------|-----------|----------------|-------------| | ||
| | 1 | `PackageVersion<Pkg>` explicitly provided | Used as-is | Strip prerelease + append BuildNumber | | ||
| | 2 | `BuildNumber` provided (non-zero) | `NextVersion[-BuildSuffix+BuildNumber]` | `NextVersion.Split('-')[0].BuildNumber` | | ||
| | 3 | Nothing provided | `NextVersion-dev` | `NextVersion.Split('-')[0].0` | | ||
|
|
||
| ## Scenarios | ||
|
|
||
| ### Developer (local `dotnet build`) | ||
|
|
||
| **Mode:** Project (default `ReferenceType=Project`) | ||
|
|
||
| - No `BuildNumber`, no `BuildSuffix`, no `PackageVersion*` passed. | ||
| - Falls into Priority 3 (the `<Otherwise>` branch). | ||
| - **Result:** `7.1.0-preview1-dev` / FileVersion `7.1.0.0` | ||
| - Dependencies are project references — no package versions needed for siblings. | ||
|
|
||
| **Mode:** Package (`-p:ReferenceType=Package`) | ||
|
|
||
| - Same version resolution for the package being built. | ||
| - Sibling dependencies are restored from local `packages/` feed (previously packed with `-dev` suffix). | ||
| - A developer would first `dotnet build build.proj -t:Pack` to produce local packages, then consume them. | ||
|
|
||
| ### PR Pipeline (non-official CI) | ||
|
|
||
| **`buildSuffix`** set via core template parameter: | ||
| - `buildSuffix: 'pr'` (passed explicitly from PR pipeline) | ||
| - `BuildNumber` = `$(DayOfYear)$(Rev:rr)` (e.g. `15401` for day-of-year 154, run 01) | ||
|
|
||
| **Mode:** Project (typical PR validation) | ||
|
|
||
| - Versions computed in `compute-versions-ci-stage.yml` (runs `GetVersions*` targets with `-p:BuildSuffix=pr -p:BuildNumber=...`) | ||
| - Falls into Priority 2 with BuildSuffix present. | ||
| - **Result:** `7.1.0-preview1-pr15401` / FileVersion `7.1.0.15401` | ||
| - Dependencies are project references — all packages built together in-tree. | ||
|
|
||
| **Mode:** Package (PR package-ref validation) | ||
|
|
||
| - Same version computation via compute-versions stage. | ||
| - Downstream stages define stage-level variables from compute-versions output using `$[ stageDependencies... ]`. | ||
| - Each build step receives explicit `-p:PackageVersion<Pkg>=<value>` (hits Priority 1). | ||
| - Sibling dependencies consumed from pipeline artifacts published by upstream stages. | ||
|
|
||
| ### CI Pipeline (non-official, triggered on merge) | ||
|
|
||
| Same structure as PR but passes `buildSuffix: 'ci'` explicitly. | ||
|
|
||
| - **Result:** `7.1.0-preview1-ci15401` / FileVersion `7.1.0.15401` | ||
|
|
||
| ### OneBranch Pipeline (official) | ||
|
|
||
| **Mode:** Always Package (`ReferenceType=Package`) | ||
|
|
||
| Uses the full `compute-versions-stage.yml` machinery: | ||
|
|
||
| #### Step A: Compute Versions (dedicated early stage) | ||
|
|
||
| 1. Runs 6 `GetVersions*` MSBuild targets against `build.proj`. | ||
| 2. Each target calls `dotnet build <project> -getProperty:<Pkg>PackageVersion` with `BuildNumber` but **no BuildSuffix**. | ||
| 3. Falls into Priority 2 without BuildSuffix → `PackageVersion = NextVersion` as-is (e.g. `7.1.0-preview1`). | ||
| 4. Also extracts `PublishedVersion` (hardcoded in Versions.props, e.g. `7.0.0`). | ||
|
|
||
| #### Step B: Resolve Effective Versions | ||
|
|
||
| For each package, a `release<Pkg>` boolean parameter determines the outcome: | ||
|
|
||
| | `release<Pkg>` | Effective Version | Meaning | | ||
| |----------------|-------------------|---------| | ||
| | `True` | `NextVersion` (e.g. `7.1.0-preview1`) | This package is being released | | ||
| | `False` | `PublishedVersion` (e.g. `7.0.0`) | Only built as dependency; use last-shipped version | | ||
|
|
||
| These are published as ADO output variables (e.g. `versions.SqlClientPackageVersion`). | ||
|
|
||
| #### Step C: Build Stages Consume Pre-computed Versions | ||
|
|
||
| Each downstream build job receives: | ||
| - `packageVersion` parameter → passed as `-p:PackageVersion<Pkg>=<value>` | ||
| - Dependency versions → passed as `-p:PackageVersion<Dep>=<value>` | ||
|
|
||
| Since an explicit `PackageVersion<Pkg>` is provided, Versions.props hits Priority 1 — uses the value verbatim. | ||
|
|
||
| #### Summary | ||
|
|
||
| | Package Status | Version Source | Example | | ||
| |----------------|----------------|---------| | ||
| | Being released | `*NextVersion` from Versions.props | `7.1.0-preview1` | | ||
| | Dependency only | `*PublishedVersion` from Versions.props | `7.0.0` | | ||
|
|
||
| ## Key Architectural Difference | ||
|
|
||
| | Scenario | Who computes versions | How dependencies get versions | | ||
| |----------|----------------------|-------------------------------| | ||
| | Developer | Versions.props inline (Priority 3) | Project references (no version needed) | | ||
| | PR/CI (Project) | `compute-versions-ci-stage` up-front | Project references (no version needed) | | ||
| | PR/CI (Package) | `compute-versions-ci-stage` up-front | Stage variables via `$[ stageDependencies... ]` → `-p:PackageVersion<Dep>=` | | ||
| | OneBranch | `compute-versions-stage` up-front | Explicit `-p:PackageVersion<Dep>=` from stage outputs | | ||
|
|
||
| ## Updating Versions | ||
|
|
||
| After a release: | ||
| 1. Update `*PublishedVersion` to the version just shipped. | ||
| 2. Update `*NextVersion` to the next planned version. | ||
| 3. Both properties live in each package's `Versions.props`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.