Develop on Windows 10

From Wiki Maui Linux NET
Revision as of 07:52, 15 October 2025 by Ten (talk | contribs) (Build MAUI Linux)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Building and Running MAUI Linux in a Windows 10 VM

Fresh installed Windows 10 VM Install in Windows Features → Windows Subsystem for Linux

Installed Components

  • Visual Studio 2022 with
    • .NET Multi-Platform App UI development
    • Git for Windows
    • .NET Debugging with WSL
    • .NET 7 Runtime

PowerShell (as Administrator)

set-executionpolicy remotesigned
Invoke-WebRequest 'https://raw.githubusercontent.com/HavenDV/Gtk/main/scripts/workload-install.ps1' -OutFile 'workload-install.ps1';
./workload-install.ps1

Source Code

Source code under `C:\source`

git clone https://github.com/TenEniunlsl/maui-linux-net
git clone https://github.com/GtkSharp/GtkSharp.git

Build GtkSharp

Open `C:\GtkSharp` in Visual Studio 2022 Open Terminal in VS

dotnet tool restore
dotnet cake .\build.cake

Build MAUI Linux

Open `C:\maui-linux-net` in Visual Studio 2022 and Open Terminal in VS

dotnet build .\Microsoft.Maui.BuildTasks.slnf

If it does not build in the Core Project, there is a missing NuGet package (`WebkitGtkSharp`). Install it from `C:\source\GtkSharp\BuildOutput\NugetPackages` it's not on nuget.org and build again in Visual Studio 2022.

Run Maui.Controls.Sample

  • Start Maui.Controls.Sample
    • If asked to install .NET 8 in WSL → click OK
    • If asked about Linux distribution in WSL → select Install Ubuntu
    • If asked to install WSL Default Debugger → install it

In my case (fresh installed Win 10 VM i needed some extra steps)

Install VcXsrv:

  • Multiple Windows
  • Display Number: `0` (maybe `-1` possible)
  • Start no client
  • Check:
 * Clipboard  
 * Primary Selection  
 * Native OpenGL  
 * Disable Access Control  

Modify launchSettings.json

{
  "profiles": {
    "Windows Machine": {
      "commandName": "MsixPackage",
      "nativeDebugging": true
    },
    "WSL": {
      "commandName": "WSL2",
      "distributionName": "",
      "environmentVariables": {
        "DISPLAY": "127.0.0.1:0.0",
        "DOTNET_ENVIRONMENT": "Development"
      }
    }
  }
}