Files
renovate/lib/modules/manager/nuget/index.spec.ts
Mattias Karlsson 5d9e0b82b5 fix(manager/nuget): detect MSBuild SDK updates in sqlproj files (#43831)
* fix(manager/nuget): detect MSBuild SDK updates in sqlproj files

MSBuild SDK versions in `<Sdk>`, `<Import Sdk>`, and `<Project Sdk>`
elements are exact pins, but NuGet versioning treats bare versions as
minimum ranges (`>=`). That caused dependencies such as
`0.1.19-preview` to resolve to the latest release and skip updates.

Apply hybrid versioning to all `msbuild-sdk` dependencies at extract
time: use strict `semver` when the pin is valid semver, otherwise fall
back to `semver-coerced` for non-standard NuGet version strings (e.g.
four-segment revisions). Also add `.sqlproj` to the default manager
file patterns for SSDT SQL projects.

Changes:
- Add `applyMsbuildSdkVersioning()` helper and wire it through all
  msbuild-sdk extract paths (XML, global.json, single-csharp-file)
- Extend `managerFilePatterns` to match `.sqlproj` files
- Add extract, util, index, and integration tests
- Document `.sqlproj` and MSBuild SDK extraction in nuget docs/readme

* fix(manager/nuget): use bump range strategy for msbuild-sdk deps

Replace hybrid semver versioning for MSBuild SDK pins with a default
package rule (`matchDepTypes: msbuild-sdk`, `rangeStrategy: bump`) per
review feedback. Remove `applyMsbuildSdkVersioning()` from all extract
paths and update tests accordingly. Sort nuget doc file extensions
alphabetically.
2026-07-02 05:13:47 +00:00

41 lines
1.1 KiB
TypeScript

import { matchRegexOrGlobList } from '../../../util/string-match.ts';
import { defaultConfig } from './index.ts';
describe('modules/manager/nuget/index', () => {
describe('managerFilePatterns', () => {
const paths = [
'src/Project.csproj',
'src/Project.fsproj',
'src/Project.vbproj',
'src/Database.sqlproj',
'Directory.Build.props',
'Directory.Build.targets',
'global.json',
'.config/dotnet-tools.json',
];
it.each(paths)('matches %s', (path) => {
expect(
matchRegexOrGlobList(path, defaultConfig.managerFilePatterns),
).toBe(true);
});
it('does not match unrelated files', () => {
expect(
matchRegexOrGlobList('package.json', defaultConfig.managerFilePatterns),
).toBe(false);
});
});
describe('defaultConfig', () => {
it('bumps msbuild-sdk dependencies via package rule', () => {
expect(defaultConfig.packageRules).toEqual([
{
matchDepTypes: ['msbuild-sdk'],
rangeStrategy: 'bump',
},
]);
});
});
});