Enable building WASDK Self-Contained packaged apps (#20019)
This commit is contained in:
Родитель
2c02adac74
Коммит
ff0aea335b
|
@ -76,7 +76,7 @@
|
|||
<!--
|
||||
Workaround for https://github.com/microsoft/WindowsAppSDK/issues/2684
|
||||
-->
|
||||
<Import Project="src\Core\src\nuget\buildTransitive\WinUI.Unpackaged.targets" Condition=" '$(WindowsPackageType)' == 'None' and '$(_MauiTargetPlatformIsWindows)' == 'True' " />
|
||||
<Import Project="src\Core\src\nuget\buildTransitive\WinUI.targets" Condition=" '$(WindowsPackageType)' == 'None' and '$(_MauiTargetPlatformIsWindows)' == 'True' " />
|
||||
|
||||
<!-- NuGet package information -->
|
||||
<PropertyGroup Condition="'$(IsPackable)' == 'true'">
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<!-- Workarounds for WinUI -->
|
||||
<Project>
|
||||
|
||||
<!--
|
||||
Workaround for https://github.com/microsoft/WindowsAppSDK/issues/2684
|
||||
This replaces the error check target entirely as it is not needed.
|
||||
-->
|
||||
<Target Name="WindowsAppSDKSelfContainedVerifyConfiguration">
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Workaround for https://github.com/microsoft/WindowsAppSDK/issues/2684
|
||||
This adjusts the items if we are still resolving to AnyCPU.
|
||||
-->
|
||||
<Target Name="_MAUIAfter_GetExtractMicrosoftWindowsAppSDKMsixFilesInputs"
|
||||
AfterTargets="GetExtractMicrosoftWindowsAppSDKMsixFilesInputs"
|
||||
Condition="'$(NativePlatform)' == 'AnyCPU'">
|
||||
<PropertyGroup>
|
||||
<NativePlatform>Invalid</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'x86'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'Win32'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'x64'">x64</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'arm'">arm</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'arm64'">arm64</NativePlatform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Platform)' == 'AnyCPU'">
|
||||
<NativePlatform>neutral</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-x86'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-x64'">x64</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-arm'">arm</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-arm64'">arm64</NativePlatform>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<MicrosoftWindowsAppSDKMsix Include="$([MSBuild]::NormalizeDirectory('$(MicrosoftWindowsAppSDKPackageDir)','tools\Msix\win10-$(NativePlatform)'))Microsoft.WindowsAppRuntime.?.?.Msix"/>
|
||||
<MicrosoftWindowsAppSDKMsix Include="$([MSBuild]::NormalizeDirectory('$(MicrosoftWindowsAppSDKPackageDir)','tools\Msix\win10-$(NativePlatform)'))Microsoft.WindowsAppRuntime.?.?-*.Msix"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -28,7 +28,37 @@
|
|||
|
||||
<!--
|
||||
Workaround for https://github.com/microsoft/WindowsAppSDK/issues/2684
|
||||
This replaces the error check target entirely as it is not needed.
|
||||
-->
|
||||
<Import Project="WinUI.Unpackaged.targets" Condition=" '$(WindowsPackageType)' == 'None' " />
|
||||
<Target Name="WindowsAppSDKSelfContainedVerifyConfiguration">
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Workaround for https://github.com/microsoft/WindowsAppSDK/issues/2684
|
||||
This adjusts the items if we are still resolving to AnyCPU.
|
||||
-->
|
||||
<Target Name="_MAUIAfter_GetExtractMicrosoftWindowsAppSDKMsixFilesInputs"
|
||||
AfterTargets="GetExtractMicrosoftWindowsAppSDKMsixFilesInputs"
|
||||
Condition="'$(NativePlatform)' == 'AnyCPU'">
|
||||
<PropertyGroup>
|
||||
<NativePlatform>Invalid</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'x86'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'Win32'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'x64'">x64</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'arm'">arm</NativePlatform>
|
||||
<NativePlatform Condition="'$(Platform)' == 'arm64'">arm64</NativePlatform>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Platform)' == 'AnyCPU'">
|
||||
<NativePlatform>neutral</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-x86'">x86</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-x64'">x64</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-arm'">arm</NativePlatform>
|
||||
<NativePlatform Condition="'$(RuntimeIdentifier)' == 'win10-arm64'">arm64</NativePlatform>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<MicrosoftWindowsAppSDKMsix Include="$([MSBuild]::NormalizeDirectory('$(MicrosoftWindowsAppSDKPackageDir)','tools\Msix\win10-$(NativePlatform)'))Microsoft.WindowsAppRuntime.?.?.Msix"/>
|
||||
<MicrosoftWindowsAppSDKMsix Include="$([MSBuild]::NormalizeDirectory('$(MicrosoftWindowsAppSDKPackageDir)','tools\Msix\win10-$(NativePlatform)'))Microsoft.WindowsAppRuntime.?.?-*.Msix"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -149,6 +149,36 @@ namespace Microsoft.Maui.IntegrationTests
|
|||
$"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,
|
||||
"<UseMaui>true</UseMaui>",
|
||||
$"""
|
||||
<UseMaui>true</UseMaui>
|
||||
<WindowsAppSDKSelfContained>{wasdkself}</WindowsAppSDKSelfContained>
|
||||
<SelfContained>{netself}</SelfContained>
|
||||
""");
|
||||
|
||||
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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче