Skip to content

Commit

Permalink
Merge pull request #23 from Dryadxon/central-package-managment-support
Browse files Browse the repository at this point in the history
Added support for Central Package Management
  • Loading branch information
kuiperzone committed Apr 6, 2023
2 parents 8543203 + 8fa3346 commit 3fadc80
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions AvantGarde/Projects/DotnetProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ private static string GetAvaloniaVersion(XElement? root)
{
if (root != null)
{
if (root.Name.LocalName == "PackageReference")
if (root.Name.LocalName == "PackageReference" || root.Name.LocalName == "PackageVersion")
{
foreach (var a0 in root.Attributes())
{
if (a0.Name.LocalName == "Include" && a0.Value == "Avalonia")
{
foreach (var a1 in root.Attributes())
{
if (a1.Name.LocalName == "Version")
if (a1.Name.LocalName == "Version" || a1.Name.LocalName == "VersionOverride")
{
return a1.Value;
}
Expand All @@ -261,6 +261,23 @@ private static string GetAvaloniaVersion(XElement? root)
return string.Empty;
}

private XDocument? GetDirectoryPackages()
{
var root = Solution.GetFileInfo().Directory;
var current = GetFileInfo().Directory;
while (current != null && current != root)
{
var path = Path.Combine(current.FullName, "Directory.Packages.props");
var item = new PathItem(path, PathKind.Xml);
if (item.Exists)
{
return XDocument.Parse(item.ReadAsText());
}
current = current.Parent;
}
return null;
}

private ProjectError? ParseProject()
{
try
Expand All @@ -275,6 +292,15 @@ private static string GetAvaloniaVersion(XElement? root)
TargetFramework = GetElementValue(doc.Root, "TargetFramework");
AvaloniaVersion = GetAvaloniaVersion(doc.Root);

if (string.IsNullOrWhiteSpace(AvaloniaVersion))
{
doc = GetDirectoryPackages();
if (doc != null)
{
AvaloniaVersion = GetAvaloniaVersion(doc.Root);
}
}

if (OutputType.Length == 0)
{
OutputType = "Library";
Expand Down Expand Up @@ -371,4 +397,4 @@ private static string GetAvaloniaVersion(XElement? root)
}

}
}
}

0 comments on commit 3fadc80

Please sign in to comment.