Skip to content

feat: use floating NuGet version 2.* for Microsoft.Build.Sql and resolve at runtime#22405

Open
ssreerama wants to merge 10 commits into
mainfrom
sai/July/buildSqlUpdate-clean
Open

feat: use floating NuGet version 2.* for Microsoft.Build.Sql and resolve at runtime#22405
ssreerama wants to merge 10 commits into
mainfrom
sai/July/buildSqlUpdate-clean

Conversation

@ssreerama

@ssreerama ssreerama commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This PR: Changes the default Microsoft.Build.Sql version from a pinned 2.1.0 to a floating 2.*, and adds runtime resolution logic that queries the NuGet v3 API to resolve it to the latest stable 2.x release before use.

This ensures new project creation and DLL downloads always pick up the latest 2.x SDK package without requiring manual extension updates.

  • Change FALLBACK_MICROSOFT_BUILD_SQL_VERSION from '2.1.0' to '2.*' (floating)
  • Add isValidMicrosoftBuildSqlVersion() to accept both exact semver and floating patterns
  • Add resolveNugetVersion() exported function: pass-through for exact, resolve for floating
  • Add resolveFloatingVersion() using NuGet v3 flat-container API (https.get)
  • Update getMicrosoftBuildSqlVersion() to use new validation helper
  • Apply resolveNugetVersion() in projectController, templates, and buildHelper
  • Add 5 unit tests for resolveNugetVersion (exact, floating, minor-floating, fallback, error)
  • Update package.json default, CHANGELOG.md, README.md

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

BuildSqlDynamicUpdate

…lve at runtime

- Change FALLBACK_MICROSOFT_BUILD_SQL_VERSION from '2.1.0' to '2.*' (floating)
- Add isValidMicrosoftBuildSqlVersion() to accept both exact semver and floating patterns
- Add resolveNugetVersion() exported function: pass-through for exact, resolve for floating
- Add resolveFloatingVersion() using NuGet v3 flat-container API (https.get)
- Update getMicrosoftBuildSqlVersion() to use new validation helper
- Apply resolveNugetVersion() in projectController, templates, and buildHelper
- Add 5 unit tests for resolveNugetVersion (exact, floating, minor-floating, fallback, error)
- Update package.json default, CHANGELOG.md, README.md
@ssreerama ssreerama added this to the July 2026 Release milestone Jun 29, 2026
Copilot AI review requested due to automatic review settings June 29, 2026 22:17
@ssreerama ssreerama linked an issue Jun 29, 2026 that may be closed by this pull request
17 tasks
Comment thread extensions/sql-database-projects/package.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the SQL Database Projects extension to use a floating default NuGet version (2.*) for Microsoft.Build.Sql, and adds runtime resolution logic to convert floating versions into exact versions when constructing NuGet download URLs and generating new project/template content.

Changes:

  • Switch default Microsoft.Build.Sql version from 2.1.0 to 2.* and accept floating versions in settings validation.
  • Add resolveNugetVersion() / resolveFloatingVersion() to resolve floating versions via NuGet’s v3 flat-container index, and apply it across project creation, template expansion, and build-time NuGet downloads.
  • Add unit tests and update docs/metadata (README, package.json default, changelog).

Reviewed changes

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

Show a summary per file
File Description
extensions/sql-database-projects/test/netCoreTool.test.ts Adds unit tests covering exact vs floating resolution, fallback behavior, and network error behavior.
extensions/sql-database-projects/src/tools/netcoreTool.ts Implements floating-version validation and NuGet v3-based resolution for Microsoft.Build.Sql.
extensions/sql-database-projects/src/tools/buildHelper.ts Resolves floating versions before constructing NuGet download URLs for legacy build tooling.
extensions/sql-database-projects/src/templates/templates.ts Resolves Microsoft.Build.Sql version during template macro expansion.
extensions/sql-database-projects/src/controllers/projectController.ts Resolves version during project creation to pass an exact SDK version to the backend.
extensions/sql-database-projects/README.md Documents that the setting supports exact and floating versions and updates the default behavior.
extensions/sql-database-projects/package.json Updates the configuration default for sqlDatabaseProjects.microsoftBuildSqlVersion to 2.*.
extensions/sql-database-projects/CHANGELOG.md Notes the default version change and the “latest 2.x” behavior.

Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts Outdated
Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/controllers/projectController.ts Outdated
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 79083 KB 79083 KB ⚪ 0 KB ( 0% )
sql-database-projects VSIX 6311 KB 6315 KB ⚪ 4 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

@codecov-commenter

codecov-commenter commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.51020% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.52%. Comparing base (4395bf6) to head (e06387f).

Files with missing lines Patch % Lines
...ons/sql-database-projects/src/tools/buildHelper.ts 36.84% 12 Missing ⚠️
...ions/sql-database-projects/src/common/constants.ts 23.07% 10 Missing ⚠️
...base-projects/src/controllers/projectController.ts 60.86% 9 Missing ⚠️
...tensions/sql-database-projects/src/common/utils.ts 78.57% 3 Missing ⚠️
...ons/sql-database-projects/src/tools/netcoreTool.ts 97.05% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (4395bf6) and HEAD (e06387f). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (4395bf6) HEAD (e06387f)
mssql 3 1
sqlproj 3 1
data-workspace 3 0
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22405       +/-   ##
===========================================
- Coverage   87.74%   75.52%   -12.23%     
===========================================
  Files         325      401       +76     
  Lines      113984   128065    +14081     
  Branches      560     8171     +7611     
===========================================
- Hits       100020    96724     -3296     
- Misses      13964    31341    +17377     
Flag Coverage Δ
data-workspace ?
mssql 75.37% <ø> (-13.75%) ⬇️
sqlproj 76.97% <75.51%> (-0.59%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...s/sql-database-projects/src/templates/templates.ts 96.21% <100.00%> (+0.11%) ⬆️
...ons/sql-database-projects/src/tools/netcoreTool.ts 73.31% <97.05%> (+3.02%) ⬆️
...tensions/sql-database-projects/src/common/utils.ts 71.77% <78.57%> (+0.13%) ⬆️
...base-projects/src/controllers/projectController.ts 60.27% <60.86%> (-0.03%) ⬇️
...ions/sql-database-projects/src/common/constants.ts 80.01% <23.07%> (-0.73%) ⬇️
...ons/sql-database-projects/src/tools/buildHelper.ts 84.72% <36.84%> (-11.39%) ⬇️

... and 317 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ssreerama and others added 2 commits June 30, 2026 09:50
- Add FALLBACK_MICROSOFT_BUILD_SQL_VERSION='2.*' and OFFLINE_FALLBACK_MICROSOFT_BUILD_SQL_VERSION='2.2.0'
- Export resolveNugetVersion() from netcoreTool to resolve floating versions via NuGet v3 API using proxy-aware HttpClient/axios
- Move isValidMicrosoftBuildSqlVersion to utils.ts (no regex, uses endsWith + parseInt)
- Add offline fallback in projectController, templates, and buildHelper so extension activation is never blocked by network failure
- Add 4 localized constant functions for NuGet version resolution messages in buildHelper region of constants.ts
- Add 5 unit tests for resolveNugetVersion covering exact, floating, fallback, and network error cases
Copilot AI review requested due to automatic review settings June 30, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 12 out of 12 changed files in this pull request and generated 9 comments.

Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts Outdated
Comment thread extensions/sql-database-projects/src/common/utils.ts
Comment thread extensions/sql-database-projects/src/controllers/projectController.ts Outdated
Copilot AI review requested due to automatic review settings June 30, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts
Comment thread extensions/sql-database-projects/src/common/utils.ts
Comment thread extensions/sql-database-projects/src/common/constants.ts Outdated
Copilot AI review requested due to automatic review settings June 30, 2026 20:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/common/constants.ts Outdated
Comment thread extensions/sql-database-projects/src/common/constants.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Comment thread extensions/sql-database-projects/src/tools/netcoreTool.ts Outdated
Copilot AI review requested due to automatic review settings June 30, 2026 22:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 13 out of 13 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

extensions/sql-database-projects/src/tools/buildHelper.ts:170

  • This runtime resolution won’t reliably "pick up the latest" package once the build DLLs already exist: the early-return check only looks for expectedFiles in BuildDirectory, so it will return true even if 2.* now resolves to a newer version than the currently-extracted DLLs. To align with the PR goal of auto-updating, consider using the resolved .nupkg for the exact version as a lightweight sentinel when the configured version was floating.
        if (utils.isValidMicrosoftBuildSqlVersion(nugetVersion)) {
            try {
                nugetVersion = await resolveNugetVersion(nugetName, nugetVersion);
            } catch (e) {
                nugetVersion = OFFLINE_FALLBACK_MICROSOFT_BUILD_SQL_VERSION;
                const fallbackMessage = constants.couldNotResolveNugetVersion(
                    utils.getErrorMessage(e),
                    nugetVersion,
                );
                outputChannel.appendLine(fallbackMessage);
                void vscode.window.showWarningMessage(fallbackMessage);
            }
        }

        const fullNugetName = `${nugetName}.${nugetVersion}`;
        const fullNugetPath = path.join(this.extensionBuildDir, `${fullNugetName}.nupkg`);

        // Check whether all required files are already present in the BuildDirectory.
        // This covers both pre-bundled DLLs (shipped in the VSIX) and previously downloaded/extracted files.
        // We do not require the .nupkg sentinel to be present — the DLLs themselves are the source of truth.
        // TODO: handle when multiple versions of this nuget are in the BuildDirectory and a user wants to
        // switch back to an older one - probably should remove other versions when a new one is downloaded.
        let missingFiles = false;
        for (const fileName of expectedFiles) {
            if (!(await utils.exists(path.join(this.extensionBuildDir, fileName)))) {
                missingFiles = true;
                break;
            }
        }

        if (!missingFiles) {
            return true;
        }

Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/common/utils.ts
Comment thread extensions/sql-database-projects/test/templates.test.ts
Copilot AI review requested due to automatic review settings July 1, 2026 19:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 14 out of 14 changed files in this pull request and generated 4 comments.

Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/test/templates.test.ts
Comment thread extensions/sql-database-projects/src/templates/templates.ts
Comment thread extensions/sql-database-projects/src/tools/buildHelper.ts
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.

[Task]: Upgrade Microsoft.Build.Sql to 2.2.0 version

4 participants