Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager/nuget): update msbuild-sdks section in global.json (#11707)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
1 parent
03ac68e
commit 196df0d
Showing
9 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"sdk": { | ||
"version": "5.0.302", | ||
"rollForward": "latestMajor" | ||
}, | ||
"msbuild-sdks": { | ||
"YoloDev.Sdk": "0.2.0" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
lib/manager/nuget/__fixtures__/msbuild-sdk-files/invalid-json/global.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invalid json |
3 changes: 3 additions & 0 deletions
3
lib/manager/nuget/__fixtures__/msbuild-sdk-files/not-nuget/global.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "not a nuget global.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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?.version) { | ||
logger.debug( | ||
{ fileName: packageFile }, | ||
'This global.json is not a Nuget file' | ||
); | ||
return null; | ||
} | ||
|
||
if (manifest.sdk?.version) { | ||
deps.push({ | ||
depType: 'dotnet-sdk', | ||
depName: 'dotnet-sdk', | ||
currentValue: manifest.sdk?.version, | ||
skipReason: SkipReason.UnsupportedDatasource, | ||
}); | ||
} | ||
|
||
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); | ||
} | ||
|
||
return { deps }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters