Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/nuget): validate msbuild sdks #11750

Merged
merged 2 commits into from Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "5.0.302",
"rollForward": "latestMajor"
}
}
54 changes: 35 additions & 19 deletions lib/manager/nuget/extract.spec.ts
Expand Up @@ -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 () => {
Expand Down
20 changes: 11 additions & 9 deletions lib/manager/nuget/extract/global-manifest.ts
Expand Up @@ -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 };
Expand Down
6 changes: 4 additions & 2 deletions 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.
4 changes: 2 additions & 2 deletions lib/manager/nuget/types.ts
Expand Up @@ -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 {
Expand Down