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 dotnet project.assets dependency tree #638

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4702,7 +4702,7 @@ export const parseCsProjAssetsData = async function (csProjData) {
// extract name, operator, version from .NET package representation
// like "NLog >= 4.5.0"
function extractNameOperatorVersion(inputStr) {
const extractNameOperatorVersion = /([\w.]+)\s*([><=!]+)\s*([\d.]+)/;
const extractNameOperatorVersion = /([\w.-]+)\s*([><=!]+)\s*([\d.]+)/;
const match = inputStr.match(extractNameOperatorVersion);

if (match) {
Expand Down Expand Up @@ -4813,7 +4813,7 @@ export const parseCsProjAssetsData = async function (csProjData) {
}
}
pkgList.push(pkg);
pkgNameVersionMap[name] = version;
pkgNameVersionMap[name + framework] = version;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

pkgAddedMap[name] = true;
}
}
Expand All @@ -4830,10 +4830,10 @@ export const parseCsProjAssetsData = async function (csProjData) {
if (dependencies) {
for (const p of Object.keys(dependencies)) {
// This condition is not required for assets json that are well-formed.
if (!pkgNameVersionMap[p]) {
if (!pkgNameVersionMap[p + framework]) {
continue;
}
let dversion = pkgNameVersionMap[p];
let dversion = pkgNameVersionMap[p + framework];
const ipurl = decodeURIComponent(
new PackageURL("nuget", "", p, dversion, null, null).toString()
);
Expand Down
3 changes: 3 additions & 0 deletions utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,9 @@ test("parse project.assets.json", async () => {
expect(dep_list["dependenciesList"][0]).toEqual({
dependsOn: [
"pkg:nuget/Castle.Core@0.0.0",
"pkg:nuget/Castle.Core-NLog@0.0.0",
"pkg:nuget/Castle.Core-Serilog@0.0.0",
"pkg:nuget/Castle.Core-log4net@0.0.0",
"pkg:nuget/Microsoft.NET.Test.Sdk@17.1.0",
"pkg:nuget/Microsoft.NETCore.App@2.1.0",
"pkg:nuget/Microsoft.NETFramework.ReferenceAssemblies@1.0.0",
Expand Down