From ed55172d062ca8560a9e68dde193115b38ea47c1 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Fri, 29 Nov 2024 16:02:40 +0800 Subject: [PATCH] Official Windows.UI.Xaml Modern .NET support (#32) * Use official Windows.UI.Xaml Modern .NET support * Enable Windows.UI.Xaml XAML templates in VS 17.12 for .NET Framework projects * Add Notes About Modern .NET Support --- Mile.Xaml.Managed/Mile.Xaml.Managed.csproj | 4 ++- Mile.Xaml/Mile.Xaml.nuspec | 4 +-- Mile.Xaml/NuGet/net48/Mile.Xaml.props | 7 ++++- Mile.Xaml/NuGet/net8.0/Mile.Xaml.props | 32 ++++++++++++++++++---- Mile.Xaml/NuGet/net8.0/Mile.Xaml.targets | 15 ++++++++++ ReadMe.md | 26 ++++++++++++++++++ 6 files changed, 78 insertions(+), 10 deletions(-) diff --git a/Mile.Xaml.Managed/Mile.Xaml.Managed.csproj b/Mile.Xaml.Managed/Mile.Xaml.Managed.csproj index 52fbdd9..f1313ab 100644 --- a/Mile.Xaml.Managed/Mile.Xaml.Managed.csproj +++ b/Mile.Xaml.Managed/Mile.Xaml.Managed.csproj @@ -18,7 +18,9 @@ Windows true - $([System.Version]::Parse('$(TargetPlatformMinVersion)').ToString(3)).39 + true + false + $([System.Version]::Parse('$(TargetPlatformMinVersion)').ToString(3)).57 diff --git a/Mile.Xaml/Mile.Xaml.nuspec b/Mile.Xaml/Mile.Xaml.nuspec index fd99d4e..278db61 100644 --- a/Mile.Xaml/Mile.Xaml.nuspec +++ b/Mile.Xaml/Mile.Xaml.nuspec @@ -25,9 +25,7 @@ - - - + diff --git a/Mile.Xaml/NuGet/net48/Mile.Xaml.props b/Mile.Xaml/NuGet/net48/Mile.Xaml.props index 6b9077f..abc9cea 100644 --- a/Mile.Xaml/NuGet/net48/Mile.Xaml.props +++ b/Mile.Xaml/NuGet/net48/Mile.Xaml.props @@ -31,4 +31,9 @@ UAP - + + + + + + \ No newline at end of file diff --git a/Mile.Xaml/NuGet/net8.0/Mile.Xaml.props b/Mile.Xaml/NuGet/net8.0/Mile.Xaml.props index 98d588c..ab1a94c 100644 --- a/Mile.Xaml/NuGet/net8.0/Mile.Xaml.props +++ b/Mile.Xaml/NuGet/net8.0/Mile.Xaml.props @@ -3,14 +3,36 @@ PROJECT: Mouri Internal Library Essentials FILE: Mile.Xaml.props PURPOSE: MSBuild props file for Mile.Xaml .NET 8 target + Note: .NET 9 SDK or higher is required LICENSE: The MIT License DEVELOPER: driver1998 (github.com/driver1998) --> - - - $(DefineConstants);DISABLE_XAML_GENERATED_MAIN - - + + + $(DefineConstants);DISABLE_XAML_GENERATED_MAIN + + false + + false + + <_EnableWindowsDesktopNetCoreFrameworkReferences>true + + true + + true + + false + + false + + + $(CustomAfterMicrosoftCSharpTargets); + $(MSBuildThisFileDirectory)..\MrtCore.PriGen.targets; + + + UAP + + \ No newline at end of file diff --git a/Mile.Xaml/NuGet/net8.0/Mile.Xaml.targets b/Mile.Xaml/NuGet/net8.0/Mile.Xaml.targets index 44a25ab..6a4f8ab 100644 --- a/Mile.Xaml/NuGet/net8.0/Mile.Xaml.targets +++ b/Mile.Xaml/NuGet/net8.0/Mile.Xaml.targets @@ -18,4 +18,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 7c10503..5c8aaef 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -42,6 +42,32 @@ XAML controls (Mile.Xaml.Styles.SunValley.xbf) to your project's output folder, please set `true` in your project configuration file. +## Notes About Modern .NET Support + +Modern .NET support is based on the +[official UWP Support in .NET 9 SDK](https://devblogs.microsoft.com/ifdef-windows/preview-uwp-support-for-dotnet-9-native-aot/), +which requires the following components: + +- .NET 9.0 SDK +- Visual Studio 2022 v17.12 +- Windows 11 SDK 26100.1882 + +Warning: the MSI version of Windows 11 SDK (and the 26100 SDK provided in VS) +is still at 26100.1742, which does not support the C#/WinRT mode of UWP XAML compiler. + +If you installed it, you may see similar errors during build: + +``` +error MSB4064: The "UsingCsWinRT" parameter is not supported by the "CompileXaml" task loaded from assembly: Microsoft.Windows.UI.Xaml.Build.Tasks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 from the path: C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\XamlCompiler\Microsoft.Windows.UI.Xaml.Build.Tasks.dll. Verify that the parameter exists on the task, the points to the correct assembly, and it is a settable public instance property. +``` + +Installing a newer NuGet version of SDK on your project **may not work**, +as VS will still prefer the globally installed version. + +To workaround this, you need to manually upgrade the XAML compiler in Windows SDK. +[Download the standalone XAML compiler from Microsoft](https://aka.ms/preview-uwp-support-for-dotnet9-windows-sdk) +and follow the instructions in the README file. + ## System Requirements - Supported OS: Windows 10 Version 2004 (Build 19041) or later