Skip to content

Commit 8b82d23

Browse files
committed
Test for MTP SelfContained
1 parent 55d3bd9 commit 8b82d23

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/Microsoft.NET.Build.Tests/ReferenceExeTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,5 +519,45 @@ public void ExeProjectCanReferenceTestProject(string testTemplateName)
519519
.Should()
520520
.Pass();
521521
}
522+
523+
[Theory]
524+
[CombinatorialData]
525+
public void MTPCanBeBuiltAsSelfContained(bool setIsTestingPlatformApplicationEarly)
526+
{
527+
var mtpSelfContained = new TestProject("MTPTestProject")
528+
{
529+
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
530+
IsExe = true,
531+
IsTestProject = true,
532+
SelfContained = "true",
533+
};
534+
535+
if (setIsTestingPlatformApplicationEarly)
536+
{
537+
mtpSelfContained.IsTestingPlatformApplication = true;
538+
}
539+
540+
var testAssetMTP = _testAssetsManager.CreateTestProject(mtpSelfContained);
541+
542+
var mtpProjectDirectory = Path.Combine(testAssetMTP.Path, mtpSelfContained.Name);
543+
Assert.True(Directory.Exists(mtpProjectDirectory), $"Expected directory {mtpProjectDirectory} to exist.");
544+
Assert.True(File.Exists(Path.Combine(mtpProjectDirectory, "MTPTestProject.csproj")), $"Expected file MTPTestProject.csproj to exist in {mtpProjectDirectory}.");
545+
546+
if (!setIsTestingPlatformApplicationEarly)
547+
{
548+
File.WriteAllText(Path.Combine(mtpProjectDirectory, "Directory.Build.targets"), """
549+
<Project>
550+
<PropertyGroup>
551+
<IsTestingPlatformApplication>true</IsTestingPlatformApplication>
552+
</PropertyGroup>
553+
</Project>
554+
""");
555+
}
556+
557+
new BuildCommand(Log, mtpProjectDirectory)
558+
.Execute()
559+
.Should()
560+
.Pass();
561+
}
522562
}
523563
}

0 commit comments

Comments
 (0)