I've recently jumped into cross-platform development and wanted to just bite the bullet and go straight into the newest framework that the do.net team has started working on, MAUI.
The issue I've run into is trying to add another test project in the solution and referencing the MAUI project. As I'm pretty new to Visual Studio as well, this may just be a rookie mistake and I just don't know what I'm doing, but here I am asking away.
I've also tried to add all the target frameworks into the project, but that causes more issues than it solves. I've tried to follow this open source project where they got it to work, but I'm unsure how to achieve it.
Alt+Enter of class not being imported
This link may be helpful. https://www.softwaremeadows.com/posts.net_maui_progressing_from_a_default_project_part_6_-_revisiting_unit_testing/
Summary:
In your .csproj
file, add .net6.0' to TargetFrameworks as below.
<TargetFrameworks.net6.0.net6.0-android.net6.0-ios.net6.0-maccatalyst</TargetFrameworks>
Modify OutputType to use Condition.
<OutputType Condition="'$(TargetFramework)'.= .net6.0'">Exe</OutputType>
Its probably because of mismatch in project target frameworks. Easy fix is to add Target Framework to your maui project that matches the one used in test project. For example if your Test poject is base on net6.0, just add net6.0 as a target framework to your maui app project.
Edit 1: Also sometimes you need to add empty start point for netX.X build, looking like this
public static void Main(string[] args)
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.