How to build Application for different platforms using the same code?

Imilio 41 Reputation points
2022-02-18T07:59:04.53+00:00

Hi, I am developing a WPF desktop application with .Net 5.0. Is it possible to build the app for Window and Mac os platform with the same code? If yes, how should it be done? Thanks!

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,761 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 48,491 Reputation points Microsoft Vendor
    2022-02-18T09:24:30.24+00:00

    You may not make .NET 5 WPF application executed in Mac os.
    Quoted from Desktop Guide (WPF .NET):

    Even though .NET is a cross-platform technology, WPF isn't and only runs on Windows.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Sreeju Nair 12,346 Reputation points
    2022-02-19T05:34:28.9+00:00

    As per your query, I understand you need to develop application for different platforms, and ofcourse it is possoble. The solution is .Net Multi-Platform App platform that can be used to create

    1. Desktop application in Windows
    2. Application for MAC
    3. Android Application
    4. iOS application

    https://learn.microsoft.com/en-us/dotnet/maui/what-is-maui

    Currently it is in preview, and you need Visual Studio 2022 Preview version and .Net 6, however, as per the current plan it will be released in the Q2 2022.

    https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation

    https://learn.microsoft.com/en-us/dotnet/maui/

    Hope this helps.


  3. Ken Tucker 5,851 Reputation points
    2022-02-21T12:05:38.987+00:00

    Take look at the open source project avonlonia UI.

    https://docs.avaloniaui.net/

    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.