Skip to content

Commit

Permalink
fix(nuget): parse nested conditional deps (#9035)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Mar 8, 2021
1 parent d6fcf01 commit 0585f2d
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 89 deletions.
12 changes: 12 additions & 0 deletions lib/manager/nuget/__fixtures__/sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,16 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Choose>
<When Condition="some-condition-like-exists">
<ItemGroup>
<ProjectReference Include="My.Package.csproj" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="My.Package" Version="1.0.0" />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
158 changes: 82 additions & 76 deletions lib/manager/nuget/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`lib/manager/nuget/extract extractPackageFile() .config/dotnet-tools.json with-config 1`] = `
exports[`manager/nuget/extract extractPackageFile() .config/dotnet-tools.json with-config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -17,7 +17,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() .config/dotnet-tools.json works 1`] = `
exports[`manager/nuget/extract extractPackageFile() .config/dotnet-tools.json works 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -30,7 +30,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() considers NuGet.config 1`] = `
exports[`manager/nuget/extract extractPackageFile() considers NuGet.config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -47,7 +47,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() considers lower-case nuget.config 1`] = `
exports[`manager/nuget/extract extractPackageFile() considers lower-case nuget.config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -64,7 +64,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() considers pascal-case NuGet.Config 1`] = `
exports[`manager/nuget/extract extractPackageFile() considers pascal-case NuGet.Config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -81,54 +81,54 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts all dependencies 1`] = `
exports[`manager/nuget/extract extractPackageFile() extracts all dependencies 1`] = `
Array [
Object {
"currentValue": "4.5.0",
"currentValue": "1.0.0",
"datasource": "nuget",
"depName": "Autofac",
"depName": "My.Package",
"depType": "nuget",
},
Object {
"currentValue": "4.1.0",
"currentValue": "1.0.0",
"datasource": "nuget",
"depName": "Autofac.Extensions.DependencyInjection",
"depName": "Microsoft.VisualStudio.Web.CodeGeneration.Tools",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Hosting",
"depName": "Range3",
"depType": "nuget",
},
Object {
"currentValue": "1.1.3",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Mvc.Core",
"depName": "Range2",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Server.Kestrel",
"depName": "Range1",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "3.1.0.5",
"datasource": "nuget",
"depName": "Microsoft.Extensions.Configuration.Json",
"depName": "Stateless",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "2.1.0",
"datasource": "nuget",
"depName": "Microsoft.Extensions.Logging.Debug",
"depName": "Serilog.Sinks.Literate",
"depType": "nuget",
},
Object {
"currentValue": "10.0.2",
"currentValue": "1.4.0",
"datasource": "nuget",
"depName": "Newtonsoft.Json",
"depName": "Serilog.Extensions.Logging",
"depType": "nuget",
},
Object {
Expand All @@ -138,98 +138,104 @@ Array [
"depType": "nuget",
},
Object {
"currentValue": "1.4.0",
"currentValue": "10.0.2",
"datasource": "nuget",
"depName": "Serilog.Extensions.Logging",
"depName": "Newtonsoft.Json",
"depType": "nuget",
},
Object {
"currentValue": "2.1.0",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Serilog.Sinks.Literate",
"depName": "Microsoft.Extensions.Logging.Debug",
"depType": "nuget",
},
Object {
"currentValue": "3.1.0.5",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Stateless",
"depName": "Microsoft.Extensions.Configuration.Json",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Range1",
"depName": "Microsoft.AspNetCore.Server.Kestrel",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "1.1.3",
"datasource": "nuget",
"depName": "Range2",
"depName": "Microsoft.AspNetCore.Mvc.Core",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Range3",
"depName": "Microsoft.AspNetCore.Hosting",
"depType": "nuget",
},
Object {
"currentValue": "1.0.0",
"currentValue": "4.1.0",
"datasource": "nuget",
"depName": "Microsoft.VisualStudio.Web.CodeGeneration.Tools",
"depName": "Autofac.Extensions.DependencyInjection",
"depType": "nuget",
},
Object {
"currentValue": "4.5.0",
"datasource": "nuget",
"depName": "Autofac",
"depType": "nuget",
},
]
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts all dependencies from global packages file 1`] = `
exports[`manager/nuget/extract extractPackageFile() extracts all dependencies from global packages file 1`] = `
Array [
Object {
"currentValue": "2.0.0",
"currentValue": "1.0.0",
"datasource": "nuget",
"depName": "Roslynator.Analyzers",
"depName": "Microsoft.VisualStudio.Web.CodeGeneration.Tools",
"depType": "nuget",
},
Object {
"currentValue": "4.5.0",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Autofac",
"depName": "Range3",
"depType": "nuget",
},
Object {
"currentValue": "4.1.0",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Autofac.Extensions.DependencyInjection",
"depName": "Range2",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "1.2.3",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Hosting",
"depName": "Range1",
"depType": "nuget",
},
Object {
"currentValue": "1.1.3",
"currentValue": "3.1.0.5",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Mvc.Core",
"depName": "Stateless",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "2.1.0",
"datasource": "nuget",
"depName": "Microsoft.AspNetCore.Server.Kestrel",
"depName": "Serilog.Sinks.Literate",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "1.4.0",
"datasource": "nuget",
"depName": "Microsoft.Extensions.Configuration.Json",
"depName": "Serilog.Extensions.Logging",
"depType": "nuget",
},
Object {
"currentValue": "1.1.2",
"currentValue": "2.4.0",
"datasource": "nuget",
"depName": "Microsoft.Extensions.Logging.Debug",
"depName": "Serilog",
"depType": "nuget",
},
Object {
Expand All @@ -239,57 +245,57 @@ Array [
"depType": "nuget",
},
Object {
"currentValue": "2.4.0",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Serilog",
"depName": "Microsoft.Extensions.Logging.Debug",
"depType": "nuget",
},
Object {
"currentValue": "1.4.0",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Serilog.Extensions.Logging",
"depName": "Microsoft.Extensions.Configuration.Json",
"depType": "nuget",
},
Object {
"currentValue": "2.1.0",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Serilog.Sinks.Literate",
"depName": "Microsoft.AspNetCore.Server.Kestrel",
"depType": "nuget",
},
Object {
"currentValue": "3.1.0.5",
"currentValue": "1.1.3",
"datasource": "nuget",
"depName": "Stateless",
"depName": "Microsoft.AspNetCore.Mvc.Core",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "1.1.2",
"datasource": "nuget",
"depName": "Range1",
"depName": "Microsoft.AspNetCore.Hosting",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "4.1.0",
"datasource": "nuget",
"depName": "Range2",
"depName": "Autofac.Extensions.DependencyInjection",
"depType": "nuget",
},
Object {
"currentValue": "1.2.3",
"currentValue": "4.5.0",
"datasource": "nuget",
"depName": "Range3",
"depName": "Autofac",
"depType": "nuget",
},
Object {
"currentValue": "1.0.0",
"currentValue": "2.0.0",
"datasource": "nuget",
"depName": "Microsoft.VisualStudio.Web.CodeGeneration.Tools",
"depName": "Roslynator.Analyzers",
"depType": "nuget",
},
]
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts package version dependency 1`] = `
exports[`manager/nuget/extract extractPackageFile() extracts package version dependency 1`] = `
Array [
Object {
"currentValue": "4.5.0",
Expand All @@ -300,7 +306,7 @@ Array [
]
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts registry URLs independently 1`] = `
exports[`manager/nuget/extract extractPackageFile() extracts registry URLs independently 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -317,7 +323,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() extracts registry URLs independently 2`] = `
exports[`manager/nuget/extract extractPackageFile() extracts registry URLs independently 2`] = `
Object {
"deps": Array [
Object {
Expand All @@ -334,7 +340,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() handles NuGet.config without package sources 1`] = `
exports[`manager/nuget/extract extractPackageFile() handles NuGet.config without package sources 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -347,7 +353,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() handles malformed NuGet.config 1`] = `
exports[`manager/nuget/extract extractPackageFile() handles malformed NuGet.config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -360,7 +366,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() ignores local feed in NuGet.config 1`] = `
exports[`manager/nuget/extract extractPackageFile() ignores local feed in NuGet.config 1`] = `
Object {
"deps": Array [
Object {
Expand All @@ -376,7 +382,7 @@ Object {
}
`;

exports[`lib/manager/nuget/extract extractPackageFile() returns empty for invalid csproj 1`] = `
exports[`manager/nuget/extract extractPackageFile() returns empty for invalid csproj 1`] = `
Object {
"deps": Array [],
}
Expand Down
Loading

0 comments on commit 0585f2d

Please sign in to comment.