-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blank App, Packaged (WinUI3 in Desktop) C++ fails to compile #5041
Comments
I don't see this. Is Visual Studio up to date? Are your extensions up to date? |
Apologies for taking so long to reply. To tell the truth, I kind of used "extension" to potentially make you stop and think and double check the project. But this particular error has three major components. First is the Windows SDK, the second is C++/WinRT and the third is the Windows App SDK. The following is taken from the diagnostic log of a build.
For the default project template, the only time that midl touches both MainWindow and Microsoft.UI.Xaml.Window is when the .winmd file is created for MainWindow. The references are gathered in The .winmd references are also added by the Windows App SDK, so having that up to date (1.6.4) is also useful. One other thing that I remembered. I think I recall people mentioning issues if the project is under a directory that has spaces in it. Is this the case here? |
I updated my VS22 installer to include the Windows 11 SDK (10.0.26100.0). I did not previously have this latest version of the Windows SDK installed. It did not change anything. The template project comes set up with WindowsAppSdk 1.7.240912003 in the NuGet packages. That's the latest version. I've tried going back to older versions and that fixed the issue for me with a C# template project which also did not build at first. However, the C++ template project is unaffected by changing the WindowsAppSdk version. Microsoft CppWinRT package is not installed in the NuGet packages. Perhaps that is what's missing? |
C++/WinRT is required for the C++ projects. There are some modifications that it makes to building, like gathering and providing metadata (.winmd files) for midl. But most importantly:
This is the default contents of pch.h, the precompiled header for the C++ WinUI project template. Everything that starts with Since you mentioned this, I removed C++/WinRT from a WinUI 3 project, and it immediately fails with So try adding C++/WinRT to the project. I am also aware that if the project templates are generating projects without C++/WinRT then this is only a work around and this should be fixed. However, there is a workaround available. |
Describe the bug
The blank app template for a packaged app using WinUI3 in Desktop (C++) fails to compile with error MIDL2011: [msg]unresolved type declaration [context]: Microsoft.UI.Xaml.Window [ RuntimeClass 'OlMaRudge.MainWindow' ]
The C# template also fails to compile due to a missing assembly, none of the Microsoft.UI.Xaml namespaces are recognized, but in the C# template if I downgrade the Microsoft.WindowsAppSDK nuget package then it appears to have fixed the issue.
Steps to reproduce the bug
Expected behavior
Unmodified template project should not fail to build
Screenshots
No response
NuGet package version
None
Windows version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: