This is the package that contains the MSBuild tasks to automate the generation of the color overrides file in projects using Uno.
License
—
Deps
0
Install Size
—
Vulns
✓ 0
Published
Jun 14, 2024
$ dotnet add package Uno.Dsp.TasksThis is the package that contains the MSBuild tasks to automate the generation of the color overrides file in projects using Uno.
This is used to generate the Color Overrides file for projects with DSP Tooling like documented in the official documentation.
⚠️ Uno.Sdk
If you are using
Uno.Sdkproject style, you don't need to add the reference to theUno.Dsp.Taskspackage. See below for more information on its usage.
Theme files are used to define the color palette of a theme and can be generated using the Material V3 Theme Builder web site. Simply export using the "Material Theme (JSON)" format and download the generated json file.
You need to add reference to the Uno.Dsp.Tasks package in the project where you want the color overrides file to be generated.
[-- MyProject.Shared\MyProject.Shared.csproj --]
<ItemGroup>
[-- You'll need to replace the version for the proper one --]
<PackageReference Include="Uno.Dsp.Tasks" Version="[version]" />
</ItemGroup>
Place your JSON theme file close to where you want the color overrides file to be generated. This is usually in the Styles folder on the shared project.
ex: MyProject.Shared\Styles\MyTheme.json
You need to add the following PropertyGroupto your project file:
[-- MyProject.Shared\MyProject.Shared.csproj --]
<PropertyGroup>
<UnoDspImportColors Include="*.json" Generator="Xaml" />
</PropertyGroup>
Compile and you should get a new file named MyTheme.xaml in the same folder as your theme file.
Reference this file in your App.xaml file, following the Uno Themes documentation:
[-- App.xaml --]
<Application.Resources>
<MaterialColors xmlns="using:Uno.Material"
OverrideSource="ms-appx:///Styles/MyTheme.xaml" />
</Application.Resources>
Another tool exists, called Uno.Dsp.Cli to generate the output file from the command line. It is less integrated than this MSBuild task, but it can be used to generate the color overrides file from a theme file that is not in your project or if you need more flexibility at the moment when it is generated.
If you are using the Single Project Uno.Sdk package style, you don't need to add the reference to the Uno.Dsp.Tasks package, as it is already included in the Uno.Sdk package.
To activate the Uno.Dsp.Tasks package in your project, you need to add the Dsp; item in the <UnoFeatures> property in your project file, as described here.
You can also change the version of the package by using the <UnoDspTasksVersion> property in your csproj file.
To use it, simply add your theme file in the Styles folder and the overrides file should get generated automatically.