Browse Source

Adjust build instructions (#21397)

pull/21402/head
Julien Lebosquain 5 months ago
committed by GitHub
parent
commit
5be3cc521e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 107
      docs/build.md

107
docs/build.md

@ -1,36 +1,26 @@
## Clone the Avalonia repository
```bash
git clone https://github.com/AvaloniaUI/Avalonia.git
cd Avalonia
git submodule update --init
git clone --recurse-submodules https://github.com/AvaloniaUI/Avalonia.git
```
## Install the required version of the .NET Core SDK
Go to https://dotnet.microsoft.com/en-us/download/visual-studio-sdks and install the latest version of the .NET SDK compatible with Avalonia UI. Make sure to download the SDK (not just the "runtime") package. The version compatible is indicated within the [global.json](https://github.com/AvaloniaUI/Avalonia/blob/master/global.json) file. Note that Avalonia UI does not always use the latest version and is hardcoded to use the last version known to be compatible (SDK releases may break the builds from time-to-time).
Go to https://dotnet.microsoft.com/en-us/download/visual-studio-sdks and install the latest version of the .NET SDK compatible with Avalonia. Make sure to download the SDK (not just the "runtime") package. The version compatible is indicated within the [global.json](https://github.com/AvaloniaUI/Avalonia/blob/master/global.json) file. Note that Avalonia does not always use the latest version and is hardcoded to use the last version known to be compatible (SDK releases may break the builds from time-to-time).
### Installing necessary .NET Workloads
### Install necessary .NET Workloads
.NET SDK requires developers to install workloads for each platform they are targeting.
Since Avalonia targets pretty much every supported .NET platform, you need to install these workloads as well.
Running it from the command line:
```bash
dotnet workload install android ios maccatalyst wasm-tools
dotnet workload install android ios tvos maccatalyst wasm-tools
```
macOS workloads are not required to build Avalonia.
Note: on Unix OS you need to run this command from sudo.
Tizen workload can be installed with PowerShell:
```powershell
(New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1') | Invoke-Expression
```
Or Bash:
```bash
curl -sSL https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.sh | sudo bash
```
## Build and Run Avalonia
## Build and Run Avalonia
```bash
cd samples\ControlCatalog.Desktop
@ -38,79 +28,82 @@ dotnet restore
dotnet run
```
## Opening in Visual Studio
## IDEs
Visual Studio, Visual Studio Code and Rider and supported.
You need a version that support at least .NET 10 (e.g. Visual Studio 2026 or Rider 2025.3).
If you want to open Avalonia in Visual Studio you have two options:
If you want to open Avalonia in your preferred IDE, you have two options:
- Avalonia.slnx: This contains the whole of Avalonia in including desktop, mobile and web. You must have a number of dotnet workloads installed in order to build everything in this solution
- Avalonia.Desktop.slnf: This solution filter opens only the parts of Avalonia required to run on desktop. This requires no extra workloads to be installed.
- `Avalonia.slnx`: This contains the whole of Avalonia in including desktop, mobile and web. You must have a number of dotnet workloads installed in order to build everything in this solution
- `Avalonia.Desktop.slnf`: This solution filter opens only the parts of Avalonia required to run on desktop. This requires no extra workloads to be installed.
Avalonia requires Visual Studio 2022 or newer. The free Visual Studio Community edition works fine.
Build and run the `ControlCatalog.Desktop` project to see the sample application.
Build and run `ControlCatalog.Desktop` project to see the sample application.
### Troubleshooting
### Visual Studio Troubleshooting
#### Submodules
* **Error MSB4062 GenerateAvaloniaResourcesTask**
When updating your local repository, always ensure that the submodules are up-to-date to avoid any problems:
```bash
git submodule update --init --recursive
```
Same as previous one, you need to manually build `Avalonia.Build.Tasks` project at least once.
#### Error MSB4062 GenerateAvaloniaResourcesTask
Alternatively, you can build the solution once with Nuke.
If you encounter this error when building inside the IDE, manually build the `Avalonia.Build.Tasks` project at least once.
Alternatively, you can build the solution once with Nuke.
## Building packages with Nuke
Install Nuke
`dotnet tool install --global Nuke.GlobalTool --version 6.2.1`
Install Nuke:
```bash
dotnet tool install --global Nuke.GlobalTool
```
Build project:
`nuke --target Compile --configuration Release`
```bash
nuke --target Compile --configuration Release
```
And run tests:
`nuke --target RunTests --configuration Release`
```bash
nuke --target RunTests --configuration Release
```
Or if you need to create nuget packages as well (it will compile and run tests automatically):
`nuke --target Package --configuration Release`
Alternatively, you can run nuke build directly without installing Nuke global tool:
`dotnet run --project nukebuild/_build.csproj -- --configuration Debug`
For integration tests, see [readme](https://github.com/AvaloniaUI/Avalonia/tree/master/tests/Avalonia.IntegrationTests.Appium#readme) next to the project.
```bash
nuke --target Package --configuration Release
```
# Linux/macOS
Alternatively, you can run nuke build directly without installing Nuke global tool. Replace `nuke` with either `./build.sh` (macOS/Linux) or `.\build.ps1` (Windows).
Examples:
It's *not* possible to build the *whole* project on Linux/macOS. You can only build the subset targeting .NET Standard and .NET Core (which is, however, sufficient to get UI working on Linux/macOS). If you want to something that involves changing platform-specific APIs you'll need a Windows machine.
On Windows:
MonoDevelop, Xamarin Studio and Visual Studio for Mac aren't capable of properly opening our solution. You can use Rider (at least 2017.2 EAP) or VS Code instead. They will fail to load most of platform specific projects, but you don't need them to run on .NET Core.
```bash
.\build.ps1 --configuration Debug
```
## Additional requirements for macOS
On macOS and Linux:
The build process needs [Xcode](https://developer.apple.com/xcode/) to build the native library. Following the install instructions at the [Xcode](https://developer.apple.com/xcode/) website to properly install.
```bash
./build.sh --configuration Debug
```
## Clone the Avalonia repository
For integration tests, see [readme](https://github.com/AvaloniaUI/Avalonia/tree/master/tests/Avalonia.IntegrationTests.Appium#readme) next to the project.
```
git clone https://github.com/AvaloniaUI/Avalonia.git
cd Avalonia
git submodule update --init --recursive
```
## Native libraries (macOS only)
## Build native libraries (macOS only)
On macOS, the build process needs [Xcode](https://developer.apple.com/xcode/) to build the native library. Follow the installation instructions on the [Xcode](https://developer.apple.com/xcode/) website to install it.
On macOS it is necessary to build and manually install the respective native libraries using [Xcode](https://developer.apple.com/xcode/). Execute the build script in the root project with the `CompileNative` task. It will build the headers, build the libraries, and place them in the appropriate place to allow .NET to find them at compilation and run time.
Then, build and manually install the corresponding native libraries using Xcode. Execute the build script in the root project with the `CompileNative` task. It will build the headers and libraries, and place them in the appropriate locations so .NET can find them at compile and run time.
```bash
./build.sh CompileNative
```
## Browser
To build and run browser/wasm projects, it's necessary to install NodeJS.
You can find latest LTS on https://nodejs.org/.
## Windows
It is possible to run some .NET Framework samples and tests using .NET Framework SDK. You need to install at least 4.7 SDK.
## Building Avalonia into a local NuGet cache
See [Building Local NuGet Packages](nuget.md)

Loading…
Cancel
Save