Skip to content

Commit

Permalink
Replace obsolete nuget api in Microsoft.DotNet.PackageValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
akoeplinger committed Aug 2, 2024
1 parent f6365c6 commit e9bd460
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public Package(string packagePath,
_contentItemCollection = new ContentItemCollection();
_contentItemCollection.Load(packageAssets);

PackageAssets = _contentItemCollection.FindItems(_conventions.Patterns.AnyTargettedFile);
RefAssets = _contentItemCollection.FindItems(_conventions.Patterns.CompileRefAssemblies);
LibAssets = _contentItemCollection.FindItems(_conventions.Patterns.CompileLibAssemblies);
PackageAssets = GetContentItemsFromPattern(_conventions.Patterns.AnyTargettedFile);
RefAssets = GetContentItemsFromPattern(_conventions.Patterns.CompileRefAssemblies);
LibAssets = GetContentItemsFromPattern(_conventions.Patterns.CompileLibAssemblies);
CompileAssets = RefAssets.Any() ? RefAssets : LibAssets;
RuntimeAssets = _contentItemCollection.FindItems(_conventions.Patterns.RuntimeAssemblies);
RuntimeAssets = GetContentItemsFromPattern(_conventions.Patterns.RuntimeAssemblies);
RuntimeSpecificAssets = RuntimeAssets.Where(t => t.Path.StartsWith("runtimes")).ToArray();
Rids = RuntimeSpecificAssets.Select(t => (string)t.Properties["rid"])
.Distinct()
Expand All @@ -108,6 +108,13 @@ public Package(string packagePath,
.Distinct()
.ToArray();
AssemblyReferences = assemblyReferences;

IEnumerable<ContentItem> GetContentItemsFromPattern(PatternSet pattern)
{
List<ContentItemGroup> itemGroups = new();
_contentItemCollection.PopulateItemGroups(pattern, itemGroups);
return itemGroups.SelectMany(i => i.Items).ToArray();
}
}

public static void InitializeRuntimeGraph(string runtimeGraph)
Expand Down

0 comments on commit e9bd460

Please sign in to comment.