Muokkaa

Jaa


Backslash mapping in Unix file paths

Backslash (\) characters are valid in directory and file names on Unix. Starting in .NET 8, the native CoreCLR runtime no longer converts \ characters to directory separators—forward slashes (/)—on Unix. This change enables .NET applications to be located on paths with names that contain backslash characters. It also allows the native runtime, dotnet host, and the ilasm and ildasm tools to access files on paths that contain backslash characters.

Previous behavior

The native CoreCLR runtime automatically converted backslash (\) characters in file paths to forward slashes (/) on Unix.

New behavior

The native CoreCLR runtime doesn't convert any file path characters on Unix.

Version introduced

.NET 8 Preview 1

Type of breaking change

This change is a behavioral change.

Reason for change

Without this change, .NET apps located in directories that contain backslash characters fail to start.

  • Use Path.DirectorySeparatorChar as a directory separator in your app instead of hardcoding it to \ or /.
  • Use / as a directory separator on Unix in file paths that you pass to the dotnet host, hosting APIs, and ilasm and ildasm tools.
  • Use / as a directory separator on Unix in file paths in various DOTNET_xxx environment variables.

Affected APIs