错误 运行 .NET MAUI 应用程序与 .NET 6 RC2 的单元测试

Error running Unit Tests for .NET MAUI Apps with .NET 6 RC2

运行 dotnet test 在引用使用 .NET MAUI (<UseMaui>true</UseMaui>) 的项目的 net6 单元测试项目上抛出以下错误:

Testhost process exited with error: It was not possible to find any compatible framework version 
The framework 'Microsoft.Maui.Core', version '**FromWorkload**' (x64) was not found. 

此错误发生在 .NET 6 Release Candidate 2

这是 .NET 6 RC2 中的已知问题:

https://github.com/dotnet/sdk/issues/21845

目前,dotnet test 还不适用于使用 dotnet workload 的项目。由于 .NET MAUI 作为 .NET 工作负载安装,这意味着 dotnet test 尚不适用于 .NET MAUI 应用程序。

更新: .NET MAUI team has fixed the issue。这意味着在 .NET MAUI 项目上使用 dotnet test 将在下一版本 .NET MAUI Preview 10 中开始工作。