Skip to content

Commit 00f9da4

Browse files
committed
Enable building WASDK Self-Contained packaged apps
1 parent c02195d commit 00f9da4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,33 @@ public void BuildUnpackaged(string id, string framework, string config)
113113
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");
114114
}
115115

116+
[Test]
117+
[TestCase("maui", true, true)]
118+
[TestCase("maui", true, false)]
119+
[TestCase("maui", false, true)]
120+
public void BuildSelfContained(string id, bool wasdkself, bool netself)
121+
{
122+
var projectDir = TestDirectory;
123+
var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj");
124+
125+
Assert.IsTrue(DotnetInternal.New(id, projectDir, DotNetCurrent),
126+
$"Unable to create template {id}. Check test output for errors.");
127+
128+
FileUtilities.ReplaceInFile(projectFile,
129+
"<UseMaui>true</UseMaui>",
130+
$"""
131+
<UseMaui>true</UseMaui>
132+
<WindowsAppSDKSelfContained>{wasdkself}</WindowsAppSDKSelfContained>
133+
<SelfContained>{netself}</SelfContained>
134+
""");
135+
136+
var extendedBuildProps = BuildProps;
137+
extendedBuildProps.Add($"TargetFramework={DotNetCurrent}-windows10.0.19041.0");
138+
139+
Assert.IsTrue(DotnetInternal.Build(projectFile, "Release", properties: extendedBuildProps, msbuildWarningsAsErrors: true),
140+
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");
141+
}
142+
116143
[Test]
117144
[TestCase("maui", $"{DotNetCurrent}-ios", "ios-arm64")]
118145
public void PublishNativeAOT(string id, string framework, string runtimeIdentifier)

0 commit comments

Comments
 (0)