diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/src/RuntimeLibrary.cs b/src/libraries/Microsoft.Extensions.DependencyModel/src/RuntimeLibrary.cs
index 336a57b9ed54f..417d68f83490e 100644
--- a/src/libraries/Microsoft.Extensions.DependencyModel/src/RuntimeLibrary.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyModel/src/RuntimeLibrary.cs
@@ -58,6 +58,31 @@ public RuntimeLibrary(string type,
{
}
+
+ ///
+ /// Initializes a new .
+ ///
+ /// The library's type.
+ /// The library's name.
+ /// The library's version.
+ /// The library package's hash.
+ /// The library's runtime assemblies.
+ /// The library's native libraries.
+ /// The library's resource assemblies.
+ /// The library's dependencies.
+ /// Whether the library is serviceable.
+ /// The library package's path.
+ /// The library package's hash path.
+ /// The library's runtime store manifest name.
+ ///
+ /// The argument is null.
+ /// The argument is null.
+ /// The argument is null.
+ /// The argument is null.
+ /// The argument is null.
+ /// The argument is null.
+ /// The argument is null.
+ ///
public RuntimeLibrary(string type,
string name,
string version,
diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonReaderTest.cs b/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonReaderTest.cs
index cf3b27e965b74..ecafadcc0a9b6 100644
--- a/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonReaderTest.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonReaderTest.cs
@@ -665,6 +665,46 @@ public void IgnoresUnknownPropertiesInRuntimeTargets()
.Which.AssetPaths.Should().BeEmpty();
}
+ [Fact]
+ public void ReadsRuntimePackLibrary()
+ {
+ var context = Read(
+@"{
+ ""runtimeTarget"": {
+ ""name"": "".NETCoreApp,Version=v5.0/win-x86"",
+ ""signature"": """"
+ },
+ ""targets"": {
+ "".NETCoreApp,Version=v5.0/win-x86"": {
+ ""runtimepack.Microsoft.NETCore.App.Runtime.win-x86/5.0.0-preview.5.20251.1"": {
+ ""runtime"": {
+ ""System.Private.CoreLib.dll"": {
+ ""assemblyVersion"": ""5.0.0.0"",
+ ""fileVersion"": ""5.0.20.25101""
+ }
+ },
+ ""native"": {
+ ""coreclr.dll"": {
+ ""fileVersion"": ""5.0.20.25101""
+ }
+ }
+ }
+ }
+ },
+ ""libraries"": {
+ ""runtimepack.Microsoft.NETCore.App.Runtime.win-x86/5.0.0-preview.5.20251.1"": {
+ ""type"": ""runtimepack"",
+ ""serviceable"": false,
+ ""sha512"": """"
+ }
+ }
+}");
+
+ var runtimeLibrary = context.RuntimeLibraries.Should().ContainSingle().Subject;
+ runtimeLibrary.Type.Should().Be("runtimepack");
+ runtimeLibrary.Serviceable.Should().Be(false);
+ }
+
[Fact]
public void ReadsCompilationOptions()
{
diff --git a/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonWriterTests.cs b/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonWriterTests.cs
index 0762b3ef3db26..c6c752c6fbb05 100644
--- a/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonWriterTests.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyModel/tests/DependencyContextJsonWriterTests.cs
@@ -299,6 +299,68 @@ private JObject WritesRuntimeLibrariesToRuntimeTargetCore(RuntimeAssetGroup grou
return runtimeAssembly;
}
+ [Fact]
+ public void WritesRuntimePackLibrariesWithFrameworkName()
+ {
+ var result = Save(Create(
+ "Target",
+ "win-x86",
+ false,
+ runtimeLibraries: new[]
+ {
+ new RuntimeLibrary(
+ "runtimepack",
+ "RuntimePackName",
+ "1.2.3",
+ "HASH",
+ new [] {
+ new RuntimeAssetGroup(
+ string.Empty,
+ new []
+ {
+ new RuntimeFile("System.Private.CoreLib.dll", "2.3.4", "3.4.5"),
+ }),
+ },
+ new [] {
+ new RuntimeAssetGroup(
+ string.Empty,
+ new []
+ {
+ new RuntimeFile("coreclr.dll", "4.5.6", "5.6.7"),
+ }),
+ },
+ new ResourceAssembly[0],
+ new Dependency[0],
+ false,
+ "PackagePath",
+ "PackageHashPath",
+ "placeHolderManifest.xml"
+ ),
+ }));
+
+ // targets
+ var targets = result.Should().HavePropertyAsObject("targets").Subject;
+ var target = targets.Should().HavePropertyAsObject("Target/win-x86").Subject;
+ var library = target.Should().HavePropertyAsObject("RuntimePackName/1.2.3").Subject;
+ library.Should().NotHaveProperty("dependencies");
+ library.Should().NotHaveProperty("resources");
+
+ library.Should().HavePropertyAsObject("runtime")
+ .Subject.Should().HaveProperty("System.Private.CoreLib.dll");
+ library.Should().HavePropertyAsObject("native")
+ .Subject.Should().HaveProperty("coreclr.dll");
+
+ //libraries
+ var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
+ library = libraries.Should().HavePropertyAsObject("RuntimePackName/1.2.3").Subject;
+ library.Should().HavePropertyValue("sha512", "HASH");
+ library.Should().HavePropertyValue("type", "runtimepack");
+ library.Should().HavePropertyValue("serviceable", false);
+ library.Should().HavePropertyValue("path", "PackagePath");
+ library.Should().HavePropertyValue("hashPath", "PackageHashPath");
+ library.Should().HavePropertyValue("runtimeStoreManifestName", "placeHolderManifest.xml");
+ }
+
[Fact]
public void MergesRuntimeAndCompileLibrariesForPortable()
{