Does anybody knows how to get information about current environment and platform in .NET Core? Currently there are no Environment class in Core library.
Environment Variables are one of the sources from which ASP.NET Core reads the configuration values. In this tutorial, let us learn how to set Environment Variables in Windows, Mac, Linux, IIS Server, Visual Studio, Visual Studio Code & dotnet run. We also learn how to read them in ASP.NET core.
GetEnvironmentVariable(envVar, EnvironmentVariableTarget. Machine) Console. WriteLine($" {envVar}: {value}") Next Console. WriteLine() ' Delete the environment variable for each target.
System.Environment
is available in the System.Runtime.Extensions
package. Ensure you've referenced that package in your project.json
.
{
"frameworks": {
"dnxcore50": {
"dependencies": {
"System.Runtime.Extensions": "4.0.10-*"
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With