Jetbrains骑士:无法建立MAUI .Net7应用程序的目标框架在net7.0-windows10.0.19041.0由于错误MSB 3073从Xamlsworer.exe

6pp0gazn  于 2023-11-20  发布在  .NET
关注(0)|答案(1)|浏览(187)

将一个经典的Xamarin项目迁移到.Net7中,只有当我尝试使用Jetbrains Rider版本2023.2.2和dotnet 7.0.403在任何配置(发布或调试)下编译net7.0-windows10.0时,我才会感到奇怪。

0>------- Started building project: Foobar.PingPong.Testbed.MauiNet7
"C:\Users\<username>\.nuget\packages\microsoft.windowsappsdk\1.2.221209.1\buildTransitive\..\tools\net5.0\..\net472\XamlCompiler.exe" "obj\Debug\net7.0-windows10.0.19041.0\win10-x64\\input.json" "obj\Debug\net7.0-windows10.0.19041.0\win10-x64\\output.json"
0>Microsoft.UI.Xaml.Markup.Compiler.interop.targets(559,9): Error MSB3073 : The command ""C:\Users\<username>\.nuget\packages\microsoft.windowsappsdk\1.2.221209.1\buildTransitive\..\tools\net5.0\..\net472\XamlCompiler.exe" "obj\Debug\net7.0-windows10.0.19041.0\win10-x64\\input.json" "obj\Debug\net7.0-windows10.0.19041.0\win10-x64\\output.json"" exited with code 1.
0>------- Finished building project: Foobar.PingPong.Testbed.MauiNet7. Succeeded: False. Errors: 1. Warnings: 0

字符串
我试着清理解决方案并从头开始重建-每次都是同样的错误。

hgtggwj0

hgtggwj01#

嗯,在绕了几个小时的圈子之后,我想给给予Visual Studio 2022一个机会,它立刻发现了真正的问题所在。
文件'Platforms/Windows/App.xaml'是这样的:

<MauiWinUIApplication
    x:Class="Foobar.PingPong.Testbed.MauiNet7.WinUI.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:maui="using:Microsoft.Maui"
    xmlns:local="using:Foobar.PingPong.Testbed.MauiNet7.WinUI">

</MauiWinUIApplication>

字符串
但正确的味道是这样的(注意'maui:'前缀):

<maui:MauiWinUIApplication
    x:Class="Foobar.PingPong.Testbed.MauiNet7.WinUI.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:maui="using:Microsoft.Maui"
    xmlns:local="using:Foobar.PingPong.Testbed.MauiNet7.WinUI">

</maui:MauiWinUIApplication>


遗憾的是,Jetbrains不能像Visual Studio那样发现这个错误,希望这能保存一些人几个小时不必要的试错。

相关问题