XDS
XDS

Reputation: 4188

Jetbrains Rider: Unable to build MAUI .Net7 app for target-framework in net7.0-windows10.0.19041.0 due to error Error MSB3073 from XamlCompiler.exe

Migrated an classic Xamarin project into .Net7 and I'm getting this weird only when I try to compile against net7.0-windows10.0 in any configuration (release or debug) using Jetbrains Rider version 2023.2.2 and the dotnet 7.0.403 with all workloads for windows installed.

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

I tried cleaning up the solution and rebuilding from scratch - same error every time. What gives?

Upvotes: 2

Views: 652

Answers (1)

XDS
XDS

Reputation: 4188

Well, after running around in circles for a few hours I thought to give Visual Studio 2022 a shot and it spotted where the actual problem was right off the bat.

The file 'Platforms/Windows/App.xaml' was like so:

<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>

But the correct flavour is this (notice the 'maui:' prefixes):

<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>

Shame that Jetbrains can't spot this one to provide a clear error like Visual Studio. Hopefully this will save someone a few hours of needless trial-and-error.

Upvotes: 2

Related Questions