diff --git a/doc/toc.yml b/doc/toc.yml index ae824ff..17a94a5 100644 --- a/doc/toc.yml +++ b/doc/toc.yml @@ -1,4 +1,4 @@ -- name: Uno the Xaml Merge task +- name: Using Uno.XamlMerge.Task topicHref: using-xamlmerge.md -- name: Troubleshooting - href: troubleshooting.md \ No newline at end of file +- name: Troubleshooting the Uno.XamlMerge.Task generation + href: troubleshooting.md diff --git a/doc/troubleshooting.md b/doc/troubleshooting.md index b0dca8f..a363ed3 100644 --- a/doc/troubleshooting.md +++ b/doc/troubleshooting.md @@ -1,3 +1,6 @@ -## Troubleshooting +# Troubleshooting the Uno.XamlMerge.Task generation + +If you encountered any issues using Uno.XamlMerge.Task: + - Make sure that all namespaces definitions across files are of the same values. (e.g. `xlmns:ns1="http://site1"` and `xlmns: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. \ No newline at end of file +- 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. diff --git a/doc/using-xamlmerge.md b/doc/using-xamlmerge.md index 8fb99a8..626a653 100644 --- a/doc/using-xamlmerge.md +++ b/doc/using-xamlmerge.md @@ -1,79 +1,88 @@ # Uno.XamlMerge.Task -An msbuild task which enables the merging of WinUI XAML resource dictionaries into a single flat ResourceDictionary. + +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`](https://github.com/microsoft/microsoft-ui-xaml/blob/a1ace7957abc19bce86141203560e15a737ccac7/tools/CustomTasks/BatchMergeXaml.cs) 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. +## 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 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: - -```xml - - <_Uno_XamlMerge_Task_Version>1.0.0 - - - - -``` - -Then select the resource dictionaries to be merged: -```xml - - - -``` - -> 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](https://github.com/unoplatform/uno.themes). - -Then add the following block at the end your project library or app: - -```xml - -``` - -The generated file is called `Generated\mergedpages.xaml` by default, but can be overriden as follows: - -```xml - - Themes\Generic.xaml - -``` -Otherwise, the generated file can be referenced as follows: -```xml - - - - - - -``` +1. In your `csproj` file, include the following block: + + ```xml + + <_Uno_XamlMerge_Task_Version>1.0.0 + + + + + ``` + +1. Specify the resource dictionaries to be merged: + + ```xml + + + + ``` + + > [!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](https://github.com/unoplatform/uno.themes). + +1. Add the following block at the end your project library or app: + + ```xml + + ``` + +1. By default, the generated file is called `Generated\mergedpages.xaml`, but can be overridden as follows: + + ```xml + + Themes\Generic.xaml + + ``` + +1. The generated file can be referenced as follows: + + ```xml + + + + + + + ``` ## 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. + +There are scenarios where placing groups of XAML files in separate merged files are useful, particularly, when IL Linking must be used. In this case, the project file must be defined as follows: + ```xml - - - + + + - - - + + + ``` In this case, the `XamlMergeOutputFile` cannot be used, as the `XamlMergeOutputFiles` is defined. ## Further reading -- [Troubleshooting the generation](troubleshooting.md) + +- [Troubleshooting the Uno.XamlMerge.Task generation](troubleshooting.md)