Forum Discussion

CCannon94's avatar
CCannon94
Copper Contributor
Jan 25, 2023
Solved

Developing a .NET MAUI app on a team using Visual Studio on both Windows and Mac

As the title states, our team consists of developers who use Visual Studio 2022 for Mac and for Windows. We are creating a cross-platform application using .NET MAUI, so I'd assume we should be able to contribute using both. However, we seem to have a problem in our .csproj file.

 

In order for the application to load in the solution on Windows machines, the .csproj file must include these lines:

<TargetFrameworks>net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('mac'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>
 
However, in order for them to load on Visual Studio for Mac, we must have these lines: 
<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
 
Is there any configuration we can put that will allow the project to load on either operating system? As the minority OS user, it is quite annoying to have to edit the .csproj each time I switch git branches.
  • Actually, typing this out helped us see the obvious solution. I need to add the "Condition" to both target lines.

     

    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net7.0-windows10.0.19041.0</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('mac'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>

     

1 Reply

  • CCannon94's avatar
    CCannon94
    Copper Contributor

    Actually, typing this out helped us see the obvious solution. I need to add the "Condition" to both target lines.

     

    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net7.0-windows10.0.19041.0</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('mac'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>

     

Resources