While your "Additional steps for a C++/WinRT project" section (on https://docs.microsoft.com/en-us/windows/apps/winui/winui2/getting-started, see below) is technically working, however I (and probably others as well) got confused by the following issue:
I added (the NuGet-Packet etc. and) the include directives as indicated (into the 'C++/WinRT - Blank App' template), but then thought "well, 'winrt/Microsoft.UI.Xaml.Controls.Primitives.h' is included already" (from the template), so I can delete that line to make my pch.h a little cleaner.
The problem however is, that the template uses include <...>, which, using the Visual-Studio 2019 default-setup, loads the header from the the SDK, which obviously is not updated by running winrt on the new references (and also pulls in the 'winrt/Microsoft.UI.Xaml.Controls.h' header from there).
Making things even worse, Visual Studio displays, when hovering the include and pressing F12, the locally generated header (which is of course correct). So from within VS all seems fine, but the compiler only pulls in the SDK headers, so one gets a compiler-error as explained in this blog post: https://devblogs.microsoft.com/oldnewthing/20190530-00/?p=102529.
Best Regards,
Martin
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 532b04ea-7927-f97a-1121-b8feac6df957
Version Independent ID: e3cf5c39-5efa-aaea-3ac3-8c4ffa50e960
The WinUI and WinApp SDK docs have seen numerous updates and improvements. Closing this issue due to age. Please open a new issue if this is still a concern.
Hi,
While your "Additional steps for a C++/WinRT project" section (on https://docs.microsoft.com/en-us/windows/apps/winui/winui2/getting-started, see below) is technically working, however I (and probably others as well) got confused by the following issue: I added (the NuGet-Packet etc. and) the include directives as indicated (into the 'C++/WinRT - Blank App' template), but then thought "well, 'winrt/Microsoft.UI.Xaml.Controls.Primitives.h' is included already" (from the template), so I can delete that line to make my pch.h a little cleaner. The problem however is, that the template uses include <...>, which, using the Visual-Studio 2019 default-setup, loads the header from the the SDK, which obviously is not updated by running winrt on the new references (and also pulls in the 'winrt/Microsoft.UI.Xaml.Controls.h' header from there). Making things even worse, Visual Studio displays, when hovering the include and pressing F12, the locally generated header (which is of course correct). So from within VS all seems fine, but the compiler only pulls in the SDK headers, so one gets a compiler-error as explained in this blog post: https://devblogs.microsoft.com/oldnewthing/20190530-00/?p=102529.
Best Regards, Martin
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.