feat: use floating NuGet version 2.* for Microsoft.Build.Sql and resolve at runtime#22405
feat: use floating NuGet version 2.* for Microsoft.Build.Sql and resolve at runtime#22405ssreerama wants to merge 10 commits into
Conversation
…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
There was a problem hiding this comment.
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.Sqlversion from2.1.0to2.*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. |
PR Changes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- 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
…k, inline exception messages, fix tests
There was a problem hiding this comment.
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
expectedFilesinBuildDirectory, so it will return true even if2.*now resolves to a newer version than the currently-extracted DLLs. To align with the PR goal of auto-updating, consider using the resolved.nupkgfor 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;
}
This PR: Changes the default
Microsoft.Build.Sqlversion from a pinned2.1.0to a floating2.*, 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.
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines