Uno.XamlMerge.Task
1.1.0-dev.12
Prefix Reserved
See the version list below for details.
dotnet add package Uno.XamlMerge.Task --version 1.1.0-dev.12
NuGet\Install-Package Uno.XamlMerge.Task -Version 1.1.0-dev.12
<PackageReference Include="Uno.XamlMerge.Task" Version="1.1.0-dev.12" />
paket add Uno.XamlMerge.Task --version 1.1.0-dev.12
#r "nuget: Uno.XamlMerge.Task, 1.1.0-dev.12"
// Install Uno.XamlMerge.Task as a Cake Addin #addin nuget:?package=Uno.XamlMerge.Task&version=1.1.0-dev.12&prerelease // Install Uno.XamlMerge.Task as a Cake Tool #tool nuget:?package=Uno.XamlMerge.Task&version=1.1.0-dev.12&prerelease
Uno.XamlMerge.Task
An msbuild task which enables the merging of WinUI XAML resource dictionaries into a single flat ResourceDictionary.
This code is derived from WinUI's BatchMergeXaml
class, to be reused in any WinUI and Uno Platform Controls library.
Why merge ResourceDictionary instances ?
This task is generally used to allow for separate resource dictionary authoring (which makes them easier to load and read) to avoid impacting resources lookup runtime performance. In WinUI, ResourceDictionary resolution is performed through a graph traversal of MergedDictionaries, which generally implies that a worse case resolution can require as many lookups as there are dictionaries.
To limit the impact of the traversal, this task task takes all resource dictionaries found in a specific MSBuild item group, and merges them into a single file. This file is then generally either named Themes\Generic.xaml
or referenced as a merged dictionary from another Themes\Generic.xaml
file.
Using the task
Include the following block:
<PropertyGroup>
<_Uno_XamlMerge_Task_Version>1.0.0</_Uno_XamlMerge_Task_Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Uno.XamlMerge.Task" Version="$(_Uno_XamlMerge_Task_Version)" />
</ItemGroup>
Then select the resource dictionaries to be merged:
<ItemGroup>
<XamlMergeInput Include="Styles\**\*.xaml" Exclude="Styles\Generic.xaml" />
</ItemGroup>
Note: The
Exclude
portion is only needed if some of your dictionaries still need to be referenced explicitly as some libraries require valid full path, such as Uno.Themes.
Then add the following block at the end your project library or app:
<Import Project="$(NuGetPackageRoot)uno.xamlmerge.task\$(_Uno_XamlMerge_Task_Version)\build\Uno.XamlMerge.Task.targets"
Condition="'$(TargetFramework)' == '' and '$(TargetFrameworks)'!='' and exists('$(NuGetPackageRoot)\uno.xamlmerge.task\$(_Uno_XamlMerge_Task_Version)')" />
The generated file is called Generated\mergedpages.xaml
by default, but can be overriden as follows:
<PropertyGroup>
<XamlMergeOutputFile>Themes\Generic.xaml</XamlMergeOutputFile>
</PropertyGroup>
Otherwise, the generated file can be referenced as follows:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestLibrary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///REPLACE_ME/Generated/mergedpages.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Multiple generated files
There are scenarios where placing groups of XAML files in separate merged file are useful, particularly when IL Linking must be used.
In this case, the project file must be defined as follows:
<ItemGroup>
<XamlMergeOutputFiles Include="Generated\MergedPart1.xaml" />
<XamlMergeOutputFiles Include="Generated\MergedPart2.xaml" />
<XamlMergeInput Include="Styles\Part1\**\*.xaml" Exclude="Styles\Generic.xaml" MergeFile="MergedPart1.xaml" />
<XamlMergeInput Include="Styles\Part2\**\*.xaml" Exclude="Styles\Generic.xaml" MergeFile="MergedPart2.xaml" />
</ItemGroup>
In this case, the XamlMergeOutputFile
cannot be used, as the XamlMergeOutputFiles
is defined.
Troubleshooting
- Make sure that all namespaces definitions across files are of the same values. (e.g.
xlmns:ns1="http://site1"
andxlmns:ns1="http://site2"
in two different files will fail) - If you include the same resource dictionary (e.g. Colors.xaml) file in multiple merged files (generally used to have a file for custom brushes and colors), you can remove those multiple inclusions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Uno.XamlMerge.Task:
Package | Downloads |
---|---|
Nventive.View.Uno
Nventive.View.Uno |
|
Nventive.View.Uno.WinUI
Nventive.View.Uno.WinUI |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Uno.XamlMerge.Task:
Repository | Stars |
---|---|
unoplatform/uno
Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
|
|
unoplatform/Uno.Themes
This library is designed to help you use the Material, Fluent or Cupertino design system with the Uno Platform
|
Version | Downloads | Last updated |
---|---|---|
1.34.0-dev.3 | 253 | 11/21/2024 |
1.33.1 | 81 | 11/21/2024 |
1.33.0-dev.2 | 40 | 11/21/2024 |
1.32.0-dev.61 | 48,146 | 12/5/2023 |
1.31.0-dev.59 | 105 | 11/8/2023 |
1.30.0-dev.54 | 80 | 11/8/2023 |
1.29.0-dev.52 | 76 | 11/8/2023 |
1.28.0-dev.46 | 79 | 11/8/2023 |
1.27.0-dev.44 | 180,775 | 7/21/2023 |
1.26.0-dev.40 | 88,259 | 2/17/2023 |
1.25.0-dev.38 | 159 | 2/17/2023 |
1.24.0-dev.34 | 130 | 2/15/2023 |
1.23.0-dev.24 | 184 | 2/8/2023 |
1.22.0-dev.22 | 1,988 | 1/12/2023 |
1.21.0-dev.21 | 172 | 12/19/2022 |
1.20.0-dev.20 | 112 | 12/19/2022 |
1.19.0-dev.19 | 112 | 12/19/2022 |
1.18.0-dev.18 | 163 | 12/16/2022 |
1.16.0-dev.16 | 1,113 | 11/23/2022 |
1.15.0-dev.15 | 111 | 11/23/2022 |
1.14.0-dev.14 | 109 | 11/22/2022 |
1.4.0-dev.8 | 38 | 11/21/2024 |
1.4.0-dev.7 | 33 | 11/20/2024 |
1.1.0-dev.13 | 43,253 | 5/13/2022 |
1.1.0-dev.12 | 95,514 | 4/13/2022 |
1.1.0-dev.11 | 130 | 4/13/2022 |
1.1.0-dev.10 | 147 | 4/12/2022 |
1.1.0-dev.9 | 140 | 4/11/2022 |
1.1.0-dev.8 | 214 | 4/8/2022 |
1.1.0-dev.7 | 130 | 4/8/2022 |
1.1.0-dev.6 | 140 | 4/7/2022 |
1.1.0-dev.5 | 135 | 4/7/2022 |
1.1.0-dev.4 | 138 | 4/7/2022 |
1.1.0-dev.3 | 252 | 3/8/2022 |
1.1.0-dev.2 | 3,038 | 2/25/2022 |
1.1.0-dev.1 | 129 | 2/23/2022 |
1.0.0 | 123,720 | 2/8/2022 |
0.1.0-dev.51 | 12,595 | 1/19/2022 |
0.1.0-dev.50 | 172 | 1/12/2022 |
0.1.0-dev.48 | 2,868 | 1/10/2022 |
0.1.0-dev.47 | 7,661 | 1/6/2022 |
0.1.0-dev.46 | 2,603 | 1/5/2022 |
0.1.0-dev.45 | 157 | 1/5/2022 |
0.1.0-dev.44 | 148 | 1/4/2022 |
0.1.0-dev.43 | 147 | 1/4/2022 |
0.1.0-dev.42 | 196 | 1/3/2022 |
0.1.0-dev.41 | 514 | 12/14/2021 |
0.1.0-dev.37 | 166 | 12/14/2021 |
# (2022-04-13)
### Bug Fixes
* Adjust assembly name rename ([#37](https://github.com/unoplatform/uno.xamlmerge.task/issues/37)) ([f70d6dd](https://github.com/unoplatform/uno.xamlmerge.task/commit/f70d6dd72ea98be335f201527f1230f1625a94a4))
* Adjust for incorrect duplicate page items ([#53](https://github.com/unoplatform/uno.xamlmerge.task/issues/53)) ([2f8b59d](https://github.com/unoplatform/uno.xamlmerge.task/commit/2f8b59df79a3b23a76127e208b524d03f6950f30))
* Allow for the same file to be present in multiple output ([#58](https://github.com/unoplatform/uno.xamlmerge.task/issues/58)) ([093fec3](https://github.com/unoplatform/uno.xamlmerge.task/commit/093fec3f7224f5eac998824834a0859df073871a))
* Avoid conflicts when a key is named like a TargetType ([#36](https://github.com/unoplatform/uno.xamlmerge.task/issues/36)) ([fc436ca](https://github.com/unoplatform/uno.xamlmerge.task/commit/fc436caebc467ab7827c69046d3aedde9a3b7aa4))
* Invalid merge inclusion ([#60](https://github.com/unoplatform/uno.xamlmerge.task/issues/60)) ([a7c211c](https://github.com/unoplatform/uno.xamlmerge.task/commit/a7c211c9c0d0ce5e8ac7ebfa72e4a321826bd083))
* Missing import for single merge file ([#54](https://github.com/unoplatform/uno.xamlmerge.task/issues/54)) ([f6c0fb0](https://github.com/unoplatform/uno.xamlmerge.task/commit/f6c0fb0e9a09a8616db6b49f811d8704e85fca86))
### Features
* Add support for multiple output merged files ([#50](https://github.com/unoplatform/uno.xamlmerge.task/issues/50)) ([c646cbd](https://github.com/unoplatform/uno.xamlmerge.task/commit/c646cbd7f91e3c563b558d06f86dd1adb804c447))