fix: Adjust the use of EnableCoreMrtTooling in winappsdk libraries

This commit is contained in:
Jérôme Laban 2024-03-20 10:21:30 -04:00 коммит произвёл GitHub
Родитель dc0c74c461
Коммит 6f3da83934
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 83 добавлений и 38 удалений

Просмотреть файл

@ -148,26 +148,26 @@ Get-ChildItem -Recurse -Filter global.json | ForEach-Object {
$projects =
@(
# 5.1 Blank
@("5.1/uno51blank/uno51blank.Mobile/uno51blank.Mobile.csproj", ""),
@("5.1/uno51blank/uno51blank.Skia.Gtk/uno51blank.Skia.Gtk.csproj", ""),
@("5.1/uno51blank/uno51blank.Skia.Linux.FrameBuffer/uno51blank.Skia.Linux.FrameBuffer.csproj", ""),
@("5.1/uno51blank/uno51blank.Skia.Wpf/uno51blank.Skia.Wpf.csproj", ""),
@("5.1/uno51blank/uno51blank.Wasm/uno51blank.Wasm.csproj", ""),
@("5.1/uno51blank/uno51blank.Windows/uno51blank.Windows.csproj", ""),
@("5.1/uno51blank/uno51blank.Mobile/uno51blank.Mobile.csproj", "", $true),
@("5.1/uno51blank/uno51blank.Skia.Gtk/uno51blank.Skia.Gtk.csproj", "", $true),
@("5.1/uno51blank/uno51blank.Skia.Linux.FrameBuffer/uno51blank.Skia.Linux.FrameBuffer.csproj", "", $true),
@("5.1/uno51blank/uno51blank.Skia.Wpf/uno51blank.Skia.Wpf.csproj", "", $true),
@("5.1/uno51blank/uno51blank.Wasm/uno51blank.Wasm.csproj", "", $true),
@("5.1/uno51blank/uno51blank.Windows/uno51blank.Windows.csproj", "", $false),
# 5.1 Recommended
@("5.1/uno51recommended/uno51recommended.Mobile/uno51recommended.Mobile.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Windows/uno51recommended.Windows.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Skia.Gtk/uno51recommended.Skia.Gtk.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Skia.Linux.FrameBuffer/uno51recommended.Skia.Linux.FrameBuffer.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Skia.Wpf/uno51recommended.Skia.Wpf.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Wasm/uno51recommended.Wasm.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Server/uno51recommended.Server.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Tests/uno51recommended.Tests.csproj", ""),
@("5.1/uno51recommended/uno51recommended.UITests/uno51recommended.UITests.csproj", ""),
@("5.1/uno51recommended/uno51recommended.Mobile/uno51recommended.Mobile.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Windows/uno51recommended.Windows.csproj", "", $false),
@("5.1/uno51recommended/uno51recommended.Skia.Gtk/uno51recommended.Skia.Gtk.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Skia.Linux.FrameBuffer/uno51recommended.Skia.Linux.FrameBuffer.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Skia.Wpf/uno51recommended.Skia.Wpf.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Wasm/uno51recommended.Wasm.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Server/uno51recommended.Server.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.Tests/uno51recommended.Tests.csproj", "", $true),
@("5.1/uno51recommended/uno51recommended.UITests/uno51recommended.UITests.csproj", "", $true),
# 5.2 Blank
@("5.2/uno52blank/uno52blank/uno52blank.csproj", "")
@("5.2/uno52blank/uno52blank/uno52blank.csproj", "", $true)
## Note for contributors
##
@ -179,12 +179,26 @@ for($i = 0; $i -lt $projects.Length; $i++)
{
$projectPath=$projects[$i][0];
$projectOptions=$projects[$i][1];
$buildWithNetCore=$projects[$i][2];
Write-Host "Building Debug $projectPath with $projectOptions"
dotnet build $debug "$projectPath" $projectOptions
Assert-ExitCodeIsZero
if ($buildWithNetCore)
{
Write-Host "NetCore Building Debug $projectPath with $projectOptions"
dotnet build $debug "$projectPath" $projectOptions
Assert-ExitCodeIsZero
Write-Host "Building Release $projectPath with $projectOptions"
dotnet build $release "$projectPath" $projectOptions
Assert-ExitCodeIsZero
Write-Host "NetCore Building Release $projectPath with $projectOptions"
dotnet build $release "$projectPath" $projectOptions
Assert-ExitCodeIsZero
}
else
{
Write-Host "MSBuild Building Debug $projectPath with $projectOptions"
$msbuild $debug "$projectPath" $projectOptions
Assert-ExitCodeIsZero
Write-Host "MSBuild Building Release $projectPath with $projectOptions"
$msbuild $release "$projectPath" $projectOptions
Assert-ExitCodeIsZero
}
}

Просмотреть файл

@ -47,6 +47,14 @@ The build process has determined that you have specified an UnoFeature that requ
The build process has detected that you have set the value `UnoGenerateAotProfile` to true for a build configuration that has not optimized the assembly (i.e. Debug build Configuration). You should only generate an AOT profile from a build Configuration that will optimize the assembly such as the Release build Configuration.
### UNOB0008: Building a WinUI class library with dotnet build is not supported
Building a `net8.0-windows10.x.x` class library using `dotnet build` is not supported at this time because of a [Windows App SDK issue](https://github.com/microsoft/WindowsAppSDK/issues/3548), when the library contains XAML files.
To work around this, use `msbuild /r` on Windows. You can build using `msbuild` with a **Developer Command Prompt for VS 2022**, or by using `vswhere` or using [GitHub actions scripts](https://learn.microsoft.com/en-us/windows/apps/package-and-deploy/ci-for-winui3?pivots=winui3-packaged-csharp) in a CI environment.
This particular check can be disabled by setting the msbuild property `UnoDisableValidateWinAppSDK3548` to `true`.
## Compiler Errors
### UNO0001

Просмотреть файл

@ -49,4 +49,14 @@
</ItemGroup>
</When>
</Choose>
<Target Name="_UnoValidateAssemblyResources"
BeforeTargets="AfterBuild"
Condition="'$(TargetFramework)'=='$(DotNetVersion)-windows10.0.19041'">
<!-- Related to https://github.com/unoplatform/uno/issues/15492 to ensure that library assets are properly generated -->
<Error Text="Missing uno51blank\AppResources.xaml"
Condition="!exists('$(OutputPath)\uno51blank\AppResources.xaml')" />
</Target>
</Project>

Просмотреть файл

@ -3,13 +3,15 @@
<IsWinAppSdk>true</IsWinAppSdk>
<TargetPlatformMinVersion Condition=" $(TargetPlatformMinVersion) == '' ">10.0.18362.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition=" $(SupportedOSPlatformVersion) == '' ">$(TargetPlatformMinVersion)</SupportedOSPlatformVersion>
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' AND '$(BuildingInsideVisualStudio)' != 'true' ">false</EnableCoreMrtTooling>
<!-- Set EnableMsixTooling to true only for executables - setting this on class libraries prevents assets from being correctly copied to windows target -->
<EnableMsixTooling Condition=" $(EnableMsixTooling) == '' AND ('$(OutputType)' == 'WinExe' OR '$(OutputType)' == 'Exe') ">true</EnableMsixTooling>
<EnableWindowsTargeting Condition=" $(EnableWindowsTargeting) == '' ">true</EnableWindowsTargeting>
<EnableDefaultWindowsItems Condition="$(EnableDefaultWindowsItems) == ''">false</EnableDefaultWindowsItems>
<!-- Required to override the `win10-xxx` identifiers that cannot work with class libraries -->
<RuntimeIdentifiers Condition="'$(RuntimeIdentifiers)'==''">win-x86;win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition=" $(_IsExecutable) == 'true' ">
@ -17,21 +19,18 @@
<EnableMsixTooling Condition=" $(EnableMsixTooling) == '' ">true</EnableMsixTooling>
</PropertyGroup>
<Choose>
<When Condition="$(BuildingInsideVisualStudio) == 'true'">
<PropertyGroup Condition="$(OutputType) != 'WinExe' AND $(OutputType) != 'Exe'">
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' ">false</EnableCoreMrtTooling>
<EnableMsixTooling Condition=" $(EnableMsixTooling) == '' ">false</EnableMsixTooling>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<!-- Workaround Uno Issue 15492 - This must be set to true for the Library so that the generated files use the Library name in the path -->
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' AND $(OutputType) != 'WinExe' AND $(OutputType) != 'Exe' ">true</EnableCoreMrtTooling>
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' AND '$(MSBuildRuntimeType)' == 'Core' ">false</EnableCoreMrtTooling>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<!-- Workaround Uno Issue 15492 - This must be set to true for the Library so that the generated files use the Library name in the path -->
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' AND !$(_IsExecutable) AND '$(MSBuildRuntimeType)' != 'Core'">true</EnableCoreMrtTooling>
<!--
This change provides the ability to use `dotnet build` but this can only work for the head
projects, not libraries.
Related to https://github.com/microsoft/WindowsAppSDK/issues/3548
-->
<EnableCoreMrtTooling Condition=" $(EnableCoreMrtTooling) == '' AND '$(MSBuildRuntimeType)' == 'Core' ">false</EnableCoreMrtTooling>
</PropertyGroup>
<PropertyGroup Condition="$(SingleProject)!='true' and $(_IsExecutable) == 'true'">
<ApplicationManifest Condition=" $(ApplicationManifest) == '' ">app.manifest</ApplicationManifest>
@ -53,4 +52,18 @@
<Import Project="Uno.SingleProject.WinAppSdk.targets"
Condition=" $(SingleProject) == 'true' " />
<Target Name="_UnoValidateWinAppSDK3548"
BeforeTargets="BeforeBuild"
Condition="
'$(UnoDisableValidateWinAppSDK3548)' != 'true'
AND $(EnableCoreMrtTooling) == 'false'
AND !$(_IsExecutable)
AND '$(MSBuildRuntimeType)' == 'Core'
AND '@(Page)' != '' ">
<Error Code="UNOB0008"
HelpLink="https://aka.platform.uno/UNOB0008"
Text="Building a WinUI class library with dotnet build is not supported when XAML files are present. Use `msbuild` instead." />
</Target>
</Project>