Skip to content

Conversation

@ilonatommy
Copy link
Member

@ilonatommy ilonatommy commented Nov 25, 2025

Fixes #103625.

This PR fixes Windows MAX_PATH (260 character) limitation in WASM AOT compilation by adding \\?\ prefix support to long file paths across the Mono runtime's file operations.
Long path prefix comes from Unicode “W” APIs. Windows versions from Windows NT on support that API.
OSs that do not support this change:

  • Windows 3.x and other DOS releases
  • Windows 95
  • Windows 98
  • Windows ME

Changes:

  1. gpath.c: Adds g_path_make_long_compatible() helper function that conditionally adds \\?\ prefix to Windows paths ≥260 characters, supporting both regular absolute paths (C:\path\\?\C:\path) and UNC network paths (\\server\share\\?\UNC\server\share).

  2. mono-path.c: Uses g_path_make_long_prefix() in mono_path_canonicalize() to ensure canonicalized paths support long path operations.

  3. image.c: Uses the canonicalized absolute path (absfname) instead of the original filename when loading assemblies to ensure long paths are handled correctly throughout the image loading process.

  4. MonoAOTCompiler.cs: Passes full absolute paths to the AOT compiler instead of potentially relative paths to ensure Windows long path support (\\?\ prefix from canonicalization) works correctly.

  5. gfile-win32.c: Calls g_path_make_long_compatible() in g_file_test() before calling GetFileAttributesW() to enable existence checks for files with long paths.

  6. gfile.c: Calls g_path_make_long_compatible() in g_fopen() before opening files to support long paths when the runtime needs to open assembly files.

  7. BuildPublishTests.cs: Adds DefaultTemplate_AOT_WithLongPath test with 300+ character path prefix to verify long path support works correctly with AOT compilation.

@ilonatommy ilonatommy self-assigned this Nov 25, 2025
@ilonatommy ilonatommy requested a review from maraf as a code owner November 25, 2025 14:19
Copilot AI review requested due to automatic review settings November 25, 2025 14:19
@ilonatommy ilonatommy added arch-wasm WebAssembly architecture wasm-aot-test WebAssembly AOT Test labels Nov 25, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses the fix for issue #103625 by removing the workaround for long path failures on Windows during AOT publish and adding a dedicated test to verify the fix.

  • Removed commented-out active issue annotation and explanatory comments about long path limitations
  • Added a new test DefaultTemplate_AOT_WithLongPath that explicitly creates a project with a long path and performs AOT publish to ensure it works correctly

@pavelsavara
Copy link
Member

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ilonatommy
Copy link
Member Author

runtime-extra-platforms are running for more than 1 day, I'll merge with main to retrigger the CI.

@ilonatommy
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono wasm-aot-test WebAssembly AOT Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][publish] Windows has problems with AOT build/publish for long paths

4 participants