Closed
Description
Description
(The issue only affects Windows.)
dotnet new console -o net5console && cd net5console && dotnet build
- Create several directories of various lengths. For this experiment, I'll use:
T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789
(272 characters, more thanMAX_PATH
)T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\30characters_34567890123456789
(252 characters, less thanMAX_PATH
)T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890
(243 characters, less thanMAX_PATH
)
- Copy all the contents from
net5console\bin\Debug\net5.0
to the directories from step 2. - Run the following commands (via
cmd
, sincepwsh
doesn't work with certain long paths too well), and see the results:> T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\net5console.exe Hello World! > T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\30characters_34567890123456789\net5console.exe Hello World! > T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890\net5console.exe Cannot use file stream for [T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890\net5console.runtimeconfig.dev.json]: No such file or directory Cannot use file stream for [T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890\net5console.runtimeconfig.json]: No such file or directory Invalid runtimeconfig.json [T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890\net5console.runtimeconfig.json] [T:\Temp\LongPaths\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\50characters_3456789012345678901234567890123456789\21characters_34567890\net5console.runtimeconfig.dev.json]
So, according to what I could gather during the initial investigation of the issue, it depends on path length for the runtimeconfig.json
file:
- less than 260 characters: works
- from 260 to 274 characters inclusively: doesn't work, throws "invalid runtimeconfig.json"
- 275 characters and more: works
It looks like the countermeasures were applied for it to work under long paths, but there's an arithmetic or logical error in the code that applies the workaround, so it breaks for certain path lengths.
I expect it to work in all three cases. Or, if it breaks due to the path length, I expect it to break in a predictable way, and not for paths in a certain length range.
Configuration
>dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.203
Commit: 383637d63f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.203\
Host (useful for support):
Version: 5.0.6
Commit: 478b2f8c0e
.NET SDKs installed:
2.1.808 [C:\Program Files\dotnet\sdk]
3.1.302 [C:\Program Files\dotnet\sdk]
5.0.100 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Regression?
I don't think it is. AFAIK, it works the same in .NET Core 3.1.