…or we could call it “The mystery of the empty MSIXPackagingToolGeneratedFile.txt file” to be catchy!
The packaging format used by UWP, MSIX, and App-V files is loosely structured around formats based on the PkZip format specification. This format mostly has file references, with the file headers providing information about the path that the file lives under. So folders are implied by the files included in the archive. Although the format also supports the definition of an empty folder, Microsoft has consistently not used this capability.
Under App-V, for example, empty folders in the package exist not in the archive format, but inside some metadata within the archive using a file called FileSystemMetatadata.xml. This file also contains other kinds of metadata about the virtual file system, such as transparency and short-names.
MSIX, and UWP, do not have this additional metadata. Transparency is always enabled, and so far they have avoided the need to have short-name information included. But this means there are no empty folders as well. If we need one what do we do?
We can steal a page from what the Microsoft MSIX Packaging Tool (MMPT) does. When capturing an installer, if the install creates an empty folder, the tool creates an additional dummy file under the empty folder so that the folder gets captured. The MMPT always calls this file MSIXPackagingToolGeneratedFile.txt and it is 0 bytes. If you’ve ever seen this in a package and wonder what it is, now you know!
We can use a similar trick when packaging through other means also. Empty folders are important because applications sometimes check for folder existence and take different actions based upon the test results. Additionally, the folder structure inside the package can affect whether newly created files get redirected or not. As an example, if the package contains no files in the Documents folder (and therefore the Documents folder is not part of the folder structure of the package VFS area), an app that writes a file to the documents folder will write it natively outside of the container boundary. But add a dummy file into the folder, then files will be redirected. In the case of the Documents folder I might prefer NOT to have any files in the package, but in most other cases I would.
Now you know!