You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a file-based app via dotnet run app.cs, there is no way to get the path of the file being executed. This makes it difficult to discover files relative to the application entry-point file. Doing file-based operations relative to the entry-point file is common in script scenarios, e.g. $PSScriptRoot in PowerShell, __file__ in Python, etc. Note that this is distinct from the current working directory, which is obtainable via Environment.CurrentDirectory and Directory.GetCurrentDirectory().
As a first step to enabling this (i.e. in lieu of a potential API or generated variable or some such in the future), we should update dotnet run to set environment variables when executing file-based apps that contain the path of the entry-point file and the path of the directory the entry-point file is in, e.g.:
DOTNET_EXECUTING_FILE_PATH
DOTNET_EXECUTING_FILE_DIRECTORY_PATH
Names up for discussion 😄. We may want to consider naming for C# instead of DOTNET, or perhaps do both, e.g.: