Unable to package Windows apps that contain long file paths
If a Windows application includes deep file paths, it can prevent the application from being packaged.
To Reproduce Steps to reproduce the behavior:
- Create a Pyside6 app
briefcase package windows visualstdio- See error
...
[verify-pyside6] Building MSI...
Compiling application manifest...
heat.exe : error HEAT5059 : The file 'D:\a\briefcase-windows-VisualStudio-template\briefcase-windows-VisualStudio-template\tests\apps\verify-pyside6\windows\VisualStudio\Hello PySide6\x64\Release\app_packages\PySide6\examples\datavisualization\surface_model_numpy\__pycache__\surfacegraph.cpython-38.pyc' cannot be found.
Compiling...
Unable to generate manifest for app verify-pyside6.
Log saved to D:\a\briefcase-windows-VisualStudio-template\briefcase-windows-VisualStudio-template\tests\apps\verify-pyside6\logs\briefcase.2022_10_31-03_27_06.package.log
The build completes successfully; however, packaging fails. The file being referenced actually does exist; however, there is a known error in WiX that prevents packaging from succeeding if any path is longer than 260 characters.
This is due to a limitation of older Windows filesystems. The Windows Python installer provides an option to enable this support at time of installation; however, it's easy to skip the significance of this option if you're not aware of it. If you didn't enable MAX_PATH support when you installed Python, you can manually modify the longPathsEnabled option in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem registry key. However, even if this option is enabled, WiX will fail.
Expected behavior
Apps with long/deep file paths should not prevent an app from being packaged.
Environment:
- Operating System: Windows
- Python version: Any
- Software versions:
- Briefcase: any
- PySide 2 or 6
Additional context
The problem has apparently been fixed in WiX 4... but WiX 4 has been in pre-release for years, so it's unclear when we'll be able to adopt this fix.
Good news - WiX 4 has now been released, so this should be fixable.
I thought this would be automatically resolved by #1185, which migrates to using WiX 5 for MSI installers - but beeware/briefcase-windows-VisualStudio-template#62 demonstrates that this isn't the case.
Looks like you also have to use a \\?\ prefix on paths to trigger C#'s long file name handling (reference). Fix is included on https://github.com/beeware/briefcase-windows-VisualStudio-template/pull/62 and beeware/briefcase-windows-app-template#68
Even Microsoft documentation about this syntax is often incomplete or incorrect. This is the best explanation I could find.