From 4a1d4d54d28fc419edd9e7fce81548a85215f3bf Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 19 Jan 2024 23:02:39 +0200 Subject: [PATCH] Enable building WASDK Self-Contained packaged apps --- Directory.Build.targets | 2 +- .../buildTransitive/WinUI.Unpackaged.targets | 39 ------------------- .../src/nuget/buildTransitive/WinUI.targets | 32 ++++++++++++++- .../TemplateTests.cs | 30 ++++++++++++++ 4 files changed, 62 insertions(+), 41 deletions(-) delete mode 100644 src/Core/src/nuget/buildTransitive/WinUI.Unpackaged.targets diff --git a/Directory.Build.targets b/Directory.Build.targets index b6c48d5223eb..5feebecca537 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -76,7 +76,7 @@ - + diff --git a/src/Core/src/nuget/buildTransitive/WinUI.Unpackaged.targets b/src/Core/src/nuget/buildTransitive/WinUI.Unpackaged.targets deleted file mode 100644 index 6ea3566ce2bc..000000000000 --- a/src/Core/src/nuget/buildTransitive/WinUI.Unpackaged.targets +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - Invalid - x86 - x86 - x64 - arm - arm64 - - - neutral - x86 - x64 - arm - arm64 - - - - - - - - diff --git a/src/Core/src/nuget/buildTransitive/WinUI.targets b/src/Core/src/nuget/buildTransitive/WinUI.targets index e6a9d3e59b13..84feb7671501 100644 --- a/src/Core/src/nuget/buildTransitive/WinUI.targets +++ b/src/Core/src/nuget/buildTransitive/WinUI.targets @@ -28,7 +28,37 @@ - + + + + + + + Invalid + x86 + x86 + x64 + arm + arm64 + + + neutral + x86 + x64 + arm + arm64 + + + + + + diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs index 53b3087746ba..8deedb9d715a 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs @@ -113,6 +113,36 @@ public void BuildUnpackaged(string id, string framework, string config) $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); } + [Test] + [TestCase("maui", true, true)] + [TestCase("maui", true, false)] + [TestCase("maui", false, true)] + public void BuildWindowsAppSDKSelfContained(string id, bool wasdkself, bool netself) + { + if (TestEnvironment.IsMacOS) + Assert.Ignore("This test is designed for testing a windows build."); + + var projectDir = TestDirectory; + var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj"); + + Assert.IsTrue(DotnetInternal.New(id, projectDir, DotNetCurrent), + $"Unable to create template {id}. Check test output for errors."); + + FileUtilities.ReplaceInFile(projectFile, + "true", + $""" + true + {wasdkself} + {netself} + """); + + var extendedBuildProps = BuildProps; + extendedBuildProps.Add($"TargetFramework={DotNetCurrent}-windows10.0.19041.0"); + + Assert.IsTrue(DotnetInternal.Build(projectFile, "Release", properties: extendedBuildProps, msbuildWarningsAsErrors: true), + $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); + } + [Test] [TestCase("maui", $"{DotNetCurrent}-ios", "ios-arm64")] public void PublishNativeAOT(string id, string framework, string runtimeIdentifier)