From 09a77864ccb2cb3bf414b33938f3c18b293bf2ff Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Mon, 13 Sep 2021 13:29:30 +0700 Subject: [PATCH 01/10] Nuget: update msbuild-sdks section in global.json #8558 --- .../nuget/__snapshots__/extract.spec.ts.snap | 16 ++++++++++ lib/manager/nuget/extract.spec.ts | 17 ++++++++++ lib/manager/nuget/extract.ts | 31 ++++++++++++++++++- lib/manager/nuget/index.ts | 1 + lib/manager/nuget/types.ts | 10 ++++++ lib/types/skip-reason.ts | 1 + 6 files changed, 75 insertions(+), 1 deletion(-) diff --git a/lib/manager/nuget/__snapshots__/extract.spec.ts.snap b/lib/manager/nuget/__snapshots__/extract.spec.ts.snap index f37a61bb873712..ee779ef1463b5b 100644 --- a/lib/manager/nuget/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/nuget/__snapshots__/extract.spec.ts.snap @@ -295,6 +295,20 @@ Array [ ] `; +exports[`manager/nuget/extract extractPackageFile() extracts msbuild-sdks from global.json 1`] = ` +Object { + "deps": Array [ + Object { + "currentValue": "0", + "datasource": null, + "depName": "YoloDev.Sdk", + "depType": "nuget", + "skipReason": "unsupported-datasource", + }, + ], +} +`; + exports[`manager/nuget/extract extractPackageFile() extracts package version dependency 1`] = ` Array [ Object { @@ -366,6 +380,8 @@ Object { } `; +exports[`manager/nuget/extract extractPackageFile() handles malformed global.json 1`] = `null`; + exports[`manager/nuget/extract extractPackageFile() ignores local feed in NuGet.config 1`] = ` Object { "deps": Array [ diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index af9392d5050541..ad694cdb822132 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -113,6 +113,22 @@ describe('manager/nuget/extract', () => { await extractPackageFile(otherContents, otherPackageFile, config) ).toMatchSnapshot(); }); + it('extracts msbuild-sdks from global.json', async () => { + const packageFile = 'msbuild-sdk-files/global.json'; + const contents = loadFixture(packageFile); + // FIXME: explicit assert condition + expect( + await extractPackageFile(contents, packageFile, config) + ).toMatchSnapshot(); + }); + it('handles malformed global.json', async () => { + const packageFile = 'msbuild-sdk-files/invalid-json/global.json'; + const contents = loadFixture(packageFile); + // FIXME: explicit assert condition + expect( + await extractPackageFile(contents, packageFile, config) + ).toMatchSnapshot(); + }); describe('.config/dotnet-tools.json', () => { const packageFile = '.config/dotnet-tools.json'; @@ -126,6 +142,7 @@ describe('manager/nuget/extract', () => { } } }`; + it('works', async () => { // FIXME: explicit assert condition expect( diff --git a/lib/manager/nuget/extract.ts b/lib/manager/nuget/extract.ts index 8f23b34d36975e..ef9cf597aa2f94 100644 --- a/lib/manager/nuget/extract.ts +++ b/lib/manager/nuget/extract.ts @@ -2,10 +2,11 @@ import { XmlDocument, XmlElement, XmlNode } from 'xmldoc'; import { getGlobalConfig } from '../../config/global'; import * as datasourceNuget from '../../datasource/nuget'; import { logger } from '../../logger'; +import { SkipReason } from '../../types'; import { getSiblingFileName, localPathExists } from '../../util/fs'; import { hasKey } from '../../util/object'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; -import type { DotnetToolsManifest } from './types'; +import type { DotnetToolsManifest, MsbuildGlobalManifest } from './types'; import { getConfiguredRegistries } from './util'; /** @@ -112,6 +113,34 @@ export async function extractPackageFile( return { deps }; } + if (packageFile.endsWith('global.json')) { + const deps: PackageDependency[] = []; + let manifest: MsbuildGlobalManifest; + + try { + manifest = JSON.parse(content); + } catch (err) { + logger.debug({ fileName: packageFile }, 'Invalid JSON'); + return null; + } + + for (const depName of Object.keys(manifest['msbuild-sdks'])) { + const sdk = manifest['msbuild-sdks'][depName]; + const currentValue = sdk[0]; + const dep: PackageDependency = { + depType: 'nuget', + depName, + currentValue, + datasource: null, + skipReason: SkipReason.UnsupportedDatasource, + }; + + deps.push(dep); + } + + return { deps }; + } + let deps: PackageDependency[] = []; try { const parsedXml = new XmlDocument(content); diff --git a/lib/manager/nuget/index.ts b/lib/manager/nuget/index.ts index 4311964f62c0d5..332a78be763e5a 100644 --- a/lib/manager/nuget/index.ts +++ b/lib/manager/nuget/index.ts @@ -10,5 +10,6 @@ export const defaultConfig = { '\\.(?:cs|fs|vb)proj$', '\\.(?:props|targets)$', '\\.config\\/dotnet-tools\\.json$', + '(^|//)global\\.json$', ], }; diff --git a/lib/manager/nuget/types.ts b/lib/manager/nuget/types.ts index 631f8114e7e78a..eae8865e24fa40 100644 --- a/lib/manager/nuget/types.ts +++ b/lib/manager/nuget/types.ts @@ -14,3 +14,13 @@ export interface Registry { readonly url: string; readonly name?: string; } + +export interface MsbuildGlobalManifest { + readonly sdk: MsbuildSdk; + readonly 'msbuild-sdks': Record; +} + +export interface MsbuildSdk { + readonly version: string; + readonly rollForward: string; +} diff --git a/lib/types/skip-reason.ts b/lib/types/skip-reason.ts index 501cce0a5c27bf..1f11d3b848c224 100644 --- a/lib/types/skip-reason.ts +++ b/lib/types/skip-reason.ts @@ -34,6 +34,7 @@ export enum SkipReason { UnknownVersion = 'unknown-version', UnknownVolta = 'unknown-volta', UnsupportedChartType = 'unsupported-chart-type', + UnsupportedDatasource = 'unsupported-datasource', UnsupportedRemote = 'unsupported-remote', UnsupportedUrl = 'unsupported-url', UnsupportedVersion = 'unsupported-version', From 04874f92fdf8e4013a53ef33b2b663af490feb56 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Mon, 13 Sep 2021 17:49:04 +0700 Subject: [PATCH 02/10] Fixing PR as requested --- .../msbuild-sdk-files/global.json | 9 +++++++ .../invalid-json/global.json | 1 + .../msbuild-sdk-files/not-nuget/global.json | 3 +++ .../nuget/__snapshots__/extract.spec.ts.snap | 16 ----------- lib/manager/nuget/extract.spec.ts | 27 ++++++++++++++++--- lib/manager/nuget/extract.ts | 8 ++++++ 6 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json create mode 100644 lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json create mode 100644 lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json new file mode 100644 index 00000000000000..3e9b3e14b37ad1 --- /dev/null +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json @@ -0,0 +1,9 @@ +{ + "sdk": { + "version": "5.0.302", + "rollForward": "latestMajor" + }, + "msbuild-sdks": { + "YoloDev.Sdk": "0.2.0" + } +} \ No newline at end of file diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json new file mode 100644 index 00000000000000..6b7f8497d84651 --- /dev/null +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json @@ -0,0 +1 @@ +invalid json \ No newline at end of file diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json new file mode 100644 index 00000000000000..0e52b5db292617 --- /dev/null +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json @@ -0,0 +1,3 @@ +{ + "type": "not a nuget global.json" +} \ No newline at end of file diff --git a/lib/manager/nuget/__snapshots__/extract.spec.ts.snap b/lib/manager/nuget/__snapshots__/extract.spec.ts.snap index ee779ef1463b5b..f37a61bb873712 100644 --- a/lib/manager/nuget/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/nuget/__snapshots__/extract.spec.ts.snap @@ -295,20 +295,6 @@ Array [ ] `; -exports[`manager/nuget/extract extractPackageFile() extracts msbuild-sdks from global.json 1`] = ` -Object { - "deps": Array [ - Object { - "currentValue": "0", - "datasource": null, - "depName": "YoloDev.Sdk", - "depType": "nuget", - "skipReason": "unsupported-datasource", - }, - ], -} -`; - exports[`manager/nuget/extract extractPackageFile() extracts package version dependency 1`] = ` Array [ Object { @@ -380,8 +366,6 @@ Object { } `; -exports[`manager/nuget/extract extractPackageFile() handles malformed global.json 1`] = `null`; - exports[`manager/nuget/extract extractPackageFile() ignores local feed in NuGet.config 1`] = ` Object { "deps": Array [ diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index ad694cdb822132..837e579f66da91 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -117,9 +117,20 @@ describe('manager/nuget/extract', () => { const packageFile = 'msbuild-sdk-files/global.json'; const contents = loadFixture(packageFile); // FIXME: explicit assert condition - expect( - await extractPackageFile(contents, packageFile, config) - ).toMatchSnapshot(); + expect(await extractPackageFile(contents, packageFile, config)) + .toMatchInlineSnapshot(` + Object { + "deps": Array [ + Object { + "currentValue": "0", + "datasource": null, + "depName": "YoloDev.Sdk", + "depType": "nuget", + "skipReason": "unsupported-datasource", + }, + ], + } + `); }); it('handles malformed global.json', async () => { const packageFile = 'msbuild-sdk-files/invalid-json/global.json'; @@ -127,7 +138,15 @@ describe('manager/nuget/extract', () => { // FIXME: explicit assert condition expect( await extractPackageFile(contents, packageFile, config) - ).toMatchSnapshot(); + ).toBeNull(); + }); + it('handles not-a-nuget global.json', async () => { + const packageFile = 'msbuild-sdk-files/not-nuget/global.json'; + const contents = loadFixture(packageFile); + // FIXME: explicit assert condition + expect( + await extractPackageFile(contents, packageFile, config) + ).toBeNull(); }); describe('.config/dotnet-tools.json', () => { diff --git a/lib/manager/nuget/extract.ts b/lib/manager/nuget/extract.ts index ef9cf597aa2f94..30fd4e26dacadc 100644 --- a/lib/manager/nuget/extract.ts +++ b/lib/manager/nuget/extract.ts @@ -124,6 +124,14 @@ export async function extractPackageFile( return null; } + if (manifest['msbuild-sdks'] === undefined) { + logger.debug( + { fileName: packageFile }, + 'This global.json is not a Nuget file' + ); + return null; + } + for (const depName of Object.keys(manifest['msbuild-sdks'])) { const sdk = manifest['msbuild-sdks'][depName]; const currentValue = sdk[0]; From 2c051d0d4c5fef94d99342e146096b0044bfdb54 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 14:24:10 +0700 Subject: [PATCH 03/10] Fixing PR as requested (2) --- .../msbuild-sdk-files/global.json | 2 +- .../invalid-json/global.json | 2 +- .../msbuild-sdk-files/not-nuget/global.json | 2 +- lib/manager/nuget/extract.spec.ts | 8 ++-- lib/manager/nuget/extract.ts | 38 ++-------------- lib/manager/nuget/extract/global-manifest.ts | 44 +++++++++++++++++++ 6 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 lib/manager/nuget/extract/global-manifest.ts diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json index 3e9b3e14b37ad1..8319e185529cdc 100644 --- a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/global.json @@ -6,4 +6,4 @@ "msbuild-sdks": { "YoloDev.Sdk": "0.2.0" } -} \ No newline at end of file +} diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json index 6b7f8497d84651..39a1b3463f5632 100644 --- a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json @@ -1 +1 @@ -invalid json \ No newline at end of file +invalid json diff --git a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json index 0e52b5db292617..72989a50028dfd 100644 --- a/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json +++ b/lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json @@ -1,3 +1,3 @@ { "type": "not a nuget global.json" -} \ No newline at end of file +} diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index 837e579f66da91..c288c8582b7b22 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -113,17 +113,17 @@ describe('manager/nuget/extract', () => { await extractPackageFile(otherContents, otherPackageFile, config) ).toMatchSnapshot(); }); + it('extracts msbuild-sdks from global.json', async () => { const packageFile = 'msbuild-sdk-files/global.json'; const contents = loadFixture(packageFile); - // FIXME: explicit assert condition expect(await extractPackageFile(contents, packageFile, config)) .toMatchInlineSnapshot(` Object { "deps": Array [ Object { "currentValue": "0", - "datasource": null, + "datasource": "nuget", "depName": "YoloDev.Sdk", "depType": "nuget", "skipReason": "unsupported-datasource", @@ -132,18 +132,18 @@ describe('manager/nuget/extract', () => { } `); }); + it('handles malformed global.json', async () => { const packageFile = 'msbuild-sdk-files/invalid-json/global.json'; const contents = loadFixture(packageFile); - // FIXME: explicit assert condition expect( await extractPackageFile(contents, packageFile, config) ).toBeNull(); }); + it('handles not-a-nuget global.json', async () => { const packageFile = 'msbuild-sdk-files/not-nuget/global.json'; const contents = loadFixture(packageFile); - // FIXME: explicit assert condition expect( await extractPackageFile(contents, packageFile, config) ).toBeNull(); diff --git a/lib/manager/nuget/extract.ts b/lib/manager/nuget/extract.ts index 30fd4e26dacadc..f4d3af4cb25809 100644 --- a/lib/manager/nuget/extract.ts +++ b/lib/manager/nuget/extract.ts @@ -2,11 +2,11 @@ import { XmlDocument, XmlElement, XmlNode } from 'xmldoc'; import { getGlobalConfig } from '../../config/global'; import * as datasourceNuget from '../../datasource/nuget'; import { logger } from '../../logger'; -import { SkipReason } from '../../types'; import { getSiblingFileName, localPathExists } from '../../util/fs'; import { hasKey } from '../../util/object'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; -import type { DotnetToolsManifest, MsbuildGlobalManifest } from './types'; +import { extractMsbuildGlobalManifest } from './extract/global-manifest'; +import type { DotnetToolsManifest } from './types'; import { getConfiguredRegistries } from './util'; /** @@ -114,39 +114,7 @@ export async function extractPackageFile( } if (packageFile.endsWith('global.json')) { - const deps: PackageDependency[] = []; - let manifest: MsbuildGlobalManifest; - - try { - manifest = JSON.parse(content); - } catch (err) { - logger.debug({ fileName: packageFile }, 'Invalid JSON'); - return null; - } - - if (manifest['msbuild-sdks'] === undefined) { - logger.debug( - { fileName: packageFile }, - 'This global.json is not a Nuget file' - ); - return null; - } - - for (const depName of Object.keys(manifest['msbuild-sdks'])) { - const sdk = manifest['msbuild-sdks'][depName]; - const currentValue = sdk[0]; - const dep: PackageDependency = { - depType: 'nuget', - depName, - currentValue, - datasource: null, - skipReason: SkipReason.UnsupportedDatasource, - }; - - deps.push(dep); - } - - return { deps }; + return extractMsbuildGlobalManifest(content, packageFile); } let deps: PackageDependency[] = []; diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts new file mode 100644 index 00000000000000..276f0db0eae70e --- /dev/null +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -0,0 +1,44 @@ +import * as datasourceNuget from '../../../datasource/nuget'; +import { logger } from '../../../logger'; +import { SkipReason } from '../../../types'; +import type { PackageDependency, PackageFile } from '../../types'; +import type { MsbuildGlobalManifest } from '../types'; + +export function extractMsbuildGlobalManifest( + content: string, + packageFile: string +): PackageFile | null { + const deps: PackageDependency[] = []; + let manifest: MsbuildGlobalManifest; + + try { + manifest = JSON.parse(content); + } catch (err) { + logger.debug({ fileName: packageFile }, 'Invalid JSON'); + return null; + } + + if (!manifest['msbuild-sdks'] && (!manifest.sdk || !manifest.sdk.version)) { + logger.debug( + { fileName: packageFile }, + 'This global.json is not a Nuget file' + ); + return null; + } + + for (const depName of Object.keys(manifest['msbuild-sdks'])) { + const sdk = manifest['msbuild-sdks'][depName]; + const currentValue = sdk[0]; + const dep: PackageDependency = { + depType: 'nuget', + depName, + currentValue, + datasource: datasourceNuget.id, + skipReason: SkipReason.UnsupportedDatasource, + }; + + deps.push(dep); + } + + return { deps }; +} From 62ace71b1c3cbb6c6b36d943c6a0705fa77410fd Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 14:35:12 +0700 Subject: [PATCH 04/10] Applying suggestions of viceice --- lib/manager/nuget/extract/global-manifest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index 276f0db0eae70e..f5bcc80d05b174 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -18,7 +18,7 @@ export function extractMsbuildGlobalManifest( return null; } - if (!manifest['msbuild-sdks'] && (!manifest.sdk || !manifest.sdk.version)) { + if (!manifest['msbuild-sdks'] && !manifest.sdk?.version) { logger.debug( { fileName: packageFile }, 'This global.json is not a Nuget file' From 5113bcc23069c009aab4f30b5a7c261309f63005 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 14:45:32 +0700 Subject: [PATCH 05/10] Update lib/manager/nuget/extract/global-manifest.ts Co-authored-by: Michael Kriese --- lib/manager/nuget/extract/global-manifest.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index f5bcc80d05b174..6da7a746491c89 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -25,6 +25,15 @@ export function extractMsbuildGlobalManifest( ); return null; } + + if (manifest.sdk?.version) { + deps.push({ + depType: 'sdk', + depName: 'dotnet-sdk', + currentValue: manifest.sdk?.version, + skipReason: SkipReason.UnsupportedDatasource, + }); + } for (const depName of Object.keys(manifest['msbuild-sdks'])) { const sdk = manifest['msbuild-sdks'][depName]; From 536f68149a0a11584172c0625200932964e33e15 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 14:46:20 +0700 Subject: [PATCH 06/10] Update lib/manager/nuget/extract/global-manifest.ts Co-authored-by: Michael Kriese --- lib/manager/nuget/extract/global-manifest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index 6da7a746491c89..26f9f42364e04e 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -39,7 +39,7 @@ export function extractMsbuildGlobalManifest( const sdk = manifest['msbuild-sdks'][depName]; const currentValue = sdk[0]; const dep: PackageDependency = { - depType: 'nuget', + depType: 'sdk', depName, currentValue, datasource: datasourceNuget.id, From 31940f2bbf465710e16ce6920c4b9994b16bef17 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 14:49:04 +0700 Subject: [PATCH 07/10] Update lib/manager/nuget/extract/global-manifest.ts Co-authored-by: Michael Kriese --- lib/manager/nuget/extract/global-manifest.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index 26f9f42364e04e..8effd5f1335f24 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -43,7 +43,6 @@ export function extractMsbuildGlobalManifest( depName, currentValue, datasource: datasourceNuget.id, - skipReason: SkipReason.UnsupportedDatasource, }; deps.push(dep); From 4497104a2bc20bc8d431a2095090d9127ba65e73 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 15:09:08 +0700 Subject: [PATCH 08/10] Fixing tests after applying reviewer suggestions --- lib/manager/nuget/extract.spec.ts | 9 +++++++-- lib/manager/nuget/extract/global-manifest.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index c288c8582b7b22..1305c70dc34d7f 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -121,12 +121,17 @@ describe('manager/nuget/extract', () => { .toMatchInlineSnapshot(` Object { "deps": Array [ + Object { + "currentValue": "5.0.302", + "depName": "dotnet-sdk", + "depType": "sdk", + "skipReason": "unsupported-datasource", + }, Object { "currentValue": "0", "datasource": "nuget", "depName": "YoloDev.Sdk", - "depType": "nuget", - "skipReason": "unsupported-datasource", + "depType": "sdk", }, ], } diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index 8effd5f1335f24..c3c231e2b00741 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -25,7 +25,7 @@ export function extractMsbuildGlobalManifest( ); return null; } - + if (manifest.sdk?.version) { deps.push({ depType: 'sdk', From f61fca938c995fc751a7f913995baa16f50858b2 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 18:15:08 +0700 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Michael Kriese --- lib/manager/nuget/extract.spec.ts | 4 ++-- lib/manager/nuget/extract/global-manifest.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index 1305c70dc34d7f..b030c020c6fe69 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -124,14 +124,14 @@ describe('manager/nuget/extract', () => { Object { "currentValue": "5.0.302", "depName": "dotnet-sdk", - "depType": "sdk", + "depType": "dotnet-sdk", "skipReason": "unsupported-datasource", }, Object { "currentValue": "0", "datasource": "nuget", "depName": "YoloDev.Sdk", - "depType": "sdk", + "depType": "msbuild-sdk", }, ], } diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index c3c231e2b00741..e57285eff69cef 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -28,7 +28,7 @@ export function extractMsbuildGlobalManifest( if (manifest.sdk?.version) { deps.push({ - depType: 'sdk', + depType: 'dotnet-sdk', depName: 'dotnet-sdk', currentValue: manifest.sdk?.version, skipReason: SkipReason.UnsupportedDatasource, @@ -39,7 +39,7 @@ export function extractMsbuildGlobalManifest( const sdk = manifest['msbuild-sdks'][depName]; const currentValue = sdk[0]; const dep: PackageDependency = { - depType: 'sdk', + depType: 'msbuild-sdk', depName, currentValue, datasource: datasourceNuget.id, From 385765162c7748007463f6f82227e60d08503c47 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Tue, 14 Sep 2021 18:16:47 +0700 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Michael Kriese --- lib/manager/nuget/extract.spec.ts | 2 +- lib/manager/nuget/extract/global-manifest.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/manager/nuget/extract.spec.ts b/lib/manager/nuget/extract.spec.ts index b030c020c6fe69..59099efb8d6c5f 100644 --- a/lib/manager/nuget/extract.spec.ts +++ b/lib/manager/nuget/extract.spec.ts @@ -128,7 +128,7 @@ describe('manager/nuget/extract', () => { "skipReason": "unsupported-datasource", }, Object { - "currentValue": "0", + "currentValue": "0.2.0", "datasource": "nuget", "depName": "YoloDev.Sdk", "depType": "msbuild-sdk", diff --git a/lib/manager/nuget/extract/global-manifest.ts b/lib/manager/nuget/extract/global-manifest.ts index e57285eff69cef..48fe0a1939adba 100644 --- a/lib/manager/nuget/extract/global-manifest.ts +++ b/lib/manager/nuget/extract/global-manifest.ts @@ -36,8 +36,7 @@ export function extractMsbuildGlobalManifest( } for (const depName of Object.keys(manifest['msbuild-sdks'])) { - const sdk = manifest['msbuild-sdks'][depName]; - const currentValue = sdk[0]; + const currentValue = manifest['msbuild-sdks'][depName]; const dep: PackageDependency = { depType: 'msbuild-sdk', depName,