Skip to content

Commit

Permalink
241 new feature explore possible nuget package installation during ix…
Browse files Browse the repository at this point in the history
…c run from apax package (#243)

* Create draft PR for #241

* [wip] installs project and package dependencies from apax.yml into twin companion project

* fixes an issue with ixr where wrong default cli parameter was set

* fixes an issue when existing package reference was not found in csproj file

---------

Co-authored-by: PTKu <PTKu@users.noreply.github.com>
  • Loading branch information
PTKu and PTKu authored Oct 5, 2023
1 parent 993ea1d commit 854308a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 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\\"
}
}
}
2 changes: 1 addition & 1 deletion src/AXSharp.compiler/src/ixd/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class Options : ICompilerOptions
public bool NoDependencyUpdate { get; set; }

[Option('p', "project-file", Required = false, Default = "",
HelpText = "Output project file")]
HelpText = "(ignored here)Output project file")]
public string? ProjectFile { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/AXSharp.compiler/src/ixr/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ internal class Options : ICompilerOptions
[Option('o', "output-project-folder", Required = false, HelpText = "Output project folder where compiler emits result.")]
public string? OutputProjectFolder { get; set; }

[Option('p', "project-file", Required = false, Default = false,
[Option('p', "project-file", Required = false, Default = "",
HelpText = "Output project file")]
public string? ProjectFile { get; set; }

[Option('b', "use-base-symbol", Required = false, Default = "",
[Option('b', "use-base-symbol", Required = false, Default = false,
HelpText = "Will use base symbol in inherited types")]
public bool UseBase { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/AXSharp.compiler/src/ixr/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
},
"Profile 1": {
"commandName": "Project"
},
"app-withref": {
"commandName": "Project",
"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\axopen.templates\\templates.simple\\app\\"
}
}
}

0 comments on commit 854308a

Please sign in to comment.