Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Environment in .NET Core 1.0

Tags:

c#

.net

.net-core

Does anybody knows how to get information about current environment and platform in .NET Core? Currently there are no Environment class in Core library.

enter image description here

like image 297
Bogdan Avatar asked Feb 13 '15 10:02

Bogdan


People also ask

What is environment variable in .NET Core?

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.

How do I set environment GetEnvironmentVariable?

GetEnvironmentVariable(envVar, EnvironmentVariableTarget. Machine) Console. WriteLine($" {envVar}: {value}") Next Console. WriteLine() ' Delete the environment variable for each target.


1 Answers

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-*"
      }
    }
  }
}
like image 95
bricelam Avatar answered Oct 14 '22 01:10

bricelam