diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.1.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.1.json new file mode 100644 index 00000000000000..a823f049f252f4 --- /dev/null +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.1.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "5.0.302", + "rollForward": "latestMajor" + } +} diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index 59099efb8d6c5f..69fa7982637ca8 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -117,25 +117,41 @@ describe('manager/nuget/extract', () => { it('extracts msbuild-sdks from global.json', async () => { const packageFile = 'msbuild-sdk-files/global.json'; const contents = loadFixture(packageFile); - expect(await extractPackageFile(contents, packageFile, config)) - .toMatchInlineSnapshot(` - Object { - "deps": Array [ - Object { - "currentValue": "5.0.302", - "depName": "dotnet-sdk", - "depType": "dotnet-sdk", - "skipReason": "unsupported-datasource", - }, - Object { - "currentValue": "0.2.0", - "datasource": "nuget", - "depName": "YoloDev.Sdk", - "depType": "msbuild-sdk", - }, - ], - } - `); + expect( + await extractPackageFile(contents, packageFile, config) + ).toMatchObject({ + deps: [ + { + currentValue: '5.0.302', + depName: 'dotnet-sdk', + depType: 'dotnet-sdk', + skipReason: 'unsupported-datasource', + }, + { + currentValue: '0.2.0', + datasource: 'nuget', + depName: 'YoloDev.Sdk', + depType: 'msbuild-sdk', + }, + ], + }); + }); + + it('extracts dotnet-sdk from global.json', async () => { + const packageFile = 'msbuild-sdk-files/global.1.json'; + const contents = loadFixture(packageFile); + expect( + await extractPackageFile(contents, 'global.json', config) + ).toMatchObject({ + deps: [ + { + currentValue: '5.0.302', + depName: 'dotnet-sdk', + depType: 'dotnet-sdk', + skipReason: 'unsupported-datasource', + }, + ], + }); }); it('handles malformed global.json', async () => { diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index 48fe0a1939adba..47edd02b474b41 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -35,16 +35,18 @@ export function extractMsbuildGlobalManifest( }); } - for (const depName of Object.keys(manifest['msbuild-sdks'])) { - const currentValue = manifest['msbuild-sdks'][depName]; - const dep: PackageDependency = { - depType: 'msbuild-sdk', - depName, - currentValue, - datasource: datasourceNuget.id, - }; + if (manifest['msbuild-sdks']) { + for (const depName of Object.keys(manifest['msbuild-sdks'])) { + const currentValue = manifest['msbuild-sdks'][depName]; + const dep: PackageDependency = { + depType: 'msbuild-sdk', + depName, + currentValue, + datasource: datasourceNuget.id, + }; - deps.push(dep); + deps.push(dep); + } } return { deps }; diff --git a/lib/manager/nuget/readme.md b/lib/manager/nuget/readme.md index fe57c0fb21e796..d8d14edd29bc8c 100644 --- a/lib/manager/nuget/readme.md +++ b/lib/manager/nuget/readme.md @@ -1,3 +1,5 @@ The `nuget` configuration object is used to control settings for the NuGet package manager. -The NuGet package manager supports a SDK-style `.csproj`/`.fsproj`/`.vbproj` format, as described [here](https://natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/). -This means that .NET Core projects are all supported but any .NET Framework projects need to be updated to the new `.csproj`/`.fsproj`/`.vbproj` format in order to be detected and supported by Renovate. +The NuGet package manager supports a SDK-style `.csproj`/`.fsproj`/`.vbproj`/`.props`/`.targets` format, as described [here](https://natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/). +This means that .NET Core projects are all supported but any .NET Framework projects need to be updated to the new `.csproj`/`.fsproj`/`.vbproj`/`.props`/`.targets` format in order to be detected and supported by Renovate. + +The NuGet manager also supports `global.json` and `.config/dotnet-tools.json` SDK files. diff --git a/lib/manager/nuget/types.ts b/lib/manager/nuget/types.ts index eae8865e24fa40..e4cbfd60f14968 100644 --- a/lib/manager/nuget/types.ts +++ b/lib/manager/nuget/types.ts @@ -16,8 +16,8 @@ export interface Registry { } export interface MsbuildGlobalManifest { - readonly sdk: MsbuildSdk; - readonly 'msbuild-sdks': Record; + readonly sdk?: MsbuildSdk; + readonly 'msbuild-sdks'?: Record; } export interface MsbuildSdk {