Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active April 12, 2021 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/98f0601245ed3a28e3730db36bd9e10d to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/98f0601245ed3a28e3730db36bd9e10d to your computer and use it in GitHub Desktop.
Commands to set ASPNETCORE_ENVIRONMENT value
# Windows Command Prompt using setx.exe
## Temporary, for current session
## When session is closed, value is lost
set ASPNETCORE_ENVIRONMENT "Test"
## Permenant, for current user, set user level
setx ASPNETCORE_ENVIRONMENT "Test"
## Permenant, for all users, set machine level
setx ASPNETCORE_ENVIRONMENT "Test" /M
# PowerShell
## Temporary, for current session
## When session is closed, value is lost
$Env:ASPNETCORE_ENVIRONMENT = "Test"
## PowerShell Script to get both key and value
Get-Item -path Env:ASPNETCORE_ENVIRONMENT
## PowerShell script to get the value
Get-Content -Path Env:ASPNETCORE_ENVIRONMENT
## PowerShell to set the value
Set-Content -Path Env:ASPNETCORE_ENVIRONMENT -Value "Test"
# PowerShell: Using System.Environment class
[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Security", "User")
[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Security", "Machine")
# MacOS
export ASPNETCORE_ENVIRONMENT=Staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment