Cannot open include file <Project Path>packages\<...>\Microsoft.Foundation.h

Cosmin Mihai 35 Reputation points
2024-02-14T10:44:59.9666667+00:00

When adding a new IDL file (ProjectItem.idl along with ProjectItem.h and .cpp) I get the following error:

1><path>ProjectItem.g.h(52,10): error C1083: Cannot open include file: '<path>\packages\Microsoft.WindowsAppSDK.1.4.231219000\lib\uap10.0.18362\Microsoft.Foundation.h': No such file or directory

If I go to the ProjectItem.g.h file I can see the include: #include "<project>\packages\Microsoft.WindowsAppSDK.1.4.231219000\lib\uap10.0.18362\Microsoft.Foundation.h" Then if I go to the path <project>\packages\Microsoft.WindowsAppSDK.1.4.231219000\lib\uap10.0.18362\, I can see that the Microsoft.Foundation.h is missing:

Directory: packages\Microsoft.WindowsAppSDK.1.4.231219000\lib\uap1
    0.0.18362
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        15.12.2023     01:16           1536 Microsoft.Foundation.winmd
-a----        20.12.2023     00:52            219 Microsoft.Foundation.xml
-a----        15.12.2023     01:16          11264 Microsoft.Graphics.winmd
-a----        20.12.2023     00:52          26946 Microsoft.Graphics.xml
-a----        15.12.2023     01:16         259072 Microsoft.UI.winmd
-a----        20.12.2023     00:52         492724 Microsoft.UI.xml

What could be the problem? Why is the generated file containing a header that is missing? Note: The project is a "Blank App, Packaged with Windows Application Packaging Project (WinUI3 in Desktop)" that I just created.

Windows development Windows App SDK
{count} votes

1 answer

Sort by: Most helpful
  1. Tong Xu - MSFT 2,546 Reputation points Microsoft External Staff
    2024-02-15T09:05:35.59+00:00

    HI, @Cosmin Mihai Sorry for the delay.
    I've already tried to reproduce it.

    After adding the "Projectitem.cpp", I didn't see any error about #include <winrt/Windows.Foundation.h>.

    And you got wrong directory. Also, It within "……\Generated Files\winrt". So please check this directory.
    fundation.h

    If you still have the issue. You might need to reinstall something on windows app sdk with C++.

    1. C++(v143)Universal Windows Platform Tools. uwptools

    2.Windows app sdk C++ template in Desktop Development with C++. Windowappsdkinstall


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.