DotNet Programming World

Sunday, July 23, 2023

When adding xUnit project to your .net Maui project on mac

 By default, .net Maui project file on mac doesn't include .net 6/7.0 in the <TargetFrameworks>

So, when a new unit test project is referencing it, it would find that TargetFramework mismatch.

In order to avoid this, update your .net Maui project file, not solution file to include the same framework you can see in the test project file. In my case "net 7.0"


But VS compiler doesn't like it because its output type is exe for your .net maui project. And The compiler can't produce an executable with .net 7.0. So, we need a condition in the <outputType>


Cheers!