dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.35k stars 9.99k forks source link

Can't use network locations #17295

Closed Leonardo-Ferreira closed 4 years ago

Leonardo-Ferreira commented 4 years ago

Describe the bug

.Net Core 3 is prepending supplied paths with the local solution path.

To Reproduce

Create a empty console app using .net 3.0 or 3.1 and insert

System.IO.File.ReadAllBytes("smb://yourshare/file.txt");
System.IO.File.ReadAllBytes("\\\\yourshare/file.txt");

and you will get a exception very similar to:
System.IO.DirectoryNotFoundException: Could not find a part of the path '/Users/leonardoferreira/Projects/MySolution/MySolution.Console/bin/Debug/netcoreapp3.1/smb:/myshare/myfile.txt'.\n at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)\n at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)\n at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)\n at System.IO.File.ReadAllBytes(String path)\n at MySolution.Console.Main() in /Users/leonardoferreira/Projects/MySolution/MySolution.Console/Program.cs:line 13

Further technical details

Runtime Environment: OS Name: Mac OS X OS Version: 10.14 OS Platform: Darwin RID: osx.10.14-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.100-preview3-014645/

Host (useful for support): Version: 3.1.0-preview3.19553.2 Commit: 13f35c3d86

.NET Core SDKs installed: 2.1.802 [/usr/local/share/dotnet/sdk] 3.0.100 [/usr/local/share/dotnet/sdk] 3.1.100-preview2-014569 [/usr/local/share/dotnet/sdk] 3.1.100-preview3-014645 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0-preview2.19528.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0-preview3.19555.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0-preview2.19525.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0-preview3.19553.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Tratcher commented 4 years ago

This issue was moved to dotnet/corefx#42665