Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 370243a

Browse files
committed
Adding a work around for publishing self-contained apps to RIDs that are not available for Microsoft.NETCore.App 2.0.0.
1 parent 9b68d55 commit 370243a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

test/dotnet-publish.Tests/GivenDotnetPublishPublishesProjects.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
using System;
55
using System.IO;
66
using System.Diagnostics;
7+
using System.Linq;
78
using System.Runtime.InteropServices;
9+
using System.Xml.Linq;
810
using FluentAssertions;
911
using Microsoft.DotNet.Cli.Utils;
1012
using Microsoft.DotNet.PlatformAbstractions;
@@ -103,7 +105,19 @@ public void ItPublishesARunnableSelfContainedApp()
103105
var testInstance = TestAssets.Get(testAppName)
104106
.CreateInstance()
105107
.WithSourceFiles()
106-
.WithRestoreFiles();
108+
.WithProjectChanges(project =>
109+
{
110+
var ns = project.Root.Name.Namespace;
111+
112+
var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
113+
114+
// This is needed to be able to restore for RIDs that were not available in Microsoft.NetCore.App 2.0.0.
115+
// M.NC.App 2.0.0 depends on a version of Microsoft.NetCore.Platforms that lacks the mapping for the
116+
// latest RIDs. Given that self-contained apps are pinned to 2.0.0 in this version of the SDK, we
117+
// need a manual roll-forward.
118+
propertyGroup.Add(
119+
new XElement(ns + "RuntimeFrameworkVersion", "2.0.*"));
120+
});
107121

108122
var testProjectDirectory = testInstance.Root;
109123

@@ -170,7 +184,19 @@ private DirectoryInfo PublishAppWithSelfContained(string testAppName, bool selfC
170184
var testInstance = TestAssets.Get(testAppName)
171185
.CreateInstance($"PublishesSelfContained{selfContained}")
172186
.WithSourceFiles()
173-
.WithRestoreFiles();
187+
.WithProjectChanges(project =>
188+
{
189+
var ns = project.Root.Name.Namespace;
190+
191+
var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
192+
193+
// This is needed to be able to restore for RIDs that were not available in Microsoft.NetCore.App 2.0.0.
194+
// M.NC.App 2.0.0 depends on a version of Microsoft.NetCore.Platforms that lacks the mapping for the
195+
// latest RIDs. Given that self-contained apps are pinned to 2.0.0 in this version of the SDK, we
196+
// need a manual roll-forward.
197+
propertyGroup.Add(
198+
new XElement(ns + "RuntimeFrameworkVersion", "2.0.*"));
199+
});
174200

175201
var testProjectDirectory = testInstance.Root;
176202

0 commit comments

Comments
 (0)