microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.38k stars 683 forks source link

Issue while building project with CLI: Incorrect use of net472 XAML compiler #8871

Open LeonSpors opened 1 year ago

LeonSpors commented 1 year ago

Describe the bug

I'm encountering an issue while trying to build my project using the command line instead of Visual Studio. I receive the following error:

 C:\Users\leon.spors\.nuget\.nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(760,9): error MSB3073: The command ""C:\Users\leon.spors\.nuget\packages\microsoft.windowsappsdk\1.3.230724000\buildTransitive\..\tools\net5.0\..\net472\XamlCompiler.exe" "obj\x64\Release\net7.0-windows10.0.19041.0\win-x64\\input.json" "obj\x64\Release\net7.0-windows10.0.19041.0\win-x64\\output.json"" exited with code 1.

It is weird that it uses the net472 xaml compiler. Is it a fallback? Did I miss something?

csproj

<PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
    <Platforms>x64</Platforms>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <LangVersion>latest</LangVersion>
    <Nullable>enable</Nullable>
    <ApplicationIcon>Assets\Kevox.Windows.ico</ApplicationIcon>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <UseWinUI>true</UseWinUI>
    <EnableMsixTooling>true</EnableMsixTooling>
    <WindowsPackageType>None</WindowsPackageType>
    <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
    <SelfContained>true</SelfContained>
    <EnableWindowsTargeting>true</EnableWindowsTargeting>

    <!--Workaround-->
    <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>

    <FileVersion>0.4.12</FileVersion>
</PropertyGroup>

Steps to reproduce the bug

Clear your project obj/bin folders. Use the following command

dotnet publish <YourProjectName.csproj> -c Release -r win-x64 -p:Platform=x64 --self-contained true -o <Your output folder>

Expected behavior

It should publish like Visual Studio does but it seems there is a difference.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

Windows 11 (22H2): Build 22621, Windows 11 (21H2): Build 22000, Windows 10 (21H2): Build 19044, Windows 10 (21H1): Build 19043, Windows 10 (20H2): Build 19042, Windows 10 (1809): Build 17763

Additional context

No response

madhavcanarymail commented 8 months ago

+1

Naveen61097 commented 7 months ago

I am facing the same issue. My project packs successfully from the Visual Studio UI (pack option). It also works perfectly if I use the command "dotnet pack {csproj}". But the problem is that restoring the packages in my specific folder throws the error.

respective command - "dotnet pack {csproj} --packages packages"

azchohfi commented 4 months ago

Hitting the same issue. xamlcompiler.exe needs better logging.