microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 323 forks source link

Windows App SDK keeps throwing "XAML Internal Error WMC9999: Unexpected XML declaration" during compilation #4600

Closed lucas-yotsui closed 3 months ago

lucas-yotsui commented 3 months ago

Describe the bug

I'm trying to compile a WinUI 3 based project and I'm currently getting the following error: <PROJECT_PATH>\packages\Microsoft.WindowsAppSDK.1.5.240627000\build\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(506,3): Xaml Internal Error error WMC9999: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 1, position 7.

I noticed I had an obsolete version of the SDK's NuGet package, so I tried updating to the latest stable, but it didn't change anything and I got the same error.

I've also already tried cleaning the solution and compiling from scratch but it also didn't work.

Steps to reproduce the bug

  1. Create a WinUI 3 project
  2. Install the latest WindowsAppSDK with NuGet
  3. Try to compile it

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.5.5: 1.5.240627000

Packaging type

No response

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

whiskhub commented 3 months ago

Well, there has to be an invalid XAML file somewhere in your project. Check all the XAML files for whitespace at the beginning.

lucas-yotsui commented 3 months ago

Weird, I've found this issue while running a project from last December that used to work just fine, but now simply won't and I haven't changed a single thing in it. I thought it could be an issue with the SDK since the error message pointed to a file from within the SDK directories.

I've created a new project and it works fine so I guess I was wrong and the issue is not the SDK. I'm sorry for the confusion, I'll close the issue now.