WinUI3 : Undestanding Generated Files folder

Harshithraj1871 1,686 Reputation points
2022-12-15T06:47:33.297+00:00

Hi,

I have been working on winui3 for some time now, I am trying to completely understand the WinUI3 build system and WinUI3 project structure.

I read "At build time, the generated code and your code are merged into a complete class definition and then compiled." Can you please help me understand when this "Generated files" folder is created and from where it and its content come?

Generated file folder contains a lot of files like sources, winrt, .g files, etc, I wanted to understand what is the purpose of each of them and how does it get generated, and understand what level of control we can get over this folder that we can control the files which are been generated.

It would be very helpful if you can point me to the right documentation and get a detailed understanding of it.

Thank you

Windows development | Windows App SDK
Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 21,646 Reputation points
    2022-12-15T08:14:54.693+00:00

    Hello @Harshithraj1871 ,

    Generated Files is a folder in WinUI3 C++ project.

    You can see $(GeneratedFilesDir) in project properties -> C/C++ -> General -> Additional Include Directories.
    270834-image.png

    With the default project settings, the included headers come from the Windows SDK, inside the folder %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt. Visual Studio includes that path in its IncludePath macro. But there's no strict dependency on the Windows SDK, because your project (via the cppwinrt.exe tool) generates those same headers into your project's $(GeneratedFilesDir) folder. They'll be loaded from that folder if they can't be found elsewhere, or if you change your project settings.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.