Skip to content

Commit 177651f

Browse files
committed
Fix test for non-portable RID
1 parent 894644d commit 177651f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ public GivenThatWeWantToPublishASingleFileApp(ITestOutputHelper log) : base(log)
4444
{
4545
}
4646

47-
private PublishCommand GetPublishCommand(string identifier = null, [CallerMemberName] string callingMethod = "")
47+
private PublishCommand GetPublishCommand(string identifier = null, [CallerMemberName] string callingMethod = "", Action<XDocument> projectChanges = null)
4848
{
49+
if (projectChanges == null)
50+
{
51+
projectChanges = d => { };
52+
}
53+
4954
var testAsset = _testAssetsManager
5055
.CopyTestAsset(TestProjectName, callingMethod, identifier)
51-
.WithSource();
56+
.WithSource()
57+
.WithProjectChanges(projectChanges);
5258

5359
// Create the following content:
5460
// <TestRoot>/SmallNameDir/This is a directory with a really long name for one that only contains a small file/.word
@@ -127,7 +133,17 @@ public void It_errors_when_publishing_single_file_without_apphost()
127133
public void It_generates_publishing_single_file_with_win7()
128134
{
129135
const string rid = "win7-x86";
130-
GetPublishCommand()
136+
137+
// Retarget project to net7.0, as net8.0 and up by default use portable runtime graph which doesn't have win7-* RIDs
138+
var projectChanges = (XDocument doc) =>
139+
{
140+
var ns = doc.Root.Name.Namespace;
141+
doc.Root.Element(ns + "PropertyGroup")
142+
.Element(ns + "TargetFramework")
143+
.Value = "net7.0";
144+
};
145+
146+
GetPublishCommand(projectChanges: projectChanges)
131147
.Execute($"/p:RuntimeIdentifier={rid}", PublishSingleFile)
132148
.Should()
133149
.Pass();

0 commit comments

Comments
 (0)