How to Best Run a WPF C# App on macOS and Linux?

MARCIN SZOLKE SCHOLKE 0 Reputation points
2025-07-28T07:49:33.3866667+00:00

Hi all,

I’ve built a Windows desktop application using WPF in C# (with Visual Studio). Now I’d like to make it available for macOS and Linux users as well.

I know WPF is Windows-only, but I’m wondering:

What’s the best way to run or port a WPF app on macOS/Linux?

Should I rewrite it in .NET MAUI, Avalonia, or something else?

Any success stories or lessons learned from people who have done this?

Performance, native look, and ease of development matter a lot in my case. Would appreciate any tips or recommendations

Thanks in advance,

Marcin Szolke

https://lov111vol.com/author

Developer technologies | Windows Presentation Foundation
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Starry Night 30 Reputation points
    2025-07-31T06:39:17.3566667+00:00

    Yes, it's possible to run WPF applications on Mac with little to no code changes using Avalonia XPF. This is possible thanks to Microsoft making WPF open-source and using a permissive license.

    The common steps are as follows:

    1. Add a NuGet.config We can ship Avalonia XPF as a NuGet package, which requires adding our private nuget feeds to gain access. We'll do this by creating a NuGet.config file at the root of our solution. It'll include the following: 
         <?xml version="1.0" encoding="utf-8"?> 
         <configuration> 
         <packageSources>   
         <clear />    
         <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />  
          <add key="xpf" value="https://xpf-nuget-feed.avaloniaui.net/v3/index.json" />             <add key="avalonia-nightly" value="https://nuget-feed-all.avaloniaui.net/v3/index.json" />
         </packageSources>
         <packageSourceCredentials>    
         <xpf> 
            <add key="Username" value="license" />
            <add key="ClearTextPassword" value="<YOUR_LICENSE_KEY>" />
         </xpf>
         </packageSourceCredentials> 
         </configuration>
      
    2. Load the solution and replace the project SDK with Avalonia XPF For example: <Project Sdk="Xpf.Sdk/1.0.1-cibuild001124">
    3. Update the TargetFramework Avalonia XPF requires WPF apps to target NET6 or above. For this reason, we'll update the apps Target Framework to the latest NET8 runtime.  <TargetFramework>net8.0</TargetFramework>
    4. Add the license key The last change is to add our license key to the csproj for the executable. 
    <ItemGroup> 
        <RuntimeHostConfigurationOption Include="AvaloniaUI.Xpf.LicenseKey" Value="<YOUR_LICENSE_KEY>" />
    </ItemGroup>
    

    For more information, please check: https://avaloniaui.net/blog/wpf-on-mac

    To run a WPF app on Linux, you can check : A developers guide to running WPF apps on Linux with .NET Core.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.