uid |
---|
Uno.Contributing.BuildingUno |
This article explains how to build Uno.UI locally, for instance, if you wish to contribute a bugfix or new feature.
TargetPlatformVersion
line in this file)TargetFrameworks
list used here)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.
Minimum configuration:
Optimal configuration:
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:
[!NOTE] 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.
generated/master/uwp-autoconvert
branch. See this section for details on this branch.src/crosstargeting_override.props.sample
file and name this copy src/crosstargeting_override.props
.crosstargeting_override.props
, uncomment the line <UnoTargetFrameworkOverride>xxx</UnoTargetFrameworkOverride>
<UnoTargetFrameworkOverride></UnoTargetFrameworkOverride>
to the identifier for the target platform you wish to build for (Identifiers for each platform are listed in the crosstargeting_override.props
file), then save the file.src
folder, look for the solution filter (.slnf
file) 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.props
for the selected UnoTargetFrameworkOverride
), and open it.Uno.UI
project in the Solution Explorer and 'Build'.Uno.UI.Runtime.WebAssembly
or Uno.UI.Runtime.Skia.[Gtk|Wpf|X11|macOS]
project in the Solution Explorer and 'Build'.crosstargeting_override.props
, such as UnoDisableNetAnalyzers
which 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.
[!IMPORTANT] You will need to repeat the above steps 2. and subsequent when changing the active
UnoTargetFrameworkOverride
value.
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 Server.
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.
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.
<UnoTargetFrameworkOverride />
line in your crosstargeting_override.props
file.Uno.UI
projectInside Visual Studio, the number of platforms is restricted to limit the compilation time.
Here are some tips when building the Uno solution and failures happen:
src/.vs
folder, then try rebuilding the solution.vs
deletion did not help, run git clean -fdx
(after having closed Visual Studio) before building againUnoTargetFrameworkOverride
which matches your solution filter19041
installedSkia and WebAssembly use a custom bait-and-switch technique for assemblies for which the net7.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 <UnoTargetFrameworkOverride>...</UnoTargetFrameworkOverride>
to net7.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 applications or libraries using the NuGet cache override.
Refer to the guidelines for breaking changes document.
The versions used are centralized in the Directory.Build.targets file, and all the
locations where <PackageReference />
are used.
When updating the versions of NuGet packages, make sure to update all the .nuspec files in the build/nuget
folder.
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:
Developer Command Prompt for Visual Studio
(2019 or 2022)uno\build
folder (not the uno\src\build
folder)run-api-sync-tool.cmd
script; make sure to follow the instructionsNote that the tool is manually run for the WinUI part of the build and automatically run as part of the CI during the UWP part of the build.
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 <PropertyGroup>
in Directory.Build.targets
that sets $(AndroidGenerateResourceDesigner)
and $(AndroidUseIntermediateDesignerFile)
to false
.
Build Uno.UI as you normally would. You will get compiler errors about duplicate fields, but obj\Debug\net6.0-android\Resource.designer.cs
should now be generated.
Open 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.cs
checked into source
control, such as: src/Uno.UI/Resources/Resource.designer.g.Android.cs
Restore the commented code in Directory.Build.targets
.
This performance optimization is inspired by @jonathanpeppers's performance work done in https://github.com/dotnet/maui/pull/2606. Thanks Jonathan!
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )