Skip to content
Permalink
Browse files
fix(manager/nuget): validate msbuild sdks (#11750)
  • Loading branch information
viceice committed Sep 15, 2021
1 parent 196df0d commit d05137fbf9c49980742688461b566d554065266b
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "5.0.302",
"rollForward": "latestMajor"
}
}
@@ -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 () => {
@@ -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 };
@@ -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.
@@ -16,8 +16,8 @@ export interface Registry {
}

export interface MsbuildGlobalManifest {
readonly sdk: MsbuildSdk;
readonly 'msbuild-sdks': Record<string, string>;
readonly sdk?: MsbuildSdk;
readonly 'msbuild-sdks'?: Record<string, string>;
}

export interface MsbuildSdk {

0 comments on commit d05137f

Please sign in to comment.