This article explains how to build Uno.UI locally, for instance if you wish to contribute a bugfix or new feature.
- Visual Studio 2022 (17.4.4 or later)
Xamarin development(Under the MAUI optional components)
ASP.NET and Web Development
.NET Core cross-platform development
UWP Development, install all recent UWP SDKs, starting from 10.0.19041 (or above or equal to
TargetPlatformVersionline in this file)
- Install (Tools / Android / Android SDK manager) all Android SDKs starting from 7.1 (or the Android versions
TargetFrameworkslist used here)
- Run Uno.Check on your dev machine to setup .NET 6 Android/iOS workloads
Recommended Windows hardware
Loading and building the Uno.UI solution is a resource intensive task. As a result, opening it in Visual Studio 2022 requires a minimum hardware configuration to avoid spending time waiting for builds.
- Intel i7 (8th gen) or equivalent
- 16 GB of RAM
- 250GB of Fast SSD
- Intel i9 or equivalent
- 32 GB of RAM
- 500GB M2 SSD
Building Uno.UI for a single target platform
This is the recommended approach to building the Uno.UI solution. It will build a single set of binaries for a particular platform (eg Android, iOS, WebAssembly, etc).
Building for a single target platform is considerably faster, much less RAM-intensive, and generally more reliable.
It involves two things - setting an override for the target framework that will be picked up by the (normally multi-targeted) projects inside the Uno solution; and opening a preconfigured solution filter which will only load the projects needed for the current platform.
The step by step process is:
- Clone the Uno.UI repository locally, and ensure using a short target path, e.g. D:\uno etc.
This is due to limitations in the legacy .NET versions used by Xamarin projects. This issue has been addressed in .NET 5, and will come to the rest of the projects in the future.
- By default the Uno.UI solution on the master branch is building using the UWP API set. If you want to build against the WinUI 3 API set, you can checkout the
generated/master/winui-autoconvertbranch. See this section for details on this branch.
- Make sure you don't have the Uno.UI solution opened in any Visual Studio instances. (Visual Studio may crash or behave inconsistently if it's open when the target override is changed.)
- Make a copy of the
src/crosstargeting_override.props.samplefile and name this copy
crosstargeting_override.props, uncomment the line
- Set the build target inside
<UnoTargetFrameworkOverride></UnoTargetFrameworkOverride>to the identifier for the target platform you wish to build for (Identifiers for each platform are listed in the
crosstargeting_override.propsfile), then save the file.
- In the
srcfolder, look for the solution filter (
.slnffile) corresponding to the target platform override you've set, which will be named
Uno.UI-[Platform]-only.slnf(or the name listed in
crosstargeting_override.propsfor the selected
UnoTargetFrameworkOverride), and open it.
- To confirm that everything works:
- For iOS/Android/macOS you can right-click on the
Uno.UIproject in the Solution Explorer and 'Build'.
- For WebAssembly and Skia you can right-click on the
Uno.UI.Runtime.Skia.[Gtk|Wpf]project in the Solution Explorer and 'Build'.
- For iOS/Android/macOS you can right-click on the
- Optionally adjust additional parameters in
crosstargeting_override.props, such as
UnoDisableNetAnalyzerswhich can improve the build time during debugging sessions.
Once you've built successfully, for the next steps, consult the guide here for debugging Uno.UI.
You will need to repeat the above steps 2. and subsequent when changing the active
If you've followed the steps above, you have your environment set up with the listed prerequisites, and you still encounter errors when you try to build the solution, you can reach out to the core team on Uno's Discord channel #uno-platform.
Windows and long paths issues
If the build tells you that
LongPath is not enabled, you may enable it on Windows 10 by using :
reg ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1
If for some reason you cannot modify the registry, you can disable this warning by adding
<UnoUIDisableLongPathWarning>false</UnoUIDisableLongPathWarning> to the project.
Note that long paths may be required when building Uno, and invalid paths errors may arise.
Building Uno.UI for all available targets
It's recommended to build using the single-target approach, but it's also possible to build for all targets at once, if you wish.
- If you've previously followed the single-target steps, comment out the
<UnoTargetFrameworkOverride />line in your
- Open the Uno.UI.sln
- Select the
Inside Visual Studio, the number of platforms is restricted to limit the compilation time.
Building Uno.UI for macOS using Visual Studio for Mac
See instructions here for building Uno.UI for the macOS platform.
Troubleshooting build issues
Here are some tips when building the Uno solution and failures happen:
- Make sure to be on the latest master commit
- Try to close VS 2022, delete the
src/.vsfolder, then try rebuilding the solution
- If the
.vsdeletion did not help, run
git clean -fdx(after having closed visual studio) before building again
- Make sure to have a valid
UnoTargetFrameworkOverridewhich matches your solution filter
- Make sure to have the Windows SDK
Other build-related topics
Building the reference assemblies for Skia and WebAssembly
Skia and WebAssembly use a custom bait-and-switch technique for assemblies for which the
netstandard2.0 target framework assemblies (called reference assemblies) found in nuget packages (
lib folder) are only used for building applications. At the end of a head build, those reference assemblies are replaced by public API compatible assemblies located in the
uno-runtime\[target-framework] folder of nuget packages.
When developing a feature using solution filters, if new public APIs are added, building the Uno.UI solution will not update the reference assemblies, causing applications or libraries using the overridden nuget cache to be unable to use those newly added APIs.
In order to update those reference assemblies, set
netstandard2.0, then open the
Uno.UI-Reference-Only.slnf filter. You can now build the
Uno.UI project. Doing this will generate the proper assemblies with the new APIs to be used in application or libraries using the nuget cache override.
Using the Package Diff tool
Refer to the guidelines for breaking changes document.
Updating the Nuget packages used by the Uno.UI solution
The versions used are centralized in the Directory.Build.targets file, and all the
<PackageReference /> are used.
When updating the versions of nuget packages, make sure to update all the .nuspec files in the Build folder.
Running the SyncGenerator tool
Uno Platform uses a tool which synchronizes all WinRT and WinUI APIs with the type implementations already present in Uno. This ensures that all APIs are present for consumers of Uno, even if some are not implemented.
The synchronization process takes the APIs provided by the WinMD files referenced by the
Uno.UWPSyncGenerator.Reference project and generates stubbed classes for types in the
Generated folders of Uno.UI, Uno.Foundation and Uno.WinRT projects. If the generated classes have been partially implemented in Uno (in the non-Generated folders), the tool will automatically skip those implemented methods.
The tool needs to be run on Windows because of its dependency on the Windows SDK WinMD files.
To run the synchronization tool:
- Open a
Developer Command Prompt for Visual Studio(2019 or 2022)
- Go the the
uno\buildfolder (not the
- Run the
run-api-sync-tool.cmdscript; make sure to follow the instructions
Note that as of Uno 3.10, the tool is manually run for the UWP part of the build and automatically run as part of the CI during the WinUI part of the build.
Android Resources ID generation
To workaround a performance issue, all
Resource.designer.cs generation is disabled for class libraries in this repo.
If you need to add a new
@(AndroidResource) value to be used from C# code inside of Uno.UI libraries:
Comment out the
Build Uno.UI as you normally would. You will get compiler errors about duplicate fields, but
obj\Debug\net6.0-android\Resource.designer.csshould now be generated.
obj\Debug\net6.0-android\Resource.designer.cs, and find the field you need such as:
// aapt resource value: 0x7F010000 public static int foo = 2130771968;
Copy this field to the
Resource.designer.cschecked into source control, such as:
Restore the commented code in
This performance optimization is inspired by @jonathanpeppers's performance work done in https://github.com/dotnet/maui/pull/2606. Thanks Jonathan!