From 61031066a8740d8cd199e6e9a255711572efdaaf Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Tue, 23 Mar 2021 11:13:43 -0700 Subject: [PATCH 1/5] Refactor GenerateRuntimeGraph into multiple files --- .../src/GenerateRuntimeGraph.cs | 306 ------------------ .../src/RID.cs | 58 ++++ .../src/RuntimeGroup.cs | 265 +++++++++++++++ 3 files changed, 323 insertions(+), 306 deletions(-) create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs index 7948abe8db1..eccdfd0d4de 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs @@ -4,12 +4,10 @@ using Microsoft.Build.Framework; using Newtonsoft.Json; using NuGet.RuntimeModel; -using NuGet.Versioning; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Xml.Linq; namespace Microsoft.DotNet.Build.Tasks.Packaging @@ -273,310 +271,6 @@ private void ValidateImports(RuntimeGraph runtimeGraph, IDictionary(item.GetStrings(nameof(OmitRIDs))); - OmitRIDDefinitions = new HashSet(item.GetStrings(nameof(OmitRIDDefinitions))); - OmitRIDReferences = new HashSet(item.GetStrings(nameof(OmitRIDReferences))); - } - - public string BaseRID { get; } - public string Parent { get; } - public IEnumerable Versions { get; } - public bool TreatVersionsAsCompatible { get; } - public bool OmitVersionDelimiter { get; } - public bool ApplyVersionsToParent { get; } - public IEnumerable Architectures { get; } - public IEnumerable AdditionalQualifiers { get; } - public ICollection OmitRIDs { get; } - public ICollection OmitRIDDefinitions { get; } - public ICollection OmitRIDReferences { get; } - - private class RIDMapping - { - public RIDMapping(RID runtimeIdentifier) - { - RuntimeIdentifier = runtimeIdentifier; - Imports = Enumerable.Empty(); - } - - public RIDMapping(RID runtimeIdentifier, IEnumerable imports) - { - RuntimeIdentifier = runtimeIdentifier; - Imports = imports; - } - - public RID RuntimeIdentifier { get; } - - public IEnumerable Imports { get; } - } - - private class RID - { - public string BaseRID { get; set; } - public string VersionDelimiter { get; set; } - public string Version { get; set; } - public string ArchitectureDelimiter { get; set; } - public string Architecture { get; set; } - public string QualifierDelimiter { get; set; } - public string Qualifier { get; set; } - - public override string ToString() - { - StringBuilder builder = new StringBuilder(BaseRID); - - if (HasVersion()) - { - builder.Append(VersionDelimiter); - builder.Append(Version); - } - - if (HasArchitecture()) - { - builder.Append(ArchitectureDelimiter); - builder.Append(Architecture); - } - - if (HasQualifier()) - { - builder.Append(QualifierDelimiter); - builder.Append(Qualifier); - } - - return builder.ToString(); - } - - public bool HasVersion() - { - return Version != null; - } - - public bool HasArchitecture() - { - return Architecture != null; - } - - public bool HasQualifier() - { - return Qualifier != null; - } - } - - private RID CreateRuntime(string baseRid, string version = null, string architecture = null, string qualifier = null) - { - return new RID() - { - BaseRID = baseRid, - VersionDelimiter = OmitVersionDelimiter ? String.Empty : VersionDelimiter.ToString(), - Version = version, - ArchitectureDelimiter = ArchitectureDelimiter.ToString(), - Architecture = architecture, - QualifierDelimiter = QualifierDelimiter.ToString(), - Qualifier = qualifier - }; - } - - private IEnumerable GetRIDMappings() - { - // base => - // Parent - yield return Parent == null ? - new RIDMapping(CreateRuntime(BaseRID)) : - new RIDMapping(CreateRuntime(BaseRID), new[] { CreateRuntime(Parent) }); - - foreach (var architecture in Architectures) - { - // base + arch => - // base, - // parent + arch - var imports = new List() - { - CreateRuntime(BaseRID) - }; - - if (!IsNullOrRoot(Parent)) - { - imports.Add(CreateRuntime(Parent, architecture: architecture)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, architecture: architecture), imports); - } - - string lastVersion = null; - foreach (var version in Versions) - { - // base + version => - // base + lastVersion, - // parent + version (optionally) - var imports = new List() - { - CreateRuntime(BaseRID, version: lastVersion) - }; - - if (ApplyVersionsToParent) - { - imports.Add(CreateRuntime(Parent, version: version)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, version: version), imports); - - foreach (var architecture in Architectures) - { - // base + version + architecture => - // base + version, - // base + lastVersion + architecture, - // parent + version + architecture (optionally) - var archImports = new List() - { - CreateRuntime(BaseRID, version: version), - CreateRuntime(BaseRID, version: lastVersion, architecture: architecture) - }; - - if (ApplyVersionsToParent) - { - archImports.Add(CreateRuntime(Parent, version: version, architecture: architecture)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, version: version, architecture: architecture), archImports); - } - - if (TreatVersionsAsCompatible) - { - lastVersion = version; - } - } - - foreach (var qualifier in AdditionalQualifiers) - { - // base + qual => - // base, - // parent + qual - yield return new RIDMapping(CreateRuntime(BaseRID, qualifier: qualifier), - new[] - { - CreateRuntime(BaseRID), - IsNullOrRoot(Parent) ? CreateRuntime(qualifier) : CreateRuntime(Parent, qualifier:qualifier) - }); - - foreach (var architecture in Architectures) - { - // base + arch + qualifier => - // base + qualifier, - // base + arch - // parent + arch + qualifier - var imports = new List() - { - CreateRuntime(BaseRID, qualifier: qualifier), - CreateRuntime(BaseRID, architecture: architecture) - }; - - if (!IsNullOrRoot(Parent)) - { - imports.Add(CreateRuntime(Parent, architecture: architecture, qualifier: qualifier)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, architecture: architecture, qualifier: qualifier), imports); - } - - lastVersion = null; - foreach (var version in Versions) - { - // base + version + qualifier => - // base + version, - // base + lastVersion + qualifier - // parent + version + qualifier (optionally) - var imports = new List() - { - CreateRuntime(BaseRID, version: version), - CreateRuntime(BaseRID, version: lastVersion, qualifier: qualifier) - }; - - if (ApplyVersionsToParent) - { - imports.Add(CreateRuntime(Parent, version: version, qualifier: qualifier)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, version: version, qualifier: qualifier), imports); - - foreach (var architecture in Architectures) - { - // base + version + architecture + qualifier => - // base + version + qualifier, - // base + version + architecture, - // base + version, - // base + lastVersion + architecture + qualifier, - // parent + version + architecture + qualifier (optionally) - var archImports = new List() - { - CreateRuntime(BaseRID, version: version, qualifier: qualifier), - CreateRuntime(BaseRID, version: version, architecture: architecture), - CreateRuntime(BaseRID, version: version), - CreateRuntime(BaseRID, version: lastVersion, architecture: architecture, qualifier: qualifier) - }; - - if (ApplyVersionsToParent) - { - imports.Add(CreateRuntime(Parent, version: version, architecture: architecture, qualifier: qualifier)); - } - - yield return new RIDMapping(CreateRuntime(BaseRID, version: version, architecture: architecture, qualifier: qualifier), archImports); - } - - if (TreatVersionsAsCompatible) - { - lastVersion = version; - } - } - } - } - - private bool IsNullOrRoot(string rid) - { - return rid == null || rid == rootRID; - } - - - public IEnumerable GetRuntimeDescriptions() - { - foreach (var mapping in GetRIDMappings()) - { - var rid = mapping.RuntimeIdentifier.ToString(); - - if (OmitRIDs.Contains(rid) || OmitRIDDefinitions.Contains(rid)) - { - continue; - } - - var imports = mapping.Imports - .Select(i => i.ToString()) - .Where(i => !OmitRIDs.Contains(i) && !OmitRIDReferences.Contains(i)) - .ToArray(); - - yield return new RuntimeDescription(rid, imports); - } - } - - public RuntimeGraph GetRuntimeGraph() - { - return new RuntimeGraph(GetRuntimeDescriptions()); - } - } - private static IDictionary> GetCompatibilityMap(RuntimeGraph graph) { Dictionary> compatibilityMap = new Dictionary>(); diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs new file mode 100644 index 00000000000..1a1a8e82429 --- /dev/null +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text; + +namespace Microsoft.DotNet.Build.Tasks.Packaging +{ + internal class RID + { + public string BaseRID { get; set; } + public string VersionDelimiter { get; set; } + public string Version { get; set; } + public string ArchitectureDelimiter { get; set; } + public string Architecture { get; set; } + public string QualifierDelimiter { get; set; } + public string Qualifier { get; set; } + + public override string ToString() + { + StringBuilder builder = new StringBuilder(BaseRID); + + if (HasVersion()) + { + builder.Append(VersionDelimiter); + builder.Append(Version); + } + + if (HasArchitecture()) + { + builder.Append(ArchitectureDelimiter); + builder.Append(Architecture); + } + + if (HasQualifier()) + { + builder.Append(QualifierDelimiter); + builder.Append(Qualifier); + } + + return builder.ToString(); + } + + public bool HasVersion() + { + return Version != null; + } + + public bool HasArchitecture() + { + return Architecture != null; + } + + public bool HasQualifier() + { + return Qualifier != null; + } + } +} diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs new file mode 100644 index 00000000000..a2caf819f46 --- /dev/null +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs @@ -0,0 +1,265 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Build.Framework; +using NuGet.RuntimeModel; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Build.Tasks.Packaging +{ + internal class RuntimeGroup + { + private const string rootRID = "any"; + private const char VersionDelimiter = '.'; + private const char ArchitectureDelimiter = '-'; + private const char QualifierDelimiter = '-'; + + public RuntimeGroup(ITaskItem item) + { + BaseRID = item.ItemSpec; + Parent = item.GetString(nameof(Parent)); + Versions = item.GetStrings(nameof(Versions)); + TreatVersionsAsCompatible = item.GetBoolean(nameof(TreatVersionsAsCompatible), true); + OmitVersionDelimiter = item.GetBoolean(nameof(OmitVersionDelimiter)); + ApplyVersionsToParent = item.GetBoolean(nameof(ApplyVersionsToParent)); + Architectures = item.GetStrings(nameof(Architectures)); + AdditionalQualifiers = item.GetStrings(nameof(AdditionalQualifiers)); + OmitRIDs = new HashSet(item.GetStrings(nameof(OmitRIDs))); + OmitRIDDefinitions = new HashSet(item.GetStrings(nameof(OmitRIDDefinitions))); + OmitRIDReferences = new HashSet(item.GetStrings(nameof(OmitRIDReferences))); + } + + public string BaseRID { get; } + public string Parent { get; } + public IEnumerable Versions { get; } + public bool TreatVersionsAsCompatible { get; } + public bool OmitVersionDelimiter { get; } + public bool ApplyVersionsToParent { get; } + public IEnumerable Architectures { get; } + public IEnumerable AdditionalQualifiers { get; } + public ICollection OmitRIDs { get; } + public ICollection OmitRIDDefinitions { get; } + public ICollection OmitRIDReferences { get; } + + private class RIDMapping + { + public RIDMapping(RID runtimeIdentifier) + { + RuntimeIdentifier = runtimeIdentifier; + Imports = Enumerable.Empty(); + } + + public RIDMapping(RID runtimeIdentifier, IEnumerable imports) + { + RuntimeIdentifier = runtimeIdentifier; + Imports = imports; + } + + public RID RuntimeIdentifier { get; } + + public IEnumerable Imports { get; } + } + + private RID CreateRuntime(string baseRid, string version = null, string architecture = null, string qualifier = null) + { + return new RID() + { + BaseRID = baseRid, + VersionDelimiter = OmitVersionDelimiter ? String.Empty : VersionDelimiter.ToString(), + Version = version, + ArchitectureDelimiter = ArchitectureDelimiter.ToString(), + Architecture = architecture, + QualifierDelimiter = QualifierDelimiter.ToString(), + Qualifier = qualifier + }; + } + + private IEnumerable GetRIDMappings() + { + // base => + // Parent + yield return Parent == null ? + new RIDMapping(CreateRuntime(BaseRID)) : + new RIDMapping(CreateRuntime(BaseRID), new[] { CreateRuntime(Parent) }); + + foreach (var architecture in Architectures) + { + // base + arch => + // base, + // parent + arch + var imports = new List() + { + CreateRuntime(BaseRID) + }; + + if (!IsNullOrRoot(Parent)) + { + imports.Add(CreateRuntime(Parent, architecture: architecture)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, architecture: architecture), imports); + } + + string lastVersion = null; + foreach (var version in Versions) + { + // base + version => + // base + lastVersion, + // parent + version (optionally) + var imports = new List() + { + CreateRuntime(BaseRID, version: lastVersion) + }; + + if (ApplyVersionsToParent) + { + imports.Add(CreateRuntime(Parent, version: version)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, version: version), imports); + + foreach (var architecture in Architectures) + { + // base + version + architecture => + // base + version, + // base + lastVersion + architecture, + // parent + version + architecture (optionally) + var archImports = new List() + { + CreateRuntime(BaseRID, version: version), + CreateRuntime(BaseRID, version: lastVersion, architecture: architecture) + }; + + if (ApplyVersionsToParent) + { + archImports.Add(CreateRuntime(Parent, version: version, architecture: architecture)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, version: version, architecture: architecture), archImports); + } + + if (TreatVersionsAsCompatible) + { + lastVersion = version; + } + } + + foreach (var qualifier in AdditionalQualifiers) + { + // base + qual => + // base, + // parent + qual + yield return new RIDMapping(CreateRuntime(BaseRID, qualifier: qualifier), + new[] + { + CreateRuntime(BaseRID), + IsNullOrRoot(Parent) ? CreateRuntime(qualifier) : CreateRuntime(Parent, qualifier:qualifier) + }); + + foreach (var architecture in Architectures) + { + // base + arch + qualifier => + // base + qualifier, + // base + arch + // parent + arch + qualifier + var imports = new List() + { + CreateRuntime(BaseRID, qualifier: qualifier), + CreateRuntime(BaseRID, architecture: architecture) + }; + + if (!IsNullOrRoot(Parent)) + { + imports.Add(CreateRuntime(Parent, architecture: architecture, qualifier: qualifier)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, architecture: architecture, qualifier: qualifier), imports); + } + + lastVersion = null; + foreach (var version in Versions) + { + // base + version + qualifier => + // base + version, + // base + lastVersion + qualifier + // parent + version + qualifier (optionally) + var imports = new List() + { + CreateRuntime(BaseRID, version: version), + CreateRuntime(BaseRID, version: lastVersion, qualifier: qualifier) + }; + + if (ApplyVersionsToParent) + { + imports.Add(CreateRuntime(Parent, version: version, qualifier: qualifier)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, version: version, qualifier: qualifier), imports); + + foreach (var architecture in Architectures) + { + // base + version + architecture + qualifier => + // base + version + qualifier, + // base + version + architecture, + // base + version, + // base + lastVersion + architecture + qualifier, + // parent + version + architecture + qualifier (optionally) + var archImports = new List() + { + CreateRuntime(BaseRID, version: version, qualifier: qualifier), + CreateRuntime(BaseRID, version: version, architecture: architecture), + CreateRuntime(BaseRID, version: version), + CreateRuntime(BaseRID, version: lastVersion, architecture: architecture, qualifier: qualifier) + }; + + if (ApplyVersionsToParent) + { + imports.Add(CreateRuntime(Parent, version: version, architecture: architecture, qualifier: qualifier)); + } + + yield return new RIDMapping(CreateRuntime(BaseRID, version: version, architecture: architecture, qualifier: qualifier), archImports); + } + + if (TreatVersionsAsCompatible) + { + lastVersion = version; + } + } + } + } + + private bool IsNullOrRoot(string rid) + { + return rid == null || rid == rootRID; + } + + + public IEnumerable GetRuntimeDescriptions() + { + foreach (var mapping in GetRIDMappings()) + { + var rid = mapping.RuntimeIdentifier.ToString(); + + if (OmitRIDs.Contains(rid) || OmitRIDDefinitions.Contains(rid)) + { + continue; + } + + var imports = mapping.Imports + .Select(i => i.ToString()) + .Where(i => !OmitRIDs.Contains(i) && !OmitRIDReferences.Contains(i)) + .ToArray(); + + yield return new RuntimeDescription(rid, imports); + } + } + + public RuntimeGraph GetRuntimeGraph() + { + return new RuntimeGraph(GetRuntimeDescriptions()); + } + } + +} From 78dec6f20a5a607e86e5c239efd3e69d27c1a321 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Tue, 23 Mar 2021 09:05:25 -0700 Subject: [PATCH 2/5] Add the ability to infer additional RuntimeGroups from RIDs During source build it's desirable to add RIDs to the runtime graph without actually. Making a change to sources. For example: the tar-ball is produced and then built on some new distro. The added RID should follow the compatibility rules for existing RIDs so we parse it and try to find the most appropriate RuntimeGroup to add it to. --- .../src/GenerateRuntimeGraph.cs | 88 +- ...rosoft.DotNet.Build.Tasks.Packaging.csproj | 4 + .../src/RID.cs | 165 ++- .../src/RuntimeGroup.cs | 46 +- .../src/RuntimeVersion.cs | 129 +++ ...phTests.CanCreateRuntimeGraph.runtime.json | 956 +++++++++++++++++ ...untimeGraphTests.CanInferRids.runtime.json | 993 ++++++++++++++++++ .../tests/GenerateRuntimeGraphTests.cs | 144 +++ ....DotNet.Build.Tasks.Packaging.Tests.csproj | 33 +- .../tests/RidTests.cs | 48 + 10 files changed, 2572 insertions(+), 34 deletions(-) create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanCreateRuntimeGraph.runtime.json create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs index eccdfd0d4de..f40decc0551 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs @@ -52,6 +52,15 @@ public ITaskItem[] RuntimeGroups set; } + /// + /// Additional runtime identifiers to add to the graph. + /// + public string[] InferRuntimeIdentifiers + { + get; + set; + } + /// /// Optional source Runtime.json to use as a starting point when merging additional RuntimeGroups /// @@ -133,7 +142,11 @@ public override bool Execute() runtimeGraph = new RuntimeGraph(); } - foreach (var runtimeGroup in RuntimeGroups.NullAsEmpty().Select(i => new RuntimeGroup(i))) + List runtimeGroups = RuntimeGroups.NullAsEmpty().Select(i => new RuntimeGroup(i)).ToList(); + + AddInferredRuntimeIdentifiers(runtimeGroups, InferRuntimeIdentifiers.NullAsEmpty()); + + foreach (var runtimeGroup in runtimeGroups) { runtimeGraph = SafeMerge(runtimeGraph, runtimeGroup); } @@ -270,6 +283,79 @@ private void ValidateImports(RuntimeGraph runtimeGraph, IDictionary runtimeGroups, IEnumerable runtimeIdentifiers) + { + var runtimeGroupsByBaseRID = runtimeGroups.GroupBy(rg => rg.BaseRID).ToDictionary(g => g.Key, g => new List(g.AsEnumerable())); + + foreach(var runtimeIdentifer in runtimeIdentifiers) + { + RID rid = RID.Parse(runtimeIdentifer); + + if (!rid.HasArchitecture() && !rid.HasVersion()) + { + Log.LogError($"Cannot add Runtime {rid} to any existing group since it has no architcture nor version."); + continue; + } + + if (runtimeGroupsByBaseRID.TryGetValue(rid.BaseRID, out var candidateRuntimeGroups)) + { + RuntimeGroup closestGroup = null; + RuntimeVersion closestVersion = null; + + foreach(var candidate in candidateRuntimeGroups) + { + if (rid.HasArchitecture() && !candidate.Architectures.Contains(rid.Architecture)) + { + continue; + } + + foreach(var version in candidate.Versions) + { + if (closestVersion == null || + ((version <= rid.Version) && + (version > closestVersion))) + { + closestVersion = version; + closestGroup = candidate; + } + } + } + + if (closestGroup == null) + { + // couldn't find a close group, create a new one for just this arch/version + RuntimeGroup templateGroup = candidateRuntimeGroups.First(); + RuntimeGroup runtimeGroup = RuntimeGroup.CreateFromTemplate(templateGroup); + + if (rid.HasArchitecture()) + { + runtimeGroup.Architectures.Add(rid.Architecture); + } + + if (rid.HasVersion()) + { + runtimeGroup.Versions.Add(rid.Version); + } + + // add to overall list + runtimeGroups.Add(runtimeGroup); + + // add to our base-RID specific list from the dictionary so that further iterations see it. + candidateRuntimeGroups.Add(runtimeGroup); + + } + else if (closestVersion != rid.Version) + { + closestGroup.Versions.Add(rid.Version); + } + + } + else + { + Log.LogError($"Cannot find a group to add Runtime {rid} ({rid.BaseRID}) from {string.Join(",", runtimeGroupsByBaseRID.Keys)}"); + } + } + } private static IDictionary> GetCompatibilityMap(RuntimeGraph graph) { diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj index 1148b8a5ac7..42d2e34cec2 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj @@ -48,6 +48,10 @@ $(BeforePack);AddRuntimeJson + + + + - + <_candidatePackageFolder>%(_candidatPackageFolders.Identity) @@ -50,17 +56,14 @@ $(_candidatePackageFolder)\%(Identity)\%(Version) - $(_candidatePackageFolder)\$([System.String]::new("%(Identity)\%(Version)").ToLower()) + $(_candidatePackageFolder)\$([System.String]::new("%(Identity)\%(Version)").ToLower()) - - + + diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs new file mode 100644 index 00000000000..cc66ac9f31e --- /dev/null +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using NuGet.Frameworks; +using NuGet.RuntimeModel; +using System.IO; +using Xunit; +using Xunit.Abstractions; +using FluentAssertions; +using Microsoft.DotNet.Build.Tasks.Packaging; +using System.Collections.Generic; + +namespace Microsoft.DotNet.Build.Tasks.Packaging.Tests +{ + public class RidTests + { + public static IEnumerable ValidRIDData() + { + yield return new object[] { "win10-x64", new RID() { BaseRID = "win", OmitVersionDelimiter = true, Version = new RuntimeVersion("10"), Architecture = "x64" } }; + yield return new object[] { "win10", new RID() { BaseRID = "win", OmitVersionDelimiter = true, Version = new RuntimeVersion("10")} }; + yield return new object[] { "linux", new RID() { BaseRID = "linux" } }; + yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" } }; + yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" } }; + yield return new object[] { "debian.10-x64", new RID() { BaseRID = "debian", Version = new RuntimeVersion("10"), Architecture = "x64" } }; + yield return new object[] { "linuxmint.19.2-x64", new RID() { BaseRID = "linuxmint", Version = new RuntimeVersion("19.2"), Architecture = "x64" } }; + yield return new object[] { "foo-bar.42-arm", new RID() { BaseRID = "foo-bar", Version = new RuntimeVersion("42"), Architecture = "arm" } }; + yield return new object[] { "foo-bar-arm", new RID() { BaseRID = "foo", Architecture = "bar", Qualifier = "arm" } }; // demonstrates ambiguity, avoid using `-` in base + } + + [Theory] + [MemberData(nameof(ValidRIDData))] + internal void ParseCorrectly(string input, RID expected) + { + RID actual = RID.Parse(input); + + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(ValidRIDData))] + internal void ToStringAsExpected(string expected, RID rid) + { + string actual = rid.ToString(); + + Assert.Equal(expected, actual); + } + } +} From 7916e11537def28b199db696ea36a9e7e7d334cf Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Tue, 23 Mar 2021 13:35:22 -0700 Subject: [PATCH 3/5] Ensure we preserve version string verbatim Versions may contain insignificant whitespace which must be preserved. --- .../src/RuntimeVersion.cs | 21 ++-- ...phTests.CanCreateRuntimeGraph.runtime.json | 117 +++++++++++++++++- ...untimeGraphTests.CanInferRids.runtime.json | 115 +++++++++++++++++ .../tests/GenerateRuntimeGraphTests.cs | 1 + 4 files changed, 243 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs index ee9d346910c..977ba6800b2 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs @@ -11,6 +11,7 @@ namespace Microsoft.DotNet.Build.Tasks.Packaging /// internal sealed class RuntimeVersion : IComparable, IComparable, IEquatable { + private string versionString; private Version version; private bool hasMinor; @@ -18,18 +19,18 @@ public RuntimeVersion(string versionString) { // intentionally don't support the type of version that omits the separators as it is abiguous. // for example Windows 8.1 was encoded as win81, where as Windows 10.0 was encoded as win10 - - if (versionString.IndexOf('.') == -1) + this.versionString = versionString; + string toParse = versionString; + if (toParse.IndexOf('.') == -1) { - versionString += ".0"; + toParse += ".0"; hasMinor = false; } else { hasMinor = true; } - version = Version.Parse(versionString); - + version = Version.Parse(toParse); } public int CompareTo(object obj) @@ -62,6 +63,8 @@ public int CompareTo(RuntimeVersion other) { return 1; } + + return string.CompareOrdinal(versionString, other.versionString); } return versionResult; @@ -70,9 +73,7 @@ public int CompareTo(RuntimeVersion other) public bool Equals(RuntimeVersion other) { return object.ReferenceEquals(other, this) || - (!(other is null) && - (hasMinor == other.hasMinor) && - version.Equals(other.version)); + versionString.Equals(other.versionString, StringComparison.Ordinal); } public override bool Equals(object obj) @@ -82,12 +83,12 @@ public override bool Equals(object obj) public override int GetHashCode() { - return version.GetHashCode() | (hasMinor ? 1 : 0); + return versionString.GetHashCode(); } public override string ToString() { - return hasMinor ? version.ToString() : version.Major.ToString(); + return versionString; } public static bool operator ==(RuntimeVersion v1, RuntimeVersion v2) diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanCreateRuntimeGraph.runtime.json b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanCreateRuntimeGraph.runtime.json index c4d0c5a943a..f298932ca02 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanCreateRuntimeGraph.runtime.json +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanCreateRuntimeGraph.runtime.json @@ -594,6 +594,121 @@ "rhel-x64" ] }, + "ubuntu": { + "#import": [ + "debian" + ] + }, + "ubuntu-arm": { + "#import": [ + "ubuntu", + "debian-arm" + ] + }, + "ubuntu-x64": { + "#import": [ + "ubuntu", + "debian-x64" + ] + }, + "ubuntu-x86": { + "#import": [ + "ubuntu", + "debian-x86" + ] + }, + "ubuntu.14.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.04-arm": { + "#import": [ + "ubuntu.14.04", + "ubuntu-arm" + ] + }, + "ubuntu.14.04-x64": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x64" + ] + }, + "ubuntu.14.04-x86": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x86" + ] + }, + "ubuntu.14.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.10-arm": { + "#import": [ + "ubuntu.14.10", + "ubuntu-arm" + ] + }, + "ubuntu.14.10-x64": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x64" + ] + }, + "ubuntu.14.10-x86": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x86" + ] + }, + "ubuntu.15.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.04-arm": { + "#import": [ + "ubuntu.15.04", + "ubuntu-arm" + ] + }, + "ubuntu.15.04-x64": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x64" + ] + }, + "ubuntu.15.04-x86": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x86" + ] + }, + "ubuntu.15.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.10-arm": { + "#import": [ + "ubuntu.15.10", + "ubuntu-arm" + ] + }, + "ubuntu.15.10-x64": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x64" + ] + }, + "ubuntu.15.10-x86": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x86" + ] + }, "unix": { "#import": [ "any" @@ -953,4 +1068,4 @@ ] } } -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json index a2c3fee064d..621fa0b47eb 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json @@ -631,6 +631,121 @@ "rhel.9-x64" ] }, + "ubuntu": { + "#import": [ + "debian" + ] + }, + "ubuntu-arm": { + "#import": [ + "ubuntu", + "debian-arm" + ] + }, + "ubuntu-x64": { + "#import": [ + "ubuntu", + "debian-x64" + ] + }, + "ubuntu-x86": { + "#import": [ + "ubuntu", + "debian-x86" + ] + }, + "ubuntu.14.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.04-arm": { + "#import": [ + "ubuntu.14.04", + "ubuntu-arm" + ] + }, + "ubuntu.14.04-x64": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x64" + ] + }, + "ubuntu.14.04-x86": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x86" + ] + }, + "ubuntu.14.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.10-arm": { + "#import": [ + "ubuntu.14.10", + "ubuntu-arm" + ] + }, + "ubuntu.14.10-x64": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x64" + ] + }, + "ubuntu.14.10-x86": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x86" + ] + }, + "ubuntu.15.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.04-arm": { + "#import": [ + "ubuntu.15.04", + "ubuntu-arm" + ] + }, + "ubuntu.15.04-x64": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x64" + ] + }, + "ubuntu.15.04-x86": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x86" + ] + }, + "ubuntu.15.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.10-arm": { + "#import": [ + "ubuntu.15.10", + "ubuntu-arm" + ] + }, + "ubuntu.15.10-x64": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x64" + ] + }, + "ubuntu.15.10-x86": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x86" + ] + }, "unix": { "#import": [ "any" diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs index 036e4d34397..59fd0ec07dd 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs @@ -91,6 +91,7 @@ public void CanIgnoreExistingInferRids() CreateRuntimeGroup("osx", "unix", "x64;arm64", "10.10;10.11;10.12;10.13;10.14;10.15;10.16;11.0"), CreateRuntimeGroup("win", "any", "x64;x86;arm;arm64", "7;8;81;10", additionalQualifiers:"aot", omitVersionDelimiter:true), CreateRuntimeGroup("debian", "linux", "x64;x86;arm;armel;arm64", "8;9;10", treatVersionsAsCompatible:false), + CreateRuntimeGroup("ubuntu", "debian", "x64;x86;arm", "14.04;14.10;15.04;15.10", treatVersionsAsCompatible:false), CreateRuntimeGroup("rhel", "linux", "x64", "6"), CreateRuntimeGroup("rhel", "linux", "x64", "7;7.0;7.1;7.2;7.3;7.4;7.5;7.6"), CreateRuntimeGroup("rhel", "linux", "x64;arm64", "8;8.0;8.1"), From c537d5588d4f1d3b8ddc26f337ccfea527d0786f Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Tue, 23 Mar 2021 21:43:53 -0700 Subject: [PATCH 4/5] Add some more tests for RID related types --- .../src/GenerateRuntimeGraph.cs | 8 +- .../src/RuntimeVersion.cs | 10 +- ...Tests.CanInferNewArchitecture.runtime.json | 1107 +++++++++++++++++ .../tests/GenerateRuntimeGraphTests.cs | 22 +- ....DotNet.Build.Tasks.Packaging.Tests.csproj | 7 +- .../tests/RidTests.cs | 11 +- .../tests/RuntimeVersionTests.cs | 233 ++++ 7 files changed, 1380 insertions(+), 18 deletions(-) create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json create mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RuntimeVersionTests.cs diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs index f40decc0551..c7b40ddf1a7 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs @@ -309,6 +309,12 @@ private void AddInferredRuntimeIdentifiers(ICollection runtimeGrou continue; } + if (!rid.HasVersion()) + { + closestGroup = candidate; + continue; + } + foreach(var version in candidate.Versions) { if (closestVersion == null || @@ -344,7 +350,7 @@ private void AddInferredRuntimeIdentifiers(ICollection runtimeGrou candidateRuntimeGroups.Add(runtimeGroup); } - else if (closestVersion != rid.Version) + else if (rid.HasVersion() && closestVersion != rid.Version) { closestGroup.Versions.Add(rid.Version); } diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs index 977ba6800b2..66b44439121 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs @@ -50,7 +50,12 @@ public int CompareTo(object obj) public int CompareTo(RuntimeVersion other) { - int versionResult = version.CompareTo(other.version); + if (other == null) + { + return 1; + } + + int versionResult = version.CompareTo(other?.version); if (versionResult == 0) { @@ -73,7 +78,8 @@ public int CompareTo(RuntimeVersion other) public bool Equals(RuntimeVersion other) { return object.ReferenceEquals(other, this) || - versionString.Equals(other.versionString, StringComparison.Ordinal); + (other != null && + versionString.Equals(other.versionString, StringComparison.Ordinal)); } public override bool Equals(object obj) diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json new file mode 100644 index 00000000000..852e12e2079 --- /dev/null +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json @@ -0,0 +1,1107 @@ +{ + "runtimes": { + "any": { + "#import": [] + }, + "aot": { + "#import": [] + }, + "centos": { + "#import": [ + "rhel" + ] + }, + "centos-arm64": { + "#import": [ + "centos", + "rhel-arm64" + ] + }, + "centos-x64": { + "#import": [ + "centos", + "rhel-x64" + ] + }, + "centos.7": { + "#import": [ + "centos", + "rhel.7" + ] + }, + "centos.7-x64": { + "#import": [ + "centos.7", + "centos-x64", + "rhel.7-x64" + ] + }, + "centos.8": { + "#import": [ + "centos", + "rhel.8" + ] + }, + "centos.8-arm64": { + "#import": [ + "centos.8", + "centos-arm64", + "rhel.8-arm64" + ] + }, + "centos.8-x64": { + "#import": [ + "centos.8", + "centos-x64", + "rhel.8-x64" + ] + }, + "centos.9": { + "#import": [ + "centos", + "rhel.9" + ] + }, + "centos.9-arm64": { + "#import": [ + "centos.9", + "centos-arm64", + "rhel.9-arm64" + ] + }, + "centos.9-x64": { + "#import": [ + "centos.9", + "centos-x64", + "rhel.9-x64" + ] + }, + "debian": { + "#import": [ + "linux" + ] + }, + "debian-arm": { + "#import": [ + "debian", + "linux-arm" + ] + }, + "debian-arm64": { + "#import": [ + "debian", + "linux-arm64" + ] + }, + "debian-armel": { + "#import": [ + "debian", + "linux-armel" + ] + }, + "debian-x64": { + "#import": [ + "debian", + "linux-x64" + ] + }, + "debian-x86": { + "#import": [ + "debian", + "linux-x86" + ] + }, + "debian.10": { + "#import": [ + "debian" + ] + }, + "debian.10-arm": { + "#import": [ + "debian.10", + "debian-arm" + ] + }, + "debian.10-arm64": { + "#import": [ + "debian.10", + "debian-arm64" + ] + }, + "debian.10-armel": { + "#import": [ + "debian.10", + "debian-armel" + ] + }, + "debian.10-x64": { + "#import": [ + "debian.10", + "debian-x64" + ] + }, + "debian.10-x86": { + "#import": [ + "debian.10", + "debian-x86" + ] + }, + "debian.8": { + "#import": [ + "debian" + ] + }, + "debian.8-arm": { + "#import": [ + "debian.8", + "debian-arm" + ] + }, + "debian.8-arm64": { + "#import": [ + "debian.8", + "debian-arm64" + ] + }, + "debian.8-armel": { + "#import": [ + "debian.8", + "debian-armel" + ] + }, + "debian.8-x64": { + "#import": [ + "debian.8", + "debian-x64" + ] + }, + "debian.8-x86": { + "#import": [ + "debian.8", + "debian-x86" + ] + }, + "debian.9": { + "#import": [ + "debian" + ] + }, + "debian.9-arm": { + "#import": [ + "debian.9", + "debian-arm" + ] + }, + "debian.9-arm64": { + "#import": [ + "debian.9", + "debian-arm64" + ] + }, + "debian.9-armel": { + "#import": [ + "debian.9", + "debian-armel" + ] + }, + "debian.9-x64": { + "#import": [ + "debian.9", + "debian-x64" + ] + }, + "debian.9-x86": { + "#import": [ + "debian.9", + "debian-x86" + ] + }, + "linux": { + "#import": [ + "unix" + ] + }, + "linux-arm": { + "#import": [ + "linux", + "unix-arm" + ] + }, + "linux-arm64": { + "#import": [ + "linux", + "unix-arm64" + ] + }, + "linux-armel": { + "#import": [ + "linux", + "unix-armel" + ] + }, + "linux-mips64": { + "#import": [ + "linux", + "unix-mips64" + ] + }, + "linux-x64": { + "#import": [ + "linux", + "unix-x64" + ] + }, + "linux-x86": { + "#import": [ + "linux", + "unix-x86" + ] + }, + "osx": { + "#import": [ + "unix" + ] + }, + "osx-arm64": { + "#import": [ + "osx", + "unix-arm64" + ] + }, + "osx-x64": { + "#import": [ + "osx", + "unix-x64" + ] + }, + "osx.10.10": { + "#import": [ + "osx" + ] + }, + "osx.10.10-arm64": { + "#import": [ + "osx.10.10", + "osx-arm64" + ] + }, + "osx.10.10-x64": { + "#import": [ + "osx.10.10", + "osx-x64" + ] + }, + "osx.10.11": { + "#import": [ + "osx.10.10" + ] + }, + "osx.10.11-arm64": { + "#import": [ + "osx.10.11", + "osx.10.10-arm64" + ] + }, + "osx.10.11-x64": { + "#import": [ + "osx.10.11", + "osx.10.10-x64" + ] + }, + "osx.10.12": { + "#import": [ + "osx.10.11" + ] + }, + "osx.10.12-arm64": { + "#import": [ + "osx.10.12", + "osx.10.11-arm64" + ] + }, + "osx.10.12-x64": { + "#import": [ + "osx.10.12", + "osx.10.11-x64" + ] + }, + "osx.10.13": { + "#import": [ + "osx.10.12" + ] + }, + "osx.10.13-arm64": { + "#import": [ + "osx.10.13", + "osx.10.12-arm64" + ] + }, + "osx.10.13-x64": { + "#import": [ + "osx.10.13", + "osx.10.12-x64" + ] + }, + "osx.10.14": { + "#import": [ + "osx.10.13" + ] + }, + "osx.10.14-arm64": { + "#import": [ + "osx.10.14", + "osx.10.13-arm64" + ] + }, + "osx.10.14-x64": { + "#import": [ + "osx.10.14", + "osx.10.13-x64" + ] + }, + "osx.10.15": { + "#import": [ + "osx.10.14" + ] + }, + "osx.10.15-arm64": { + "#import": [ + "osx.10.15", + "osx.10.14-arm64" + ] + }, + "osx.10.15-x64": { + "#import": [ + "osx.10.15", + "osx.10.14-x64" + ] + }, + "osx.10.16": { + "#import": [ + "osx.10.15" + ] + }, + "osx.10.16-arm64": { + "#import": [ + "osx.10.16", + "osx.10.15-arm64" + ] + }, + "osx.10.16-x64": { + "#import": [ + "osx.10.16", + "osx.10.15-x64" + ] + }, + "osx.11.0": { + "#import": [ + "osx.10.16" + ] + }, + "osx.11.0-arm64": { + "#import": [ + "osx.11.0", + "osx.10.16-arm64" + ] + }, + "osx.11.0-x64": { + "#import": [ + "osx.11.0", + "osx.10.16-x64" + ] + }, + "rhel": { + "#import": [ + "linux" + ] + }, + "rhel-arm64": { + "#import": [ + "rhel", + "linux-arm64" + ] + }, + "rhel-x64": { + "#import": [ + "rhel", + "linux-x64" + ] + }, + "rhel.6": { + "#import": [ + "rhel" + ] + }, + "rhel.6-x64": { + "#import": [ + "rhel.6", + "rhel-x64" + ] + }, + "rhel.7": { + "#import": [ + "rhel" + ] + }, + "rhel.7-x64": { + "#import": [ + "rhel.7", + "rhel-x64" + ] + }, + "rhel.7.0": { + "#import": [ + "rhel.7" + ] + }, + "rhel.7.0-x64": { + "#import": [ + "rhel.7.0", + "rhel.7-x64" + ] + }, + "rhel.7.1": { + "#import": [ + "rhel.7.0" + ] + }, + "rhel.7.1-x64": { + "#import": [ + "rhel.7.1", + "rhel.7.0-x64" + ] + }, + "rhel.7.2": { + "#import": [ + "rhel.7.1" + ] + }, + "rhel.7.2-x64": { + "#import": [ + "rhel.7.2", + "rhel.7.1-x64" + ] + }, + "rhel.7.3": { + "#import": [ + "rhel.7.2" + ] + }, + "rhel.7.3-x64": { + "#import": [ + "rhel.7.3", + "rhel.7.2-x64" + ] + }, + "rhel.7.4": { + "#import": [ + "rhel.7.3" + ] + }, + "rhel.7.4-x64": { + "#import": [ + "rhel.7.4", + "rhel.7.3-x64" + ] + }, + "rhel.7.5": { + "#import": [ + "rhel.7.4" + ] + }, + "rhel.7.5-x64": { + "#import": [ + "rhel.7.5", + "rhel.7.4-x64" + ] + }, + "rhel.7.6": { + "#import": [ + "rhel.7.5" + ] + }, + "rhel.7.6-x64": { + "#import": [ + "rhel.7.6", + "rhel.7.5-x64" + ] + }, + "rhel.8": { + "#import": [ + "rhel" + ] + }, + "rhel.8-arm64": { + "#import": [ + "rhel.8", + "rhel-arm64" + ] + }, + "rhel.8-x64": { + "#import": [ + "rhel.8", + "rhel-x64" + ] + }, + "rhel.8.0": { + "#import": [ + "rhel.8" + ] + }, + "rhel.8.0-arm64": { + "#import": [ + "rhel.8.0", + "rhel.8-arm64" + ] + }, + "rhel.8.0-x64": { + "#import": [ + "rhel.8.0", + "rhel.8-x64" + ] + }, + "rhel.8.1": { + "#import": [ + "rhel.8.0" + ] + }, + "rhel.8.1-arm64": { + "#import": [ + "rhel.8.1", + "rhel.8.0-arm64" + ] + }, + "rhel.8.1-x64": { + "#import": [ + "rhel.8.1", + "rhel.8.0-x64" + ] + }, + "rhel.9": { + "#import": [ + "rhel" + ] + }, + "rhel.9-arm64": { + "#import": [ + "rhel.9", + "rhel-arm64" + ] + }, + "rhel.9-x64": { + "#import": [ + "rhel.9", + "rhel-x64" + ] + }, + "ubuntu": { + "#import": [ + "debian" + ] + }, + "ubuntu-arm": { + "#import": [ + "ubuntu", + "debian-arm" + ] + }, + "ubuntu-x64": { + "#import": [ + "ubuntu", + "debian-x64" + ] + }, + "ubuntu-x86": { + "#import": [ + "ubuntu", + "debian-x86" + ] + }, + "ubuntu.14.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.04-arm": { + "#import": [ + "ubuntu.14.04", + "ubuntu-arm" + ] + }, + "ubuntu.14.04-x64": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x64" + ] + }, + "ubuntu.14.04-x86": { + "#import": [ + "ubuntu.14.04", + "ubuntu-x86" + ] + }, + "ubuntu.14.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.14.10-arm": { + "#import": [ + "ubuntu.14.10", + "ubuntu-arm" + ] + }, + "ubuntu.14.10-x64": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x64" + ] + }, + "ubuntu.14.10-x86": { + "#import": [ + "ubuntu.14.10", + "ubuntu-x86" + ] + }, + "ubuntu.15.04": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.04-arm": { + "#import": [ + "ubuntu.15.04", + "ubuntu-arm" + ] + }, + "ubuntu.15.04-x64": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x64" + ] + }, + "ubuntu.15.04-x86": { + "#import": [ + "ubuntu.15.04", + "ubuntu-x86" + ] + }, + "ubuntu.15.10": { + "#import": [ + "ubuntu" + ] + }, + "ubuntu.15.10-arm": { + "#import": [ + "ubuntu.15.10", + "ubuntu-arm" + ] + }, + "ubuntu.15.10-x64": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x64" + ] + }, + "ubuntu.15.10-x86": { + "#import": [ + "ubuntu.15.10", + "ubuntu-x86" + ] + }, + "unix": { + "#import": [ + "any" + ] + }, + "unix-arm": { + "#import": [ + "unix" + ] + }, + "unix-arm64": { + "#import": [ + "unix" + ] + }, + "unix-armel": { + "#import": [ + "unix" + ] + }, + "unix-mips64": { + "#import": [ + "unix" + ] + }, + "unix-x64": { + "#import": [ + "unix" + ] + }, + "unix-x86": { + "#import": [ + "unix" + ] + }, + "win": { + "#import": [ + "any" + ] + }, + "win-aot": { + "#import": [ + "win", + "aot" + ] + }, + "win-arm": { + "#import": [ + "win" + ] + }, + "win-arm-aot": { + "#import": [ + "win-aot", + "win-arm" + ] + }, + "win-arm64": { + "#import": [ + "win" + ] + }, + "win-arm64-aot": { + "#import": [ + "win-aot", + "win-arm64" + ] + }, + "win-x128": { + "#import": [ + "win" + ] + }, + "win-x128-aot": { + "#import": [ + "win-aot", + "win-x128" + ] + }, + "win-x64": { + "#import": [ + "win" + ] + }, + "win-x64-aot": { + "#import": [ + "win-aot", + "win-x64" + ] + }, + "win-x86": { + "#import": [ + "win" + ] + }, + "win-x86-aot": { + "#import": [ + "win-aot", + "win-x86" + ] + }, + "win10": { + "#import": [ + "win81" + ] + }, + "win10-aot": { + "#import": [ + "win10", + "win81-aot" + ] + }, + "win10-arm": { + "#import": [ + "win10", + "win81-arm" + ] + }, + "win10-arm-aot": { + "#import": [ + "win10-aot", + "win10-arm", + "win10", + "win81-arm-aot" + ] + }, + "win10-arm64": { + "#import": [ + "win10", + "win81-arm64" + ] + }, + "win10-arm64-aot": { + "#import": [ + "win10-aot", + "win10-arm64", + "win10", + "win81-arm64-aot" + ] + }, + "win10-x64": { + "#import": [ + "win10", + "win81-x64" + ] + }, + "win10-x64-aot": { + "#import": [ + "win10-aot", + "win10-x64", + "win10", + "win81-x64-aot" + ] + }, + "win10-x86": { + "#import": [ + "win10", + "win81-x86" + ] + }, + "win10-x86-aot": { + "#import": [ + "win10-aot", + "win10-x86", + "win10", + "win81-x86-aot" + ] + }, + "win12": { + "#import": [ + "win" + ] + }, + "win12-aot": { + "#import": [ + "win12", + "win-aot" + ] + }, + "win12-x128": { + "#import": [ + "win12", + "win-x128" + ] + }, + "win12-x128-aot": { + "#import": [ + "win12-aot", + "win12-x128", + "win12", + "win-x128-aot" + ] + }, + "win7": { + "#import": [ + "win" + ] + }, + "win7-aot": { + "#import": [ + "win7", + "win-aot" + ] + }, + "win7-arm": { + "#import": [ + "win7", + "win-arm" + ] + }, + "win7-arm-aot": { + "#import": [ + "win7-aot", + "win7-arm", + "win7", + "win-arm-aot" + ] + }, + "win7-arm64": { + "#import": [ + "win7", + "win-arm64" + ] + }, + "win7-arm64-aot": { + "#import": [ + "win7-aot", + "win7-arm64", + "win7", + "win-arm64-aot" + ] + }, + "win7-x64": { + "#import": [ + "win7", + "win-x64" + ] + }, + "win7-x64-aot": { + "#import": [ + "win7-aot", + "win7-x64", + "win7", + "win-x64-aot" + ] + }, + "win7-x86": { + "#import": [ + "win7", + "win-x86" + ] + }, + "win7-x86-aot": { + "#import": [ + "win7-aot", + "win7-x86", + "win7", + "win-x86-aot" + ] + }, + "win8": { + "#import": [ + "win7" + ] + }, + "win8-aot": { + "#import": [ + "win8", + "win7-aot" + ] + }, + "win8-arm": { + "#import": [ + "win8", + "win7-arm" + ] + }, + "win8-arm-aot": { + "#import": [ + "win8-aot", + "win8-arm", + "win8", + "win7-arm-aot" + ] + }, + "win8-arm64": { + "#import": [ + "win8", + "win7-arm64" + ] + }, + "win8-arm64-aot": { + "#import": [ + "win8-aot", + "win8-arm64", + "win8", + "win7-arm64-aot" + ] + }, + "win8-x64": { + "#import": [ + "win8", + "win7-x64" + ] + }, + "win8-x64-aot": { + "#import": [ + "win8-aot", + "win8-x64", + "win8", + "win7-x64-aot" + ] + }, + "win8-x86": { + "#import": [ + "win8", + "win7-x86" + ] + }, + "win8-x86-aot": { + "#import": [ + "win8-aot", + "win8-x86", + "win8", + "win7-x86-aot" + ] + }, + "win81": { + "#import": [ + "win8" + ] + }, + "win81-aot": { + "#import": [ + "win81", + "win8-aot" + ] + }, + "win81-arm": { + "#import": [ + "win81", + "win8-arm" + ] + }, + "win81-arm-aot": { + "#import": [ + "win81-aot", + "win81-arm", + "win81", + "win8-arm-aot" + ] + }, + "win81-arm64": { + "#import": [ + "win81", + "win8-arm64" + ] + }, + "win81-arm64-aot": { + "#import": [ + "win81-aot", + "win81-arm64", + "win81", + "win8-arm64-aot" + ] + }, + "win81-x64": { + "#import": [ + "win81", + "win8-x64" + ] + }, + "win81-x64-aot": { + "#import": [ + "win81-aot", + "win81-x64", + "win81", + "win8-x64-aot" + ] + }, + "win81-x86": { + "#import": [ + "win81", + "win8-x86" + ] + }, + "win81-x86-aot": { + "#import": [ + "win81-aot", + "win81-x86", + "win81", + "win8-x86-aot" + ] + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs index 59fd0ec07dd..c129187388d 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs @@ -60,6 +60,26 @@ public void CanInferRids() _log.WarningsLogged.Should().Be(0); } + [Fact] + public void CanInferNewArchitecture() + { + string runtimeFile = $"{nameof(GenerateRuntimeGraphTests)}.{nameof(CanInferNewArchitecture)}.runtime.json"; + + // will generate and compare to existing file. + GenerateRuntimeGraph task = new GenerateRuntimeGraph() + { + BuildEngine = _engine, + RuntimeGroups = runtimeGroups, + RuntimeJson = runtimeFile, + InferRuntimeIdentifiers = new[] { "win12-x128" } + }; + + _log.Reset(); + task.Execute(); + _log.ErrorsLogged.Should().Be(0); + _log.WarningsLogged.Should().Be(0); + } + [Fact] public void CanIgnoreExistingInferRids() { @@ -72,7 +92,7 @@ public void CanIgnoreExistingInferRids() BuildEngine = _engine, RuntimeGroups = runtimeGroups, RuntimeJson = runtimeFile, - InferRuntimeIdentifiers = new[] { "rhel.9-x64", "centos.9-arm64" } + InferRuntimeIdentifiers = new[] { "rhel.9-x64", "centos.9-arm64", "win-x64" } }; _log.Reset(); diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Microsoft.DotNet.Build.Tasks.Packaging.Tests.csproj b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Microsoft.DotNet.Build.Tasks.Packaging.Tests.csproj index 6ef0aa4f18c..63323c0d13b 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Microsoft.DotNet.Build.Tasks.Packaging.Tests.csproj +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/Microsoft.DotNet.Build.Tasks.Packaging.Tests.csproj @@ -39,12 +39,7 @@ - - PreserveNewest - - - PreserveNewest - + diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs index cc66ac9f31e..762309bd79a 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RidTests.cs @@ -1,14 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using NuGet.Frameworks; -using NuGet.RuntimeModel; -using System.IO; -using Xunit; -using Xunit.Abstractions; -using FluentAssertions; -using Microsoft.DotNet.Build.Tasks.Packaging; using System.Collections.Generic; +using Xunit; namespace Microsoft.DotNet.Build.Tasks.Packaging.Tests { @@ -21,8 +15,9 @@ public static IEnumerable ValidRIDData() yield return new object[] { "linux", new RID() { BaseRID = "linux" } }; yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" } }; yield return new object[] { "linux-x64", new RID() { BaseRID = "linux", Architecture = "x64" } }; - yield return new object[] { "debian.10-x64", new RID() { BaseRID = "debian", Version = new RuntimeVersion("10"), Architecture = "x64" } }; + yield return new object[] { "debian.10-x64", new RID() { BaseRID = "debian", Version = new RuntimeVersion("10"), Architecture = "x64" } }; yield return new object[] { "linuxmint.19.2-x64", new RID() { BaseRID = "linuxmint", Version = new RuntimeVersion("19.2"), Architecture = "x64" } }; + yield return new object[] { "ubuntu.14.04-x64", new RID() { BaseRID = "ubuntu", Version = new RuntimeVersion("14.04"), Architecture = "x64" } }; yield return new object[] { "foo-bar.42-arm", new RID() { BaseRID = "foo-bar", Version = new RuntimeVersion("42"), Architecture = "arm" } }; yield return new object[] { "foo-bar-arm", new RID() { BaseRID = "foo", Architecture = "bar", Qualifier = "arm" } }; // demonstrates ambiguity, avoid using `-` in base } diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RuntimeVersionTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RuntimeVersionTests.cs new file mode 100644 index 00000000000..579f14cf0f7 --- /dev/null +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/RuntimeVersionTests.cs @@ -0,0 +1,233 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using Xunit; + +namespace Microsoft.DotNet.Build.Tasks.Packaging.Tests +{ + public class RuntimeVersionTests + { + public enum Comparison + { + LessThan, + Equal, + GreaterThan + } + + public static IEnumerable ComparisonData() + { + yield return new object[] { "0.0", "00.0", Comparison.LessThan }; + yield return new object[] { "2.0", "1.0", Comparison.GreaterThan }; + yield return new object[] { "2", "1.0", Comparison.GreaterThan }; + yield return new object[] { "2", "1", Comparison.GreaterThan }; + yield return new object[] { "10", "10.0", Comparison.LessThan }; + yield return new object[] { "10", "10.00", Comparison.LessThan }; + yield return new object[] { "10.0", "10.0", Comparison.Equal }; + yield return new object[] { "10.0", null, Comparison.GreaterThan }; + yield return new object[] { "8", "8", Comparison.Equal }; + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void CompareTo(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + int actual = v1.CompareTo(v2); + int invActual = v2?.CompareTo(v1) ?? -1; + + switch (expected) + { + case Comparison.LessThan: + Assert.True(actual < 0); + Assert.True(invActual > 0); + break; + case Comparison.Equal: + Assert.Equal(0, actual); + Assert.Equal(0, invActual); + break; + case Comparison.GreaterThan: + Assert.True(actual > 0); + Assert.True(invActual < 0); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void GreaterThan(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + bool actual = v1 > v2; + bool invActual = v2 > v1; + + switch (expected) + { + case Comparison.LessThan: + Assert.False(actual); + Assert.True(invActual); + break; + case Comparison.Equal: + Assert.False(actual); + Assert.False(invActual); + break; + case Comparison.GreaterThan: + Assert.True(actual); + Assert.False(invActual); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void GreaterThanOrEqual(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + bool actual = v1 >= v2; + bool invActual = v2 >= v1; + + switch (expected) + { + case Comparison.LessThan: + Assert.False(actual); + Assert.True(invActual); + break; + case Comparison.Equal: + Assert.True(actual); + Assert.True(invActual); + break; + case Comparison.GreaterThan: + Assert.True(actual); + Assert.False(invActual); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void LessThan(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + bool actual = v1 < v2; + bool invActual = v2 < v1; + + switch (expected) + { + case Comparison.LessThan: + Assert.True(actual); + Assert.False(invActual); + break; + case Comparison.Equal: + Assert.False(actual); + Assert.False(invActual); + break; + case Comparison.GreaterThan: + Assert.False(actual); + Assert.True(invActual); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void LessThanOrEqual(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + bool actual = v1 <= v2; + bool invActual = v2 <= v1; + + switch (expected) + { + case Comparison.LessThan: + Assert.True(actual); + Assert.False(invActual); + break; + case Comparison.Equal: + Assert.True(actual); + Assert.True(invActual); + break; + case Comparison.GreaterThan: + Assert.False(actual); + Assert.True(invActual); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void Equal(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + bool actual = v1 == v2; + bool invActual = v2 == v1; + + switch (expected) + { + case Comparison.LessThan: + Assert.False(actual); + Assert.False(invActual); + break; + case Comparison.Equal: + Assert.True(actual); + Assert.True(invActual); + break; + case Comparison.GreaterThan: + Assert.False(actual); + Assert.False(invActual); + break; + } + } + + [MemberData(nameof(ComparisonData))] + [Theory] + public static void GetHashCodeUnique(string vs1, string vs2, Comparison expected) + { + RuntimeVersion v1 = new RuntimeVersion(vs1); + RuntimeVersion v2 = vs2 == null ? null : new RuntimeVersion(vs2); + int h1 = v1.GetHashCode(); + int h2 = v2?.GetHashCode() ?? 0; + + switch (expected) + { + case Comparison.LessThan: + Assert.NotEqual(h1, h2); + break; + case Comparison.Equal: + Assert.Equal(h1, h2); + break; + case Comparison.GreaterThan: + Assert.NotEqual(h1, h2); + break; + } + } + public static IEnumerable ValidVersions() + { + yield return new object[] { "0" }; + yield return new object[] { "00" }; + yield return new object[] { "000" }; + yield return new object[] { "1" }; + yield return new object[] { "1.0" }; + yield return new object[] { "1.1" }; + yield return new object[] { "1.01" }; + yield return new object[] { "1.2.3.4" }; + yield return new object[] { "1.02.03.04" }; + } + + + [MemberData(nameof(ValidVersions))] + [Theory] + public static void RoundTripToString(string expected) + { + RuntimeVersion version = new RuntimeVersion(expected); + string actual = version.ToString(); + Assert.Equal(expected, actual); + } + + } +} From f8a7773a61bea2022ecd0d9a622989aae1e4d2ae Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Wed, 24 Mar 2021 23:30:52 -0700 Subject: [PATCH 5/5] Refactor RID addition and tests --- .../src/GenerateRuntimeGraph.cs | 49 +- .../src/RID.cs | 21 +- .../src/RuntimeGroup.cs | 45 +- ...Tests.CanInferNewArchitecture.runtime.json | 1107 ---------------- ...untimeGraphTests.CanInferRids.runtime.json | 1108 ----------------- .../tests/GenerateRuntimeGraphTests.cs | 69 +- 6 files changed, 98 insertions(+), 2301 deletions(-) delete mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json delete mode 100644 src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs index c7b40ddf1a7..25946410251 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GenerateRuntimeGraph.cs @@ -55,7 +55,7 @@ public ITaskItem[] RuntimeGroups /// /// Additional runtime identifiers to add to the graph. /// - public string[] InferRuntimeIdentifiers + public string[] AdditionalRuntimeIdentifiers { get; set; @@ -144,7 +144,7 @@ public override bool Execute() List runtimeGroups = RuntimeGroups.NullAsEmpty().Select(i => new RuntimeGroup(i)).ToList(); - AddInferredRuntimeIdentifiers(runtimeGroups, InferRuntimeIdentifiers.NullAsEmpty()); + AddRuntimeIdentifiers(runtimeGroups, AdditionalRuntimeIdentifiers.NullAsEmpty(), defaultParent: "linux"); foreach (var runtimeGroup in runtimeGroups) { @@ -283,35 +283,31 @@ private void ValidateImports(RuntimeGraph runtimeGraph, IDictionary runtimeGroups, IEnumerable runtimeIdentifiers) + + internal static void AddRuntimeIdentifiers(ICollection runtimeGroups, IEnumerable runtimeIdentifiers, string defaultParent) { var runtimeGroupsByBaseRID = runtimeGroups.GroupBy(rg => rg.BaseRID).ToDictionary(g => g.Key, g => new List(g.AsEnumerable())); foreach(var runtimeIdentifer in runtimeIdentifiers) { + RuntimeGroup runtimeGroup = null; RID rid = RID.Parse(runtimeIdentifer); - if (!rid.HasArchitecture() && !rid.HasVersion()) - { - Log.LogError($"Cannot add Runtime {rid} to any existing group since it has no architcture nor version."); - continue; - } if (runtimeGroupsByBaseRID.TryGetValue(rid.BaseRID, out var candidateRuntimeGroups)) { - RuntimeGroup closestGroup = null; RuntimeVersion closestVersion = null; foreach(var candidate in candidateRuntimeGroups) { - if (rid.HasArchitecture() && !candidate.Architectures.Contains(rid.Architecture)) + if (rid.HasArchitecture && !candidate.Architectures.Contains(rid.Architecture)) { continue; } - if (!rid.HasVersion()) + if (!rid.HasVersion) { - closestGroup = candidate; + runtimeGroup = candidate; continue; } @@ -322,44 +318,33 @@ private void AddInferredRuntimeIdentifiers(ICollection runtimeGrou (version > closestVersion))) { closestVersion = version; - closestGroup = candidate; + runtimeGroup = candidate; } } } - if (closestGroup == null) + if (runtimeGroup == null) { // couldn't find a close group, create a new one for just this arch/version RuntimeGroup templateGroup = candidateRuntimeGroups.First(); - RuntimeGroup runtimeGroup = RuntimeGroup.CreateFromTemplate(templateGroup); - - if (rid.HasArchitecture()) - { - runtimeGroup.Architectures.Add(rid.Architecture); - } - - if (rid.HasVersion()) - { - runtimeGroup.Versions.Add(rid.Version); - } + runtimeGroup = RuntimeGroup.CreateFromTemplate(templateGroup); // add to overall list runtimeGroups.Add(runtimeGroup); // add to our base-RID specific list from the dictionary so that further iterations see it. candidateRuntimeGroups.Add(runtimeGroup); - - } - else if (rid.HasVersion() && closestVersion != rid.Version) - { - closestGroup.Versions.Add(rid.Version); } - } else { - Log.LogError($"Cannot find a group to add Runtime {rid} ({rid.BaseRID}) from {string.Join(",", runtimeGroupsByBaseRID.Keys)}"); + runtimeGroup = new RuntimeGroup(rid.BaseRID, defaultParent); + runtimeGroups.Add(runtimeGroup); + + runtimeGroupsByBaseRID.Add(rid.BaseRID, new List() { runtimeGroup }); } + + runtimeGroup.ApplyRid(rid); } } diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs index cd0390cc275..c3dc3f6991b 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RID.cs @@ -23,7 +23,7 @@ public override string ToString() { StringBuilder builder = new StringBuilder(BaseRID); - if (HasVersion()) + if (HasVersion) { if (!OmitVersionDelimiter) { @@ -32,13 +32,13 @@ public override string ToString() builder.Append(Version); } - if (HasArchitecture()) + if (HasArchitecture) { builder.Append(ArchitectureDelimiter); builder.Append(Architecture); } - if (HasQualifier()) + if (HasQualifier) { builder.Append(QualifierDelimiter); builder.Append(Qualifier); @@ -161,20 +161,11 @@ void SetPart() } - public bool HasVersion() - { - return Version != null; - } + public bool HasVersion => Version != null; - public bool HasArchitecture() - { - return Architecture != null; - } + public bool HasArchitecture => Architecture != null; - public bool HasQualifier() - { - return Qualifier != null; - } + public bool HasQualifier => Qualifier != null; public override bool Equals(object obj) { diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs index 53dae59c793..a3ed3f4ddec 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeGroup.cs @@ -22,35 +22,35 @@ public RuntimeGroup(ITaskItem item) OmitVersionDelimiter = item.GetBoolean(nameof(OmitVersionDelimiter)); ApplyVersionsToParent = item.GetBoolean(nameof(ApplyVersionsToParent)); Architectures = new HashSet(item.GetStrings(nameof(Architectures))); - AdditionalQualifiers = item.GetStrings(nameof(AdditionalQualifiers)); + AdditionalQualifiers = new HashSet(item.GetStrings(nameof(AdditionalQualifiers))); OmitRIDs = new HashSet(item.GetStrings(nameof(OmitRIDs))); OmitRIDDefinitions = new HashSet(item.GetStrings(nameof(OmitRIDDefinitions))); OmitRIDReferences = new HashSet(item.GetStrings(nameof(OmitRIDReferences))); } - private RuntimeGroup(RuntimeGroup template) + public RuntimeGroup(string baseRID, string parent, bool treatVersionsAsCompatible = true, bool omitVersionDelimiter = false, bool applyVersionsToParent = false, IEnumerable additionalQualifiers = null) { - BaseRID = template.BaseRID; - Parent = template.Parent; + BaseRID = baseRID; + Parent = parent; Versions = new HashSet(); - TreatVersionsAsCompatible = template.TreatVersionsAsCompatible; - OmitVersionDelimiter = template.OmitVersionDelimiter; - ApplyVersionsToParent = template.ApplyVersionsToParent; + TreatVersionsAsCompatible = treatVersionsAsCompatible; + OmitVersionDelimiter = omitVersionDelimiter; + ApplyVersionsToParent = applyVersionsToParent; Architectures = new HashSet(); - AdditionalQualifiers = template.AdditionalQualifiers; + AdditionalQualifiers = new HashSet(additionalQualifiers.NullAsEmpty()); OmitRIDs = new HashSet(); OmitRIDDefinitions = new HashSet(); OmitRIDReferences = new HashSet(); } /// - /// Creates a new RuntimeGroup that matches existing template for parent and format with no architectures, versions or qualifiers. + /// Creates a new RuntimeGroup that matches existing template for parent and format with no architectures nor versions. /// /// /// public static RuntimeGroup CreateFromTemplate(RuntimeGroup template) { - return new RuntimeGroup(template); + return new RuntimeGroup(template.BaseRID, template.Parent, template.TreatVersionsAsCompatible, template.OmitVersionDelimiter, template.ApplyVersionsToParent, template.AdditionalQualifiers); } public string BaseRID { get; } @@ -60,11 +60,34 @@ public static RuntimeGroup CreateFromTemplate(RuntimeGroup template) public bool OmitVersionDelimiter { get; } public bool ApplyVersionsToParent { get; } public ICollection Architectures { get; } - public IEnumerable AdditionalQualifiers { get; } + public ICollection AdditionalQualifiers { get; } public ICollection OmitRIDs { get; } public ICollection OmitRIDDefinitions { get; } public ICollection OmitRIDReferences { get; } + public void ApplyRid(RID rid) + { + if (!rid.BaseRID.Equals(BaseRID, StringComparison.Ordinal)) + { + throw new ArgumentException(nameof(rid), $"Cannot apply {nameof(RID)} with {nameof(RID.BaseRID)} {rid.BaseRID} to {nameof(RuntimeGroup)} with {nameof(RuntimeGroup.BaseRID)} {BaseRID}."); + } + + if (rid.HasArchitecture) + { + Architectures.Add(rid.Architecture); + } + + if (rid.HasVersion) + { + Versions.Add(rid.Version); + } + + if (rid.HasQualifier) + { + AdditionalQualifiers.Add(rid.Qualifier); + } + } + private class RIDMapping { public RIDMapping(RID runtimeIdentifier) diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json deleted file mode 100644 index 852e12e2079..00000000000 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferNewArchitecture.runtime.json +++ /dev/null @@ -1,1107 +0,0 @@ -{ - "runtimes": { - "any": { - "#import": [] - }, - "aot": { - "#import": [] - }, - "centos": { - "#import": [ - "rhel" - ] - }, - "centos-arm64": { - "#import": [ - "centos", - "rhel-arm64" - ] - }, - "centos-x64": { - "#import": [ - "centos", - "rhel-x64" - ] - }, - "centos.7": { - "#import": [ - "centos", - "rhel.7" - ] - }, - "centos.7-x64": { - "#import": [ - "centos.7", - "centos-x64", - "rhel.7-x64" - ] - }, - "centos.8": { - "#import": [ - "centos", - "rhel.8" - ] - }, - "centos.8-arm64": { - "#import": [ - "centos.8", - "centos-arm64", - "rhel.8-arm64" - ] - }, - "centos.8-x64": { - "#import": [ - "centos.8", - "centos-x64", - "rhel.8-x64" - ] - }, - "centos.9": { - "#import": [ - "centos", - "rhel.9" - ] - }, - "centos.9-arm64": { - "#import": [ - "centos.9", - "centos-arm64", - "rhel.9-arm64" - ] - }, - "centos.9-x64": { - "#import": [ - "centos.9", - "centos-x64", - "rhel.9-x64" - ] - }, - "debian": { - "#import": [ - "linux" - ] - }, - "debian-arm": { - "#import": [ - "debian", - "linux-arm" - ] - }, - "debian-arm64": { - "#import": [ - "debian", - "linux-arm64" - ] - }, - "debian-armel": { - "#import": [ - "debian", - "linux-armel" - ] - }, - "debian-x64": { - "#import": [ - "debian", - "linux-x64" - ] - }, - "debian-x86": { - "#import": [ - "debian", - "linux-x86" - ] - }, - "debian.10": { - "#import": [ - "debian" - ] - }, - "debian.10-arm": { - "#import": [ - "debian.10", - "debian-arm" - ] - }, - "debian.10-arm64": { - "#import": [ - "debian.10", - "debian-arm64" - ] - }, - "debian.10-armel": { - "#import": [ - "debian.10", - "debian-armel" - ] - }, - "debian.10-x64": { - "#import": [ - "debian.10", - "debian-x64" - ] - }, - "debian.10-x86": { - "#import": [ - "debian.10", - "debian-x86" - ] - }, - "debian.8": { - "#import": [ - "debian" - ] - }, - "debian.8-arm": { - "#import": [ - "debian.8", - "debian-arm" - ] - }, - "debian.8-arm64": { - "#import": [ - "debian.8", - "debian-arm64" - ] - }, - "debian.8-armel": { - "#import": [ - "debian.8", - "debian-armel" - ] - }, - "debian.8-x64": { - "#import": [ - "debian.8", - "debian-x64" - ] - }, - "debian.8-x86": { - "#import": [ - "debian.8", - "debian-x86" - ] - }, - "debian.9": { - "#import": [ - "debian" - ] - }, - "debian.9-arm": { - "#import": [ - "debian.9", - "debian-arm" - ] - }, - "debian.9-arm64": { - "#import": [ - "debian.9", - "debian-arm64" - ] - }, - "debian.9-armel": { - "#import": [ - "debian.9", - "debian-armel" - ] - }, - "debian.9-x64": { - "#import": [ - "debian.9", - "debian-x64" - ] - }, - "debian.9-x86": { - "#import": [ - "debian.9", - "debian-x86" - ] - }, - "linux": { - "#import": [ - "unix" - ] - }, - "linux-arm": { - "#import": [ - "linux", - "unix-arm" - ] - }, - "linux-arm64": { - "#import": [ - "linux", - "unix-arm64" - ] - }, - "linux-armel": { - "#import": [ - "linux", - "unix-armel" - ] - }, - "linux-mips64": { - "#import": [ - "linux", - "unix-mips64" - ] - }, - "linux-x64": { - "#import": [ - "linux", - "unix-x64" - ] - }, - "linux-x86": { - "#import": [ - "linux", - "unix-x86" - ] - }, - "osx": { - "#import": [ - "unix" - ] - }, - "osx-arm64": { - "#import": [ - "osx", - "unix-arm64" - ] - }, - "osx-x64": { - "#import": [ - "osx", - "unix-x64" - ] - }, - "osx.10.10": { - "#import": [ - "osx" - ] - }, - "osx.10.10-arm64": { - "#import": [ - "osx.10.10", - "osx-arm64" - ] - }, - "osx.10.10-x64": { - "#import": [ - "osx.10.10", - "osx-x64" - ] - }, - "osx.10.11": { - "#import": [ - "osx.10.10" - ] - }, - "osx.10.11-arm64": { - "#import": [ - "osx.10.11", - "osx.10.10-arm64" - ] - }, - "osx.10.11-x64": { - "#import": [ - "osx.10.11", - "osx.10.10-x64" - ] - }, - "osx.10.12": { - "#import": [ - "osx.10.11" - ] - }, - "osx.10.12-arm64": { - "#import": [ - "osx.10.12", - "osx.10.11-arm64" - ] - }, - "osx.10.12-x64": { - "#import": [ - "osx.10.12", - "osx.10.11-x64" - ] - }, - "osx.10.13": { - "#import": [ - "osx.10.12" - ] - }, - "osx.10.13-arm64": { - "#import": [ - "osx.10.13", - "osx.10.12-arm64" - ] - }, - "osx.10.13-x64": { - "#import": [ - "osx.10.13", - "osx.10.12-x64" - ] - }, - "osx.10.14": { - "#import": [ - "osx.10.13" - ] - }, - "osx.10.14-arm64": { - "#import": [ - "osx.10.14", - "osx.10.13-arm64" - ] - }, - "osx.10.14-x64": { - "#import": [ - "osx.10.14", - "osx.10.13-x64" - ] - }, - "osx.10.15": { - "#import": [ - "osx.10.14" - ] - }, - "osx.10.15-arm64": { - "#import": [ - "osx.10.15", - "osx.10.14-arm64" - ] - }, - "osx.10.15-x64": { - "#import": [ - "osx.10.15", - "osx.10.14-x64" - ] - }, - "osx.10.16": { - "#import": [ - "osx.10.15" - ] - }, - "osx.10.16-arm64": { - "#import": [ - "osx.10.16", - "osx.10.15-arm64" - ] - }, - "osx.10.16-x64": { - "#import": [ - "osx.10.16", - "osx.10.15-x64" - ] - }, - "osx.11.0": { - "#import": [ - "osx.10.16" - ] - }, - "osx.11.0-arm64": { - "#import": [ - "osx.11.0", - "osx.10.16-arm64" - ] - }, - "osx.11.0-x64": { - "#import": [ - "osx.11.0", - "osx.10.16-x64" - ] - }, - "rhel": { - "#import": [ - "linux" - ] - }, - "rhel-arm64": { - "#import": [ - "rhel", - "linux-arm64" - ] - }, - "rhel-x64": { - "#import": [ - "rhel", - "linux-x64" - ] - }, - "rhel.6": { - "#import": [ - "rhel" - ] - }, - "rhel.6-x64": { - "#import": [ - "rhel.6", - "rhel-x64" - ] - }, - "rhel.7": { - "#import": [ - "rhel" - ] - }, - "rhel.7-x64": { - "#import": [ - "rhel.7", - "rhel-x64" - ] - }, - "rhel.7.0": { - "#import": [ - "rhel.7" - ] - }, - "rhel.7.0-x64": { - "#import": [ - "rhel.7.0", - "rhel.7-x64" - ] - }, - "rhel.7.1": { - "#import": [ - "rhel.7.0" - ] - }, - "rhel.7.1-x64": { - "#import": [ - "rhel.7.1", - "rhel.7.0-x64" - ] - }, - "rhel.7.2": { - "#import": [ - "rhel.7.1" - ] - }, - "rhel.7.2-x64": { - "#import": [ - "rhel.7.2", - "rhel.7.1-x64" - ] - }, - "rhel.7.3": { - "#import": [ - "rhel.7.2" - ] - }, - "rhel.7.3-x64": { - "#import": [ - "rhel.7.3", - "rhel.7.2-x64" - ] - }, - "rhel.7.4": { - "#import": [ - "rhel.7.3" - ] - }, - "rhel.7.4-x64": { - "#import": [ - "rhel.7.4", - "rhel.7.3-x64" - ] - }, - "rhel.7.5": { - "#import": [ - "rhel.7.4" - ] - }, - "rhel.7.5-x64": { - "#import": [ - "rhel.7.5", - "rhel.7.4-x64" - ] - }, - "rhel.7.6": { - "#import": [ - "rhel.7.5" - ] - }, - "rhel.7.6-x64": { - "#import": [ - "rhel.7.6", - "rhel.7.5-x64" - ] - }, - "rhel.8": { - "#import": [ - "rhel" - ] - }, - "rhel.8-arm64": { - "#import": [ - "rhel.8", - "rhel-arm64" - ] - }, - "rhel.8-x64": { - "#import": [ - "rhel.8", - "rhel-x64" - ] - }, - "rhel.8.0": { - "#import": [ - "rhel.8" - ] - }, - "rhel.8.0-arm64": { - "#import": [ - "rhel.8.0", - "rhel.8-arm64" - ] - }, - "rhel.8.0-x64": { - "#import": [ - "rhel.8.0", - "rhel.8-x64" - ] - }, - "rhel.8.1": { - "#import": [ - "rhel.8.0" - ] - }, - "rhel.8.1-arm64": { - "#import": [ - "rhel.8.1", - "rhel.8.0-arm64" - ] - }, - "rhel.8.1-x64": { - "#import": [ - "rhel.8.1", - "rhel.8.0-x64" - ] - }, - "rhel.9": { - "#import": [ - "rhel" - ] - }, - "rhel.9-arm64": { - "#import": [ - "rhel.9", - "rhel-arm64" - ] - }, - "rhel.9-x64": { - "#import": [ - "rhel.9", - "rhel-x64" - ] - }, - "ubuntu": { - "#import": [ - "debian" - ] - }, - "ubuntu-arm": { - "#import": [ - "ubuntu", - "debian-arm" - ] - }, - "ubuntu-x64": { - "#import": [ - "ubuntu", - "debian-x64" - ] - }, - "ubuntu-x86": { - "#import": [ - "ubuntu", - "debian-x86" - ] - }, - "ubuntu.14.04": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.14.04-arm": { - "#import": [ - "ubuntu.14.04", - "ubuntu-arm" - ] - }, - "ubuntu.14.04-x64": { - "#import": [ - "ubuntu.14.04", - "ubuntu-x64" - ] - }, - "ubuntu.14.04-x86": { - "#import": [ - "ubuntu.14.04", - "ubuntu-x86" - ] - }, - "ubuntu.14.10": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.14.10-arm": { - "#import": [ - "ubuntu.14.10", - "ubuntu-arm" - ] - }, - "ubuntu.14.10-x64": { - "#import": [ - "ubuntu.14.10", - "ubuntu-x64" - ] - }, - "ubuntu.14.10-x86": { - "#import": [ - "ubuntu.14.10", - "ubuntu-x86" - ] - }, - "ubuntu.15.04": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.15.04-arm": { - "#import": [ - "ubuntu.15.04", - "ubuntu-arm" - ] - }, - "ubuntu.15.04-x64": { - "#import": [ - "ubuntu.15.04", - "ubuntu-x64" - ] - }, - "ubuntu.15.04-x86": { - "#import": [ - "ubuntu.15.04", - "ubuntu-x86" - ] - }, - "ubuntu.15.10": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.15.10-arm": { - "#import": [ - "ubuntu.15.10", - "ubuntu-arm" - ] - }, - "ubuntu.15.10-x64": { - "#import": [ - "ubuntu.15.10", - "ubuntu-x64" - ] - }, - "ubuntu.15.10-x86": { - "#import": [ - "ubuntu.15.10", - "ubuntu-x86" - ] - }, - "unix": { - "#import": [ - "any" - ] - }, - "unix-arm": { - "#import": [ - "unix" - ] - }, - "unix-arm64": { - "#import": [ - "unix" - ] - }, - "unix-armel": { - "#import": [ - "unix" - ] - }, - "unix-mips64": { - "#import": [ - "unix" - ] - }, - "unix-x64": { - "#import": [ - "unix" - ] - }, - "unix-x86": { - "#import": [ - "unix" - ] - }, - "win": { - "#import": [ - "any" - ] - }, - "win-aot": { - "#import": [ - "win", - "aot" - ] - }, - "win-arm": { - "#import": [ - "win" - ] - }, - "win-arm-aot": { - "#import": [ - "win-aot", - "win-arm" - ] - }, - "win-arm64": { - "#import": [ - "win" - ] - }, - "win-arm64-aot": { - "#import": [ - "win-aot", - "win-arm64" - ] - }, - "win-x128": { - "#import": [ - "win" - ] - }, - "win-x128-aot": { - "#import": [ - "win-aot", - "win-x128" - ] - }, - "win-x64": { - "#import": [ - "win" - ] - }, - "win-x64-aot": { - "#import": [ - "win-aot", - "win-x64" - ] - }, - "win-x86": { - "#import": [ - "win" - ] - }, - "win-x86-aot": { - "#import": [ - "win-aot", - "win-x86" - ] - }, - "win10": { - "#import": [ - "win81" - ] - }, - "win10-aot": { - "#import": [ - "win10", - "win81-aot" - ] - }, - "win10-arm": { - "#import": [ - "win10", - "win81-arm" - ] - }, - "win10-arm-aot": { - "#import": [ - "win10-aot", - "win10-arm", - "win10", - "win81-arm-aot" - ] - }, - "win10-arm64": { - "#import": [ - "win10", - "win81-arm64" - ] - }, - "win10-arm64-aot": { - "#import": [ - "win10-aot", - "win10-arm64", - "win10", - "win81-arm64-aot" - ] - }, - "win10-x64": { - "#import": [ - "win10", - "win81-x64" - ] - }, - "win10-x64-aot": { - "#import": [ - "win10-aot", - "win10-x64", - "win10", - "win81-x64-aot" - ] - }, - "win10-x86": { - "#import": [ - "win10", - "win81-x86" - ] - }, - "win10-x86-aot": { - "#import": [ - "win10-aot", - "win10-x86", - "win10", - "win81-x86-aot" - ] - }, - "win12": { - "#import": [ - "win" - ] - }, - "win12-aot": { - "#import": [ - "win12", - "win-aot" - ] - }, - "win12-x128": { - "#import": [ - "win12", - "win-x128" - ] - }, - "win12-x128-aot": { - "#import": [ - "win12-aot", - "win12-x128", - "win12", - "win-x128-aot" - ] - }, - "win7": { - "#import": [ - "win" - ] - }, - "win7-aot": { - "#import": [ - "win7", - "win-aot" - ] - }, - "win7-arm": { - "#import": [ - "win7", - "win-arm" - ] - }, - "win7-arm-aot": { - "#import": [ - "win7-aot", - "win7-arm", - "win7", - "win-arm-aot" - ] - }, - "win7-arm64": { - "#import": [ - "win7", - "win-arm64" - ] - }, - "win7-arm64-aot": { - "#import": [ - "win7-aot", - "win7-arm64", - "win7", - "win-arm64-aot" - ] - }, - "win7-x64": { - "#import": [ - "win7", - "win-x64" - ] - }, - "win7-x64-aot": { - "#import": [ - "win7-aot", - "win7-x64", - "win7", - "win-x64-aot" - ] - }, - "win7-x86": { - "#import": [ - "win7", - "win-x86" - ] - }, - "win7-x86-aot": { - "#import": [ - "win7-aot", - "win7-x86", - "win7", - "win-x86-aot" - ] - }, - "win8": { - "#import": [ - "win7" - ] - }, - "win8-aot": { - "#import": [ - "win8", - "win7-aot" - ] - }, - "win8-arm": { - "#import": [ - "win8", - "win7-arm" - ] - }, - "win8-arm-aot": { - "#import": [ - "win8-aot", - "win8-arm", - "win8", - "win7-arm-aot" - ] - }, - "win8-arm64": { - "#import": [ - "win8", - "win7-arm64" - ] - }, - "win8-arm64-aot": { - "#import": [ - "win8-aot", - "win8-arm64", - "win8", - "win7-arm64-aot" - ] - }, - "win8-x64": { - "#import": [ - "win8", - "win7-x64" - ] - }, - "win8-x64-aot": { - "#import": [ - "win8-aot", - "win8-x64", - "win8", - "win7-x64-aot" - ] - }, - "win8-x86": { - "#import": [ - "win8", - "win7-x86" - ] - }, - "win8-x86-aot": { - "#import": [ - "win8-aot", - "win8-x86", - "win8", - "win7-x86-aot" - ] - }, - "win81": { - "#import": [ - "win8" - ] - }, - "win81-aot": { - "#import": [ - "win81", - "win8-aot" - ] - }, - "win81-arm": { - "#import": [ - "win81", - "win8-arm" - ] - }, - "win81-arm-aot": { - "#import": [ - "win81-aot", - "win81-arm", - "win81", - "win8-arm-aot" - ] - }, - "win81-arm64": { - "#import": [ - "win81", - "win8-arm64" - ] - }, - "win81-arm64-aot": { - "#import": [ - "win81-aot", - "win81-arm64", - "win81", - "win8-arm64-aot" - ] - }, - "win81-x64": { - "#import": [ - "win81", - "win8-x64" - ] - }, - "win81-x64-aot": { - "#import": [ - "win81-aot", - "win81-x64", - "win81", - "win8-x64-aot" - ] - }, - "win81-x86": { - "#import": [ - "win81", - "win8-x86" - ] - }, - "win81-x86-aot": { - "#import": [ - "win81-aot", - "win81-x86", - "win81", - "win8-x86-aot" - ] - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json deleted file mode 100644 index 621fa0b47eb..00000000000 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.CanInferRids.runtime.json +++ /dev/null @@ -1,1108 +0,0 @@ -{ - "runtimes": { - "any": { - "#import": [] - }, - "aot": { - "#import": [] - }, - "centos": { - "#import": [ - "rhel" - ] - }, - "centos-arm64": { - "#import": [ - "centos", - "rhel-arm64" - ] - }, - "centos-x64": { - "#import": [ - "centos", - "rhel-x64" - ] - }, - "centos.7": { - "#import": [ - "centos", - "rhel.7" - ] - }, - "centos.7-x64": { - "#import": [ - "centos.7", - "centos-x64", - "rhel.7-x64" - ] - }, - "centos.8": { - "#import": [ - "centos", - "rhel.8" - ] - }, - "centos.8-arm64": { - "#import": [ - "centos.8", - "centos-arm64", - "rhel.8-arm64" - ] - }, - "centos.8-x64": { - "#import": [ - "centos.8", - "centos-x64", - "rhel.8-x64" - ] - }, - "centos.9": { - "#import": [ - "centos", - "rhel.9" - ] - }, - "centos.9-arm64": { - "#import": [ - "centos.9", - "centos-arm64", - "rhel.9-arm64" - ] - }, - "centos.9-x64": { - "#import": [ - "centos.9", - "centos-x64", - "rhel.9-x64" - ] - }, - "centos.9.2": { - "#import": [ - "centos", - "rhel.9.2" - ] - }, - "centos.9.2-arm64": { - "#import": [ - "centos.9.2", - "centos-arm64", - "rhel.9.2-arm64" - ] - }, - "centos.9.2-x64": { - "#import": [ - "centos.9.2", - "centos-x64", - "rhel.9.2-x64" - ] - }, - "debian": { - "#import": [ - "linux" - ] - }, - "debian-arm": { - "#import": [ - "debian", - "linux-arm" - ] - }, - "debian-arm64": { - "#import": [ - "debian", - "linux-arm64" - ] - }, - "debian-armel": { - "#import": [ - "debian", - "linux-armel" - ] - }, - "debian-x64": { - "#import": [ - "debian", - "linux-x64" - ] - }, - "debian-x86": { - "#import": [ - "debian", - "linux-x86" - ] - }, - "debian.10": { - "#import": [ - "debian" - ] - }, - "debian.10-arm": { - "#import": [ - "debian.10", - "debian-arm" - ] - }, - "debian.10-arm64": { - "#import": [ - "debian.10", - "debian-arm64" - ] - }, - "debian.10-armel": { - "#import": [ - "debian.10", - "debian-armel" - ] - }, - "debian.10-x64": { - "#import": [ - "debian.10", - "debian-x64" - ] - }, - "debian.10-x86": { - "#import": [ - "debian.10", - "debian-x86" - ] - }, - "debian.8": { - "#import": [ - "debian" - ] - }, - "debian.8-arm": { - "#import": [ - "debian.8", - "debian-arm" - ] - }, - "debian.8-arm64": { - "#import": [ - "debian.8", - "debian-arm64" - ] - }, - "debian.8-armel": { - "#import": [ - "debian.8", - "debian-armel" - ] - }, - "debian.8-x64": { - "#import": [ - "debian.8", - "debian-x64" - ] - }, - "debian.8-x86": { - "#import": [ - "debian.8", - "debian-x86" - ] - }, - "debian.9": { - "#import": [ - "debian" - ] - }, - "debian.9-arm": { - "#import": [ - "debian.9", - "debian-arm" - ] - }, - "debian.9-arm64": { - "#import": [ - "debian.9", - "debian-arm64" - ] - }, - "debian.9-armel": { - "#import": [ - "debian.9", - "debian-armel" - ] - }, - "debian.9-x64": { - "#import": [ - "debian.9", - "debian-x64" - ] - }, - "debian.9-x86": { - "#import": [ - "debian.9", - "debian-x86" - ] - }, - "linux": { - "#import": [ - "unix" - ] - }, - "linux-arm": { - "#import": [ - "linux", - "unix-arm" - ] - }, - "linux-arm64": { - "#import": [ - "linux", - "unix-arm64" - ] - }, - "linux-armel": { - "#import": [ - "linux", - "unix-armel" - ] - }, - "linux-mips64": { - "#import": [ - "linux", - "unix-mips64" - ] - }, - "linux-x64": { - "#import": [ - "linux", - "unix-x64" - ] - }, - "linux-x86": { - "#import": [ - "linux", - "unix-x86" - ] - }, - "osx": { - "#import": [ - "unix" - ] - }, - "osx-arm64": { - "#import": [ - "osx", - "unix-arm64" - ] - }, - "osx-x64": { - "#import": [ - "osx", - "unix-x64" - ] - }, - "osx.10.10": { - "#import": [ - "osx" - ] - }, - "osx.10.10-arm64": { - "#import": [ - "osx.10.10", - "osx-arm64" - ] - }, - "osx.10.10-x64": { - "#import": [ - "osx.10.10", - "osx-x64" - ] - }, - "osx.10.11": { - "#import": [ - "osx.10.10" - ] - }, - "osx.10.11-arm64": { - "#import": [ - "osx.10.11", - "osx.10.10-arm64" - ] - }, - "osx.10.11-x64": { - "#import": [ - "osx.10.11", - "osx.10.10-x64" - ] - }, - "osx.10.12": { - "#import": [ - "osx.10.11" - ] - }, - "osx.10.12-arm64": { - "#import": [ - "osx.10.12", - "osx.10.11-arm64" - ] - }, - "osx.10.12-x64": { - "#import": [ - "osx.10.12", - "osx.10.11-x64" - ] - }, - "osx.10.13": { - "#import": [ - "osx.10.12" - ] - }, - "osx.10.13-arm64": { - "#import": [ - "osx.10.13", - "osx.10.12-arm64" - ] - }, - "osx.10.13-x64": { - "#import": [ - "osx.10.13", - "osx.10.12-x64" - ] - }, - "osx.10.14": { - "#import": [ - "osx.10.13" - ] - }, - "osx.10.14-arm64": { - "#import": [ - "osx.10.14", - "osx.10.13-arm64" - ] - }, - "osx.10.14-x64": { - "#import": [ - "osx.10.14", - "osx.10.13-x64" - ] - }, - "osx.10.15": { - "#import": [ - "osx.10.14" - ] - }, - "osx.10.15-arm64": { - "#import": [ - "osx.10.15", - "osx.10.14-arm64" - ] - }, - "osx.10.15-x64": { - "#import": [ - "osx.10.15", - "osx.10.14-x64" - ] - }, - "osx.10.16": { - "#import": [ - "osx.10.15" - ] - }, - "osx.10.16-arm64": { - "#import": [ - "osx.10.16", - "osx.10.15-arm64" - ] - }, - "osx.10.16-x64": { - "#import": [ - "osx.10.16", - "osx.10.15-x64" - ] - }, - "osx.11.0": { - "#import": [ - "osx.10.16" - ] - }, - "osx.11.0-arm64": { - "#import": [ - "osx.11.0", - "osx.10.16-arm64" - ] - }, - "osx.11.0-x64": { - "#import": [ - "osx.11.0", - "osx.10.16-x64" - ] - }, - "rhel": { - "#import": [ - "linux" - ] - }, - "rhel-arm64": { - "#import": [ - "rhel", - "linux-arm64" - ] - }, - "rhel-x64": { - "#import": [ - "rhel", - "linux-x64" - ] - }, - "rhel.6": { - "#import": [ - "rhel" - ] - }, - "rhel.6-x64": { - "#import": [ - "rhel.6", - "rhel-x64" - ] - }, - "rhel.7": { - "#import": [ - "rhel" - ] - }, - "rhel.7-x64": { - "#import": [ - "rhel.7", - "rhel-x64" - ] - }, - "rhel.7.0": { - "#import": [ - "rhel.7" - ] - }, - "rhel.7.0-x64": { - "#import": [ - "rhel.7.0", - "rhel.7-x64" - ] - }, - "rhel.7.1": { - "#import": [ - "rhel.7.0" - ] - }, - "rhel.7.1-x64": { - "#import": [ - "rhel.7.1", - "rhel.7.0-x64" - ] - }, - "rhel.7.2": { - "#import": [ - "rhel.7.1" - ] - }, - "rhel.7.2-x64": { - "#import": [ - "rhel.7.2", - "rhel.7.1-x64" - ] - }, - "rhel.7.3": { - "#import": [ - "rhel.7.2" - ] - }, - "rhel.7.3-x64": { - "#import": [ - "rhel.7.3", - "rhel.7.2-x64" - ] - }, - "rhel.7.4": { - "#import": [ - "rhel.7.3" - ] - }, - "rhel.7.4-x64": { - "#import": [ - "rhel.7.4", - "rhel.7.3-x64" - ] - }, - "rhel.7.5": { - "#import": [ - "rhel.7.4" - ] - }, - "rhel.7.5-x64": { - "#import": [ - "rhel.7.5", - "rhel.7.4-x64" - ] - }, - "rhel.7.6": { - "#import": [ - "rhel.7.5" - ] - }, - "rhel.7.6-x64": { - "#import": [ - "rhel.7.6", - "rhel.7.5-x64" - ] - }, - "rhel.8": { - "#import": [ - "rhel" - ] - }, - "rhel.8-arm64": { - "#import": [ - "rhel.8", - "rhel-arm64" - ] - }, - "rhel.8-x64": { - "#import": [ - "rhel.8", - "rhel-x64" - ] - }, - "rhel.8.0": { - "#import": [ - "rhel.8" - ] - }, - "rhel.8.0-arm64": { - "#import": [ - "rhel.8.0", - "rhel.8-arm64" - ] - }, - "rhel.8.0-x64": { - "#import": [ - "rhel.8.0", - "rhel.8-x64" - ] - }, - "rhel.8.1": { - "#import": [ - "rhel.8.0" - ] - }, - "rhel.8.1-arm64": { - "#import": [ - "rhel.8.1", - "rhel.8.0-arm64" - ] - }, - "rhel.8.1-x64": { - "#import": [ - "rhel.8.1", - "rhel.8.0-x64" - ] - }, - "rhel.9": { - "#import": [ - "rhel" - ] - }, - "rhel.9-arm64": { - "#import": [ - "rhel.9", - "rhel-arm64" - ] - }, - "rhel.9-x64": { - "#import": [ - "rhel.9", - "rhel-x64" - ] - }, - "rhel.9.2": { - "#import": [ - "rhel.9" - ] - }, - "rhel.9.2-arm64": { - "#import": [ - "rhel.9.2", - "rhel.9-arm64" - ] - }, - "rhel.9.2-x64": { - "#import": [ - "rhel.9.2", - "rhel.9-x64" - ] - }, - "ubuntu": { - "#import": [ - "debian" - ] - }, - "ubuntu-arm": { - "#import": [ - "ubuntu", - "debian-arm" - ] - }, - "ubuntu-x64": { - "#import": [ - "ubuntu", - "debian-x64" - ] - }, - "ubuntu-x86": { - "#import": [ - "ubuntu", - "debian-x86" - ] - }, - "ubuntu.14.04": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.14.04-arm": { - "#import": [ - "ubuntu.14.04", - "ubuntu-arm" - ] - }, - "ubuntu.14.04-x64": { - "#import": [ - "ubuntu.14.04", - "ubuntu-x64" - ] - }, - "ubuntu.14.04-x86": { - "#import": [ - "ubuntu.14.04", - "ubuntu-x86" - ] - }, - "ubuntu.14.10": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.14.10-arm": { - "#import": [ - "ubuntu.14.10", - "ubuntu-arm" - ] - }, - "ubuntu.14.10-x64": { - "#import": [ - "ubuntu.14.10", - "ubuntu-x64" - ] - }, - "ubuntu.14.10-x86": { - "#import": [ - "ubuntu.14.10", - "ubuntu-x86" - ] - }, - "ubuntu.15.04": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.15.04-arm": { - "#import": [ - "ubuntu.15.04", - "ubuntu-arm" - ] - }, - "ubuntu.15.04-x64": { - "#import": [ - "ubuntu.15.04", - "ubuntu-x64" - ] - }, - "ubuntu.15.04-x86": { - "#import": [ - "ubuntu.15.04", - "ubuntu-x86" - ] - }, - "ubuntu.15.10": { - "#import": [ - "ubuntu" - ] - }, - "ubuntu.15.10-arm": { - "#import": [ - "ubuntu.15.10", - "ubuntu-arm" - ] - }, - "ubuntu.15.10-x64": { - "#import": [ - "ubuntu.15.10", - "ubuntu-x64" - ] - }, - "ubuntu.15.10-x86": { - "#import": [ - "ubuntu.15.10", - "ubuntu-x86" - ] - }, - "unix": { - "#import": [ - "any" - ] - }, - "unix-arm": { - "#import": [ - "unix" - ] - }, - "unix-arm64": { - "#import": [ - "unix" - ] - }, - "unix-armel": { - "#import": [ - "unix" - ] - }, - "unix-mips64": { - "#import": [ - "unix" - ] - }, - "unix-x64": { - "#import": [ - "unix" - ] - }, - "unix-x86": { - "#import": [ - "unix" - ] - }, - "win": { - "#import": [ - "any" - ] - }, - "win-aot": { - "#import": [ - "win", - "aot" - ] - }, - "win-arm": { - "#import": [ - "win" - ] - }, - "win-arm-aot": { - "#import": [ - "win-aot", - "win-arm" - ] - }, - "win-arm64": { - "#import": [ - "win" - ] - }, - "win-arm64-aot": { - "#import": [ - "win-aot", - "win-arm64" - ] - }, - "win-x64": { - "#import": [ - "win" - ] - }, - "win-x64-aot": { - "#import": [ - "win-aot", - "win-x64" - ] - }, - "win-x86": { - "#import": [ - "win" - ] - }, - "win-x86-aot": { - "#import": [ - "win-aot", - "win-x86" - ] - }, - "win10": { - "#import": [ - "win81" - ] - }, - "win10-aot": { - "#import": [ - "win10", - "win81-aot" - ] - }, - "win10-arm": { - "#import": [ - "win10", - "win81-arm" - ] - }, - "win10-arm-aot": { - "#import": [ - "win10-aot", - "win10-arm", - "win10", - "win81-arm-aot" - ] - }, - "win10-arm64": { - "#import": [ - "win10", - "win81-arm64" - ] - }, - "win10-arm64-aot": { - "#import": [ - "win10-aot", - "win10-arm64", - "win10", - "win81-arm64-aot" - ] - }, - "win10-x64": { - "#import": [ - "win10", - "win81-x64" - ] - }, - "win10-x64-aot": { - "#import": [ - "win10-aot", - "win10-x64", - "win10", - "win81-x64-aot" - ] - }, - "win10-x86": { - "#import": [ - "win10", - "win81-x86" - ] - }, - "win10-x86-aot": { - "#import": [ - "win10-aot", - "win10-x86", - "win10", - "win81-x86-aot" - ] - }, - "win7": { - "#import": [ - "win" - ] - }, - "win7-aot": { - "#import": [ - "win7", - "win-aot" - ] - }, - "win7-arm": { - "#import": [ - "win7", - "win-arm" - ] - }, - "win7-arm-aot": { - "#import": [ - "win7-aot", - "win7-arm", - "win7", - "win-arm-aot" - ] - }, - "win7-arm64": { - "#import": [ - "win7", - "win-arm64" - ] - }, - "win7-arm64-aot": { - "#import": [ - "win7-aot", - "win7-arm64", - "win7", - "win-arm64-aot" - ] - }, - "win7-x64": { - "#import": [ - "win7", - "win-x64" - ] - }, - "win7-x64-aot": { - "#import": [ - "win7-aot", - "win7-x64", - "win7", - "win-x64-aot" - ] - }, - "win7-x86": { - "#import": [ - "win7", - "win-x86" - ] - }, - "win7-x86-aot": { - "#import": [ - "win7-aot", - "win7-x86", - "win7", - "win-x86-aot" - ] - }, - "win8": { - "#import": [ - "win7" - ] - }, - "win8-aot": { - "#import": [ - "win8", - "win7-aot" - ] - }, - "win8-arm": { - "#import": [ - "win8", - "win7-arm" - ] - }, - "win8-arm-aot": { - "#import": [ - "win8-aot", - "win8-arm", - "win8", - "win7-arm-aot" - ] - }, - "win8-arm64": { - "#import": [ - "win8", - "win7-arm64" - ] - }, - "win8-arm64-aot": { - "#import": [ - "win8-aot", - "win8-arm64", - "win8", - "win7-arm64-aot" - ] - }, - "win8-x64": { - "#import": [ - "win8", - "win7-x64" - ] - }, - "win8-x64-aot": { - "#import": [ - "win8-aot", - "win8-x64", - "win8", - "win7-x64-aot" - ] - }, - "win8-x86": { - "#import": [ - "win8", - "win7-x86" - ] - }, - "win8-x86-aot": { - "#import": [ - "win8-aot", - "win8-x86", - "win8", - "win7-x86-aot" - ] - }, - "win81": { - "#import": [ - "win8" - ] - }, - "win81-aot": { - "#import": [ - "win81", - "win8-aot" - ] - }, - "win81-arm": { - "#import": [ - "win81", - "win8-arm" - ] - }, - "win81-arm-aot": { - "#import": [ - "win81-aot", - "win81-arm", - "win81", - "win8-arm-aot" - ] - }, - "win81-arm64": { - "#import": [ - "win81", - "win8-arm64" - ] - }, - "win81-arm64-aot": { - "#import": [ - "win81-aot", - "win81-arm64", - "win81", - "win8-arm64-aot" - ] - }, - "win81-x64": { - "#import": [ - "win81", - "win8-x64" - ] - }, - "win81-x64-aot": { - "#import": [ - "win81-aot", - "win81-x64", - "win81", - "win8-x64-aot" - ] - }, - "win81-x86": { - "#import": [ - "win81", - "win8-x86" - ] - }, - "win81-x86-aot": { - "#import": [ - "win81-aot", - "win81-x86", - "win81", - "win8-x86-aot" - ] - } - } -} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs index c129187388d..160e39bb886 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Packaging/tests/GenerateRuntimeGraphTests.cs @@ -7,6 +7,9 @@ using Xunit.Abstractions; using FluentAssertions; using System.IO; +using System.Collections.Generic; +using System.Linq; +using System; namespace Microsoft.DotNet.Build.Tasks.Packaging.Tests { @@ -41,43 +44,53 @@ public void CanCreateRuntimeGraph() } [Fact] - public void CanInferRids() + public void CanAddVersionsToExistingGroups() { - string runtimeFile = $"{nameof(GenerateRuntimeGraphTests)}.{nameof(CanInferRids)}.runtime.json"; + List groups = runtimeGroups.Select(g => new RuntimeGroup(g)).ToList(); - // will generate and compare to existing file. - GenerateRuntimeGraph task = new GenerateRuntimeGraph() - { - BuildEngine = _engine, - RuntimeGroups = runtimeGroups, - RuntimeJson = runtimeFile, - InferRuntimeIdentifiers = new[] { "rhel.9.2-x64", "centos.9.2-arm64" } - }; + RuntimeGroup rhelGroup = groups.Where(g => g.BaseRID.Equals("rhel", StringComparison.Ordinal) && + g.Versions.Contains(new RuntimeVersion("9")) && + g.Architectures.Contains("x64")).Single(); + RuntimeGroup centosGroup = groups.Where(g => g.BaseRID.Equals("centos", StringComparison.Ordinal) && + g.Versions.Contains(new RuntimeVersion("9")) && + g.Architectures.Contains("arm64")).Single(); - _log.Reset(); - task.Execute(); - _log.ErrorsLogged.Should().Be(0); - _log.WarningsLogged.Should().Be(0); + GenerateRuntimeGraph.AddRuntimeIdentifiers(groups, new[] { "rhel.9.2-x64", "centos.9.2-arm64" }, null); + + rhelGroup.Versions.Should().Contain(new RuntimeVersion("9.2")); + centosGroup.Versions.Should().Contain(new RuntimeVersion("9.2")); } [Fact] - public void CanInferNewArchitecture() + public void CanAddArchitectureToExistingGroups() { - string runtimeFile = $"{nameof(GenerateRuntimeGraphTests)}.{nameof(CanInferNewArchitecture)}.runtime.json"; + List groups = runtimeGroups.Select(g => new RuntimeGroup(g)).ToList(); + List originalGroups = new List(groups); + GenerateRuntimeGraph.AddRuntimeIdentifiers(groups, new[] { "win10-x128" }, null); - // will generate and compare to existing file. - GenerateRuntimeGraph task = new GenerateRuntimeGraph() + groups.Except(originalGroups).Should().SatisfyRespectively(g => { - BuildEngine = _engine, - RuntimeGroups = runtimeGroups, - RuntimeJson = runtimeFile, - InferRuntimeIdentifiers = new[] { "win12-x128" } - }; + Assert.Equal("win", g.BaseRID); + Assert.Equal("any", g.Parent); + g.Versions.Should().SatisfyRespectively(v => Assert.Equal(new RuntimeVersion("10"), v)); + g.Architectures.Should().SatisfyRespectively(a => Assert.Equal("x128", a)); + }); + } - _log.Reset(); - task.Execute(); - _log.ErrorsLogged.Should().Be(0); - _log.WarningsLogged.Should().Be(0); + [Fact] + public void CanAdNewGroups() + { + List groups = runtimeGroups.Select(g => new RuntimeGroup(g)).ToList(); + List originalGroups = new List(groups); + GenerateRuntimeGraph.AddRuntimeIdentifiers(groups, new[] { "yolinux.42.0-quantum" }, "linux"); + + groups.Except(originalGroups).Should().SatisfyRespectively(g => + { + Assert.Equal("yolinux", g.BaseRID); + Assert.Equal("linux", g.Parent); + g.Versions.Should().SatisfyRespectively(v => Assert.Equal(new RuntimeVersion("42.0"), v)); + g.Architectures.Should().SatisfyRespectively(a => Assert.Equal("quantum", a)); + }); } [Fact] @@ -92,7 +105,7 @@ public void CanIgnoreExistingInferRids() BuildEngine = _engine, RuntimeGroups = runtimeGroups, RuntimeJson = runtimeFile, - InferRuntimeIdentifiers = new[] { "rhel.9-x64", "centos.9-arm64", "win-x64" } + AdditionalRuntimeIdentifiers = new[] { "rhel.9-x64", "centos.9-arm64", "win-x64" } }; _log.Reset();