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
ASP.NET Core version: 3 and 3.1
Include the output of dotnet --info:
.NET Core SDK (reflecting any global.json):
Version: 3.1.100-preview3-014645
Commit: b32d27f4b3
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
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
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
dotnet --info
: .NET Core SDK (reflecting any global.json): Version: 3.1.100-preview3-014645 Commit: b32d27f4b3Runtime 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]