Skip to content

Commit

Permalink
fixes an issue when existing package reference was not found in cspro…
Browse files Browse the repository at this point in the history
…j file
  • Loading branch information
PTKu committed Oct 5, 2023
1 parent 41bce43 commit 9be0ec0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,14 @@ private static bool PackageReferenceExists(string projectFilePath, string packag
var package
= PackageReference.GetVersionFromCentralPackageManagement(projectFilePath)?
.FirstOrDefault(p => p.include == packageName);


// Using XPath to search for the PackageReference with a specific Include attribute and Version child element

return xDocument.XPathSelectElements(
$"//PackageReference[@Include='{packageName}']/Version[text()='{version}']").Any()
||
(xDocument.XPathSelectElements(
var hasWithVersion = xDocument.XPathSelectElements($"//PackageReference[@Include='{packageName}' and @Version='{version}']").Any();

var hasVersionInCentralPackageManagement = (xDocument.XPathSelectElements(
$"//PackageReference[@Include='{packageName}']").Any() && package != null && package?.version == version);

return hasWithVersion || hasVersionInCentralPackageManagement;

}

private static void AddNuGetPackageReference(string projectPath, string packageName, string version = null)
Expand Down
8 changes: 6 additions & 2 deletions src/AXSharp.compiler/src/ixc/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
"workingDirectory": "C:\\W\\Develop\\gh\\ix-ax\\axsharp\\src\\AXSharp.connectors\\tests\\ax-test-project\\"
},
"app-withref": {
"commandName": "Project",
"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\axopen\\src\\.application\\app\\"
"commandName": "Project",
"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\axopen.templates\\templates.simple\\app\\"
},
"app-withref-cpm": {
"commandName": "Project",
"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\axopen\\src\\templates.simple\\app\\"
}
}
}

0 comments on commit 9be0ec0

Please sign in to comment.