-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables for .NET Framework 4.7.2 set on a run basis rather than on a project root folder basis #69
Comments
Fortunately, it can be used in Net Framework by temporarily using it as follows.
|
But this error only occurs when using ASP.NET with .NET Framework? Because I just tested the I just tested that the I am not so sure but I think the solution would be to remove dotnet-env/src/DotNetEnv/Env.cs Line 29 in a47e667
|
I'll take a PR for it if that is all it takes |
It seems to happen when using ASP.net together. |
When using xamarin-android, there is an issue that the function returns NULL. I can't write in detail because I don't have time right now, but if you check the attached issue, there is a solution. |
Having the same problem with a ASP.Net Core and Console application within the same solution that uses 1 common .env file. Using |
I did make this change as it sounds appropriate (I can imagine an app changing the current directory before loading this and ending up in the wrong place anyway). That said, if at any time anyone feels that they want the old behavior, or are having trouble, this is already quite easy to work around, since the first arg to |
I'm not using NET Core, I'm developing using NET Framework 4.7.2.
The project is using a function called Directory.GetCurrentDirectory() to find the root folder.
NET Framework, the function finds the location where the project was launched, not the root folder of the project.
Because of this, the path changes depending on the execution environment, and when you build with IIS Express in Visual Studio 2022, the root folder is applied as "C:\Program Files\IIS Express" rather than the project folder.
Because of this, putting ".env" in the project root folder doesn't work.
This issue was in the past "dotnet/aspnetcore#4206" and was fixed in Net Core but not in Net Framework.
According to what I checked on https://stackoverflow.com/a/53655514, in NET Framework, you should use System.AppContext.BaseDirectory instead of System.IO.Directory.GetCurrentDirectory() to work properly. At this time, I confirmed that it normally finds the project root folder.
The text was updated successfully, but these errors were encountered: