uid |
---|
Uno.Development.AppStructure |
This guide briefly explains the structure of an app created with either the dotnet new unoapp
template or the Uno Platform Template Wizard. It's particularly aimed at developers who have not worked with cross-platform codebases before.
After creating a new solution called MyApp
, it will contain the following projects:
-
A
MyApp.[Platform].csproj
file for each platform that Uno Platform supports: Mobile (iOS/Android/Mac Catalyst), Skia.Gtk, Wasm and Windows. These projects are known as heads for their respective platform.Head projects typically contain information like settings, metadata, dependencies, and also a list of files included in the project. Each of the head projects has a reference to the main class library of the application.
The head projects are the projects that generate the executable binaries for the platform. They are also the projects that are used to debug the application on the platform. Right-click on the project in the Solution Explorer tool window and select
Set as Startup Project
to debug the application on the platform. -
The
MyApp.csproj
file is the Application Class Library for the application and contains most of the code for the application. -
The
MyApp.Shared.csproj
is a placeholder project used to edit theAppHead.xaml
andbase.props
files. These files are automatically included in all other heads. This project is present to support the.Windows
head and WinAppSDK. This project is not intended to be built and produces no output. The Application Class Library will contain most of the classes, XAML files, String resources and assets (images, fonts etc) for the application.
Note
In an Uno Platform solution, the commonly known App.xaml
and App.xaml.cs
files are named AppResources.xaml
and App.cs
, respectively. Both are automatically included as part of each head's AppHead.xaml
and AppHead.xaml.cs
in order to create a cross-platform experience. It is recommended to use AppResources.xaml
and App.cs
for editing the application's startup.
Dependencies (ie NuGet Package References) should be added to the Application Class Library. This ensures that the dependencies are available to all the heads of the application. Platform-specific dependencies can be conditionally included in the Application Class Library by setting an appropriate Condition
on the PackageReference
element in the project file.
See additional guides on handling platform-specific C# code and XAML markup in an Uno Platform project.
The Uno Platform solution also can be further optimized to build larger projects with Visual Studio 2022.
Learn more about:
- Uno Platform features and architecture
- Hot Reload feature
- Troubleshooting
- List of views implemented in Uno for the set of available controls and their properties.
- You can head to How-tos and tutorials on how to work on your Uno Platform app.