parent
1d06f1f935
commit
615efcc78e
221
dnvm.ps1
221
dnvm.ps1
|
|
@ -67,7 +67,7 @@ function _WriteOut {
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
$ProductVersion="1.0.0"
|
$ProductVersion="1.0.0"
|
||||||
$BuildVersion="beta8-15516"
|
$BuildVersion="beta8-15517"
|
||||||
$Authors="Microsoft Open Technologies, Inc."
|
$Authors="Microsoft Open Technologies, Inc."
|
||||||
|
|
||||||
# If the Version hasn't been replaced...
|
# If the Version hasn't been replaced...
|
||||||
|
|
@ -109,8 +109,8 @@ Set-Variable -Option Constant "DNVMUpgradeUrl" "https://raw.githubusercontent.co
|
||||||
Set-Variable -Option Constant "AsciiArt" @"
|
Set-Variable -Option Constant "AsciiArt" @"
|
||||||
___ _ ___ ____ ___
|
___ _ ___ ____ ___
|
||||||
/ _ \/ |/ / | / / |/ /
|
/ _ \/ |/ / | / / |/ /
|
||||||
/ // / /| |/ / /|_/ /
|
/ // / /| |/ / /|_/ /
|
||||||
/____/_/|_/ |___/_/ /_/
|
/____/_/|_/ |___/_/ /_/
|
||||||
"@
|
"@
|
||||||
|
|
||||||
$ExitCodes = @{
|
$ExitCodes = @{
|
||||||
|
|
@ -154,11 +154,11 @@ if($__TeeTo) {
|
||||||
$DeprecatedCommands = @("unalias")
|
$DeprecatedCommands = @("unalias")
|
||||||
|
|
||||||
# Load Environment variables
|
# Load Environment variables
|
||||||
$RuntimeHomes = $env:DNX_HOME
|
$RuntimeHomes = $(if (Test-Path "env:\$HomeEnvVar") {Get-Content "env:\$HomeEnvVar"})
|
||||||
$UserHome = $env:DNX_USER_HOME
|
$UserHome = $env:DNX_USER_HOME
|
||||||
$GlobalHome = $env:DNX_GLOBAL_HOME
|
$GlobalHome = $env:DNX_GLOBAL_HOME
|
||||||
$ActiveFeed = $env:DNX_FEED
|
$ActiveFeed = $(if (Test-Path "env:\$DefaultFeedKey") {Get-Content "env:\$DefaultFeedKey"})
|
||||||
$ActiveUnstableFeed = $env:DNX_UNSTABLE_FEED
|
$ActiveUnstableFeed = $(if (Test-Path "env:\$DefaultUnstableFeedKey") {Get-Content "env:\$DefaultUnstableFeedKey"})
|
||||||
|
|
||||||
# Default Exit Code
|
# Default Exit Code
|
||||||
$Script:ExitCode = $ExitCodes.Success
|
$Script:ExitCode = $ExitCodes.Success
|
||||||
|
|
@ -181,13 +181,32 @@ if($CmdPathFile) {
|
||||||
_WriteDebug "Using CMD PATH file: $CmdPathFile"
|
_WriteDebug "Using CMD PATH file: $CmdPathFile"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine where runtimes can exist (RuntimeHomes)
|
# Determine the default installation directory (UserHome)
|
||||||
if(!$RuntimeHomes) {
|
if(!$UserHome) {
|
||||||
# Set up a default value for the runtime home
|
if ($RuntimeHomes) {
|
||||||
$UnencodedHomes = "$env:USERPROFILE\$DefaultUserDirectoryName;$GlobalHome\$DefaultGlobalDirectoryName"
|
_WriteDebug "Detecting User Home..."
|
||||||
} else {
|
$pf = $env:ProgramFiles
|
||||||
$UnencodedHomes = $RuntimeHomes
|
if(Test-Path "env:\ProgramFiles(x86)") {
|
||||||
|
$pf32 = Get-Content "env:\ProgramFiles(x86)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Canonicalize so we can do StartsWith tests
|
||||||
|
if(!$pf.EndsWith("\")) { $pf += "\" }
|
||||||
|
if($pf32 -and !$pf32.EndsWith("\")) { $pf32 += "\" }
|
||||||
|
|
||||||
|
$UserHome = $RuntimeHomes.Split(";") | Where-Object {
|
||||||
|
# Take the first path that isn't under program files
|
||||||
|
!($_.StartsWith($pf) -or $_.StartsWith($pf32))
|
||||||
|
} | Select-Object -First 1
|
||||||
|
|
||||||
|
_WriteDebug "Found: $UserHome"
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$UserHome) {
|
||||||
|
$UserHome = "$DefaultUserHome"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$UserHome = [Environment]::ExpandEnvironmentVariables($UserHome)
|
||||||
|
|
||||||
# Determine the default global installation directory (GlobalHome)
|
# Determine the default global installation directory (GlobalHome)
|
||||||
if(!$GlobalHome) {
|
if(!$GlobalHome) {
|
||||||
|
|
@ -196,40 +215,27 @@ if(!$GlobalHome) {
|
||||||
} else {
|
} else {
|
||||||
$GlobalHome = "$env:AllUsersProfile\$DefaultGlobalDirectoryName"
|
$GlobalHome = "$env:AllUsersProfile\$DefaultGlobalDirectoryName"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$GlobalHome = [Environment]::ExpandEnvironmentVariables($GlobalHome)
|
||||||
|
|
||||||
$env:DNX_GLOBAL_HOME="$GlobalHome"
|
# Determine where runtimes can exist (RuntimeHomes)
|
||||||
$env:DNX_HOME="$env:DNX_HOME;$env:DNX_GLOBAL_HOME"
|
if(!$RuntimeHomes) {
|
||||||
$UnencodedHomes = "$UnencodedHomes;$GlobalHome"
|
# Set up a default value for the runtime home
|
||||||
|
$UnencodedHomes = "$UserHome;$GlobalHome"
|
||||||
|
} elseif ($RuntimeHomes.StartsWith(';')) {
|
||||||
|
_WriteOut "Ignoring invalid $HomeEnvVar; value was '$RuntimeHomes'" -ForegroundColor $ColorScheme.Warning
|
||||||
|
Clean-HomeEnv($true)
|
||||||
|
|
||||||
|
# Use default instead.
|
||||||
|
$UnencodedHomes = "$UserHome;$GlobalHome"
|
||||||
|
} else {
|
||||||
|
$UnencodedHomes = $RuntimeHomes
|
||||||
}
|
}
|
||||||
|
|
||||||
$UnencodedHomes = $UnencodedHomes.Split(";")
|
$UnencodedHomes = $UnencodedHomes.Split(";")
|
||||||
$RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment]::ExpandEnvironmentVariables($_) }
|
$RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment]::ExpandEnvironmentVariables($_) }
|
||||||
$RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ "runtimes" }
|
$RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ "runtimes" }
|
||||||
|
|
||||||
# Determine the default installation directory (UserHome)
|
|
||||||
if(!$UserHome) {
|
|
||||||
_WriteDebug "Detecting User Home..."
|
|
||||||
$pf = $env:ProgramFiles
|
|
||||||
if(Test-Path "env:\ProgramFiles(x86)") {
|
|
||||||
$pf32 = Get-Content "env:\ProgramFiles(x86)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Canonicalize so we can do StartsWith tests
|
|
||||||
if(!$pf.EndsWith("\")) { $pf += "\" }
|
|
||||||
if($pf32 -and !$pf32.EndsWith("\")) { $pf32 += "\" }
|
|
||||||
|
|
||||||
$UserHome = $RuntimeHomes | Where-Object {
|
|
||||||
# Take the first path that isn't under program files
|
|
||||||
!($_.StartsWith($pf) -or $_.StartsWith($pf32))
|
|
||||||
} | Select-Object -First 1
|
|
||||||
|
|
||||||
_WriteDebug "Found: $UserHome"
|
|
||||||
|
|
||||||
if(!$UserHome) {
|
|
||||||
$UserHome = "$env:USERPROFILE\$DefaultUserDirectoryName"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_WriteDebug ""
|
_WriteDebug ""
|
||||||
_WriteDebug "=== Running $CommandName ==="
|
_WriteDebug "=== Running $CommandName ==="
|
||||||
_WriteDebug "Runtime Homes: $RuntimeHomes"
|
_WriteDebug "Runtime Homes: $RuntimeHomes"
|
||||||
|
|
@ -240,18 +246,34 @@ $GlobalRuntimesDir = Join-Path $GlobalHome "runtimes"
|
||||||
$Aliases = $null
|
$Aliases = $null
|
||||||
|
|
||||||
### Helper Functions
|
### Helper Functions
|
||||||
|
# Remove $HomeEnv from process and user environment.
|
||||||
|
# Called when current value is invalid or after installing files to default location.
|
||||||
|
function Clean-HomeEnv {
|
||||||
|
param([switch]$SkipUserEnvironment)
|
||||||
|
|
||||||
|
if (Test-Path "env:\$HomeEnvVar") {
|
||||||
|
_WriteOut "Removing Process $HomeEnvVar"
|
||||||
|
Set-Content "env:\$HomeEnvVar" $null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$SkipUserEnvironment -and [Environment]::GetEnvironmentVariable($HomeEnvVar, "User")) {
|
||||||
|
_WriteOut "Removing User $HomeEnvVar"
|
||||||
|
[Environment]::SetEnvironmentVariable($HomeEnvVar, $null, "User")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Checks if a specified file exists in the destination folder and if not, copies the file
|
# Checks if a specified file exists in the destination folder and if not, copies the file
|
||||||
# to the destination folder.
|
# to the destination folder.
|
||||||
function Safe-Filecopy {
|
function Safe-Filecopy {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true, Position=0)] $Filename,
|
[Parameter(Mandatory=$true, Position=0)] $Filename,
|
||||||
[Parameter(Mandatory=$true, Position=1)] $SourceFolder,
|
[Parameter(Mandatory=$true, Position=1)] $SourceFolder,
|
||||||
[Parameter(Mandatory=$true, Position=2)] $DestinationFolder)
|
[Parameter(Mandatory=$true, Position=2)] $DestinationFolder)
|
||||||
|
|
||||||
# Make sure the destination folder is created if it doesn't already exist.
|
# Make sure the destination folder is created if it doesn't already exist.
|
||||||
if(!(Test-Path $DestinationFolder)) {
|
if(!(Test-Path $DestinationFolder)) {
|
||||||
_WriteOut "Creating destination folder '$DestinationFolder' ... "
|
_WriteOut "Creating destination folder '$DestinationFolder' ... "
|
||||||
|
|
||||||
New-Item -Type Directory $Destination | Out-Null
|
New-Item -Type Directory $Destination | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,7 +291,7 @@ function Safe-Filecopy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_WriteOut "WARNING: Unable to install: Could not find '$Filename' in '$SourceFolder'. "
|
_WriteOut "WARNING: Unable to install: Could not find '$Filename' in '$SourceFolder'. "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,9 +335,9 @@ function GetRuntimeInfo($Architecture, $Runtime, $OS, $Version) {
|
||||||
if([String]::IsNullOrEmpty($runtimeInfo.Architecture)) {
|
if([String]::IsNullOrEmpty($runtimeInfo.Architecture)) {
|
||||||
$runtimeInfo.Architecture = $RuntimeBitnessDefaults.Get_Item($RuntimeInfo.Runtime)
|
$runtimeInfo.Architecture = $RuntimeBitnessDefaults.Get_Item($RuntimeInfo.Runtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
$runtimeObject = New-Object PSObject -Property $runtimeInfo
|
$runtimeObject = New-Object PSObject -Property $runtimeInfo
|
||||||
|
|
||||||
$runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeId -Value {
|
$runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeId -Value {
|
||||||
if($this.Runtime -eq "mono") {
|
if($this.Runtime -eq "mono") {
|
||||||
"$RuntimePackageName-$($this.Runtime)".ToLowerInvariant()
|
"$RuntimePackageName-$($this.Runtime)".ToLowerInvariant()
|
||||||
|
|
@ -409,8 +431,8 @@ function Get-RuntimeAliasOrRuntimeInfo(
|
||||||
$Version = Get-PackageVersion $BaseName
|
$Version = Get-PackageVersion $BaseName
|
||||||
$OS = Get-PackageOS $BaseName
|
$OS = Get-PackageOS $BaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
GetRuntimeInfo $Architecture $Runtime $OS $Version
|
GetRuntimeInfo $Architecture $Runtime $OS $Version
|
||||||
}
|
}
|
||||||
|
|
||||||
filter List-Parts {
|
filter List-Parts {
|
||||||
|
|
@ -500,7 +522,7 @@ function Write-Alias {
|
||||||
|
|
||||||
$aliasFilePath = Join-Path $AliasesDir "$Name.txt"
|
$aliasFilePath = Join-Path $AliasesDir "$Name.txt"
|
||||||
$action = if (Test-Path $aliasFilePath) { "Updating" } else { "Setting" }
|
$action = if (Test-Path $aliasFilePath) { "Updating" } else { "Setting" }
|
||||||
|
|
||||||
if(!(Test-Path $AliasesDir)) {
|
if(!(Test-Path $AliasesDir)) {
|
||||||
_WriteDebug "Creating alias directory: $AliasesDir"
|
_WriteDebug "Creating alias directory: $AliasesDir"
|
||||||
New-Item -Type Directory $AliasesDir | Out-Null
|
New-Item -Type Directory $AliasesDir | Out-Null
|
||||||
|
|
@ -636,11 +658,11 @@ function Download-Package() {
|
||||||
[string]$Feed,
|
[string]$Feed,
|
||||||
[string]$Proxy
|
[string]$Proxy
|
||||||
)
|
)
|
||||||
|
|
||||||
_WriteOut "Downloading $($runtimeInfo.RuntimeName) from $feed"
|
_WriteOut "Downloading $($runtimeInfo.RuntimeName) from $feed"
|
||||||
$wc = New-Object System.Net.WebClient
|
$wc = New-Object System.Net.WebClient
|
||||||
try {
|
try {
|
||||||
Apply-Proxy $wc -Proxy:$Proxy
|
Apply-Proxy $wc -Proxy:$Proxy
|
||||||
_WriteDebug "Downloading $DownloadUrl ..."
|
_WriteDebug "Downloading $DownloadUrl ..."
|
||||||
|
|
||||||
Register-ObjectEvent $wc DownloadProgressChanged -SourceIdentifier WebClient.ProgressChanged -action {
|
Register-ObjectEvent $wc DownloadProgressChanged -SourceIdentifier WebClient.ProgressChanged -action {
|
||||||
|
|
@ -706,7 +728,7 @@ function Unpack-Package([string]$DownloadFile, [string]$UnpackFolder) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($DownloadFile, $UnpackFolder)
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($DownloadFile, $UnpackFolder)
|
||||||
|
|
||||||
# Clean up the package file itself.
|
# Clean up the package file itself.
|
||||||
Remove-Item $DownloadFile -Force
|
Remove-Item $DownloadFile -Force
|
||||||
}
|
}
|
||||||
|
|
@ -742,7 +764,7 @@ function Change-Path() {
|
||||||
[string[]] $removePaths
|
[string[]] $removePaths
|
||||||
)
|
)
|
||||||
_WriteDebug "Updating value to prepend '$prependPath' and remove '$removePaths'"
|
_WriteDebug "Updating value to prepend '$prependPath' and remove '$removePaths'"
|
||||||
|
|
||||||
$newPath = $prependPath
|
$newPath = $prependPath
|
||||||
foreach($portion in $existingPaths.Split(';')) {
|
foreach($portion in $existingPaths.Split(';')) {
|
||||||
if(![string]::IsNullOrEmpty($portion)) {
|
if(![string]::IsNullOrEmpty($portion)) {
|
||||||
|
|
@ -834,13 +856,13 @@ function Is-Elevated() {
|
||||||
#>
|
#>
|
||||||
function dnvm-update-self {
|
function dnvm-update-self {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Proxy)
|
[string]$Proxy)
|
||||||
|
|
||||||
_WriteOut "Updating $CommandName from $DNVMUpgradeUrl"
|
_WriteOut "Updating $CommandName from $DNVMUpgradeUrl"
|
||||||
$wc = New-Object System.Net.WebClient
|
$wc = New-Object System.Net.WebClient
|
||||||
Apply-Proxy $wc -Proxy:$Proxy
|
Apply-Proxy $wc -Proxy:$Proxy
|
||||||
|
|
||||||
$dnvmFile = Join-Path $PSScriptRoot "dnvm.ps1"
|
$dnvmFile = Join-Path $PSScriptRoot "dnvm.ps1"
|
||||||
$tempDnvmFile = Join-Path $PSScriptRoot "temp"
|
$tempDnvmFile = Join-Path $PSScriptRoot "temp"
|
||||||
$backupFilePath = Join-Path $PSSCriptRoot "dnvm.ps1.bak"
|
$backupFilePath = Join-Path $PSSCriptRoot "dnvm.ps1.bak"
|
||||||
|
|
@ -899,7 +921,7 @@ function dnvm-help {
|
||||||
}
|
}
|
||||||
|
|
||||||
_WriteOut -NoNewLine " "
|
_WriteOut -NoNewLine " "
|
||||||
|
|
||||||
if($_.required -ne "true") {
|
if($_.required -ne "true") {
|
||||||
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Optional "["
|
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Optional "["
|
||||||
}
|
}
|
||||||
|
|
@ -909,7 +931,7 @@ function dnvm-help {
|
||||||
}
|
}
|
||||||
if($_.parameterValue) {
|
if($_.parameterValue) {
|
||||||
if($_.position -eq "Named") {
|
if($_.position -eq "Named") {
|
||||||
_WriteOut -NoNewLine " "
|
_WriteOut -NoNewLine " "
|
||||||
}
|
}
|
||||||
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Argument "<$($_.name)>"
|
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Argument "<$($_.name)>"
|
||||||
}
|
}
|
||||||
|
|
@ -931,9 +953,9 @@ function dnvm-help {
|
||||||
if($cmdParam.Aliases.Length -gt 0) {
|
if($cmdParam.Aliases.Length -gt 0) {
|
||||||
$name = $cmdParam.Aliases | Sort-Object | Select-Object -First 1
|
$name = $cmdParam.Aliases | Sort-Object | Select-Object -First 1
|
||||||
}
|
}
|
||||||
|
|
||||||
_WriteOut -NoNewLine " "
|
_WriteOut -NoNewLine " "
|
||||||
|
|
||||||
if($_.position -eq "Named") {
|
if($_.position -eq "Named") {
|
||||||
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Switch "-$name".PadRight($OptionPadding)
|
_WriteOut -NoNewLine -ForegroundColor $ColorScheme.Help_Switch "-$name".PadRight($OptionPadding)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -946,7 +968,7 @@ function dnvm-help {
|
||||||
if($help.description) {
|
if($help.description) {
|
||||||
_WriteOut
|
_WriteOut
|
||||||
_WriteOut -ForegroundColor $ColorScheme.Help_Header "remarks:"
|
_WriteOut -ForegroundColor $ColorScheme.Help_Header "remarks:"
|
||||||
$help.description.Text.Split(@("`r", "`n"), "RemoveEmptyEntries") |
|
$help.description.Text.Split(@("`r", "`n"), "RemoveEmptyEntries") |
|
||||||
ForEach-Object { _WriteOut " $_" }
|
ForEach-Object { _WriteOut " $_" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -959,7 +981,7 @@ function dnvm-help {
|
||||||
Write-Feeds
|
Write-Feeds
|
||||||
_WriteOut
|
_WriteOut
|
||||||
_WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: "
|
_WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: "
|
||||||
Get-Command "$CommandPrefix*" |
|
Get-Command "$CommandPrefix*" |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
if($Host.Version.Major -lt 3) {
|
if($Host.Version.Major -lt 3) {
|
||||||
$h = Get-Help $_.Name
|
$h = Get-Help $_.Name
|
||||||
|
|
@ -981,7 +1003,7 @@ filter ColorActive {
|
||||||
$lines = $_.Split("`n")
|
$lines = $_.Split("`n")
|
||||||
foreach($line in $lines) {
|
foreach($line in $lines) {
|
||||||
if($line.Contains("*")){
|
if($line.Contains("*")){
|
||||||
_WriteOut -ForegroundColor $ColorScheme.ActiveRuntime $line
|
_WriteOut -ForegroundColor $ColorScheme.ActiveRuntime $line
|
||||||
} else {
|
} else {
|
||||||
_WriteOut $line
|
_WriteOut $line
|
||||||
}
|
}
|
||||||
|
|
@ -1032,12 +1054,12 @@ function dnvm-list {
|
||||||
if($items) {
|
if($items) {
|
||||||
#TODO: Probably a better way to do this.
|
#TODO: Probably a better way to do this.
|
||||||
if($Detailed) {
|
if($Detailed) {
|
||||||
$items |
|
$items |
|
||||||
Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias |
|
Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias |
|
||||||
Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias", "Location" | Out-String| ColorActive
|
Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias", "Location" | Out-String| ColorActive
|
||||||
} else {
|
} else {
|
||||||
$items |
|
$items |
|
||||||
Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias |
|
Sort-Object Version, Runtime, Architecture, OperatingSystem, Alias |
|
||||||
Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias" | Out-String | ColorActive
|
Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "OperatingSystem", "Alias" | Out-String | ColorActive
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1068,7 +1090,7 @@ function dnvm-list {
|
||||||
(defaults to 'x86') and <Runtime> (defaults to 'clr').
|
(defaults to 'x86') and <Runtime> (defaults to 'clr').
|
||||||
|
|
||||||
Finally, if the '-d' switch is provided, the alias <Name> is deleted, if it exists.
|
Finally, if the '-d' switch is provided, the alias <Name> is deleted, if it exists.
|
||||||
|
|
||||||
NOTE: You cannot create an alias for a non-windows runtime. The intended use case for
|
NOTE: You cannot create an alias for a non-windows runtime. The intended use case for
|
||||||
an alias to help make it easier to switch the runtime, and you cannot use a non-windows
|
an alias to help make it easier to switch the runtime, and you cannot use a non-windows
|
||||||
runtime on a windows machine.
|
runtime on a windows machine.
|
||||||
|
|
@ -1092,7 +1114,7 @@ function dnvm-alias {
|
||||||
[ValidateSet("", "clr","coreclr", "mono")]
|
[ValidateSet("", "clr","coreclr", "mono")]
|
||||||
[Parameter(ParameterSetName="Write")]
|
[Parameter(ParameterSetName="Write")]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
[ValidateSet("win", "osx", "darwin", "linux")]
|
[ValidateSet("win", "osx", "darwin", "linux")]
|
||||||
[Parameter(Mandatory=$false,ParameterSetName="Write")]
|
[Parameter(Mandatory=$false,ParameterSetName="Write")]
|
||||||
[string]$OS = "")
|
[string]$OS = "")
|
||||||
|
|
@ -1146,7 +1168,7 @@ function dnvm-unalias {
|
||||||
.PARAMETER Ngen
|
.PARAMETER Ngen
|
||||||
For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
|
For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
|
||||||
.PARAMETER Unstable
|
.PARAMETER Unstable
|
||||||
Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
|
Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
|
||||||
.PARAMETER Global
|
.PARAMETER Global
|
||||||
Installs to configured global dnx file location (default: C:\ProgramData)
|
Installs to configured global dnx file location (default: C:\ProgramData)
|
||||||
#>
|
#>
|
||||||
|
|
@ -1165,7 +1187,7 @@ function dnvm-upgrade {
|
||||||
[ValidateSet("", "clr", "coreclr")]
|
[ValidateSet("", "clr", "coreclr")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$OS = "",
|
[string]$OS = "",
|
||||||
|
|
@ -1185,7 +1207,7 @@ function dnvm-upgrade {
|
||||||
|
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Unstable,
|
[switch]$Unstable,
|
||||||
|
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Global)
|
[switch]$Global)
|
||||||
|
|
||||||
|
|
@ -1322,7 +1344,7 @@ function dnvm-install {
|
||||||
if([String]::IsNullOrEmpty($Architecture)) {
|
if([String]::IsNullOrEmpty($Architecture)) {
|
||||||
$Architecture = Get-PackageArch $BaseName
|
$Architecture = Get-PackageArch $BaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
if([String]::IsNullOrEmpty($Runtime)) {
|
if([String]::IsNullOrEmpty($Runtime)) {
|
||||||
$Runtime = Get-PackageRuntime $BaseName
|
$Runtime = Get-PackageRuntime $BaseName
|
||||||
}
|
}
|
||||||
|
|
@ -1330,7 +1352,7 @@ function dnvm-install {
|
||||||
if([String]::IsNullOrEmpty($Version)) {
|
if([String]::IsNullOrEmpty($Version)) {
|
||||||
$Version = Get-PackageVersion $BaseName
|
$Version = Get-PackageVersion $BaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
if([String]::IsNullOrEmpty($OS)) {
|
if([String]::IsNullOrEmpty($OS)) {
|
||||||
$OS = Get-PackageOS $BaseName
|
$OS = Get-PackageOS $BaseName
|
||||||
}
|
}
|
||||||
|
|
@ -1395,12 +1417,12 @@ function dnvm-install {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
$Architecture = $runtimeInfo.Architecture
|
$Architecture = $runtimeInfo.Architecture
|
||||||
$Runtime = $runtimeInfo.Runtime
|
$Runtime = $runtimeInfo.Runtime
|
||||||
$OS = $runtimeInfo.OS
|
$OS = $runtimeInfo.OS
|
||||||
|
|
||||||
$TempFolder = Join-Path $installDir "temp"
|
$TempFolder = Join-Path $installDir "temp"
|
||||||
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
||||||
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
||||||
|
|
||||||
|
|
@ -1450,7 +1472,7 @@ function dnvm-install {
|
||||||
if($runtimeInfo.OS -eq "win") {
|
if($runtimeInfo.OS -eq "win") {
|
||||||
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($runtimeInfo.Runtime -eq "clr") {
|
if ($runtimeInfo.Runtime -eq "clr") {
|
||||||
if (-not $NoNative) {
|
if (-not $NoNative) {
|
||||||
if ((Is-Elevated) -or $Ngen) {
|
if ((Is-Elevated) -or $Ngen) {
|
||||||
|
|
@ -1470,7 +1492,7 @@ function dnvm-install {
|
||||||
else {
|
else {
|
||||||
_WriteOut "Compiling native images for $($runtimeInfo.RuntimeName) to improve startup performance..."
|
_WriteOut "Compiling native images for $($runtimeInfo.RuntimeName) to improve startup performance..."
|
||||||
Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1
|
Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1
|
||||||
|
|
||||||
if(Get-Command $CrossGenCommand -ErrorAction SilentlyContinue) {
|
if(Get-Command $CrossGenCommand -ErrorAction SilentlyContinue) {
|
||||||
$crossGenCommand = $CrossGenCommand
|
$crossGenCommand = $CrossGenCommand
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1532,7 +1554,7 @@ function dnvm-use {
|
||||||
[ValidateSet("", "clr", "coreclr")]
|
[ValidateSet("", "clr", "coreclr")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$OS = "",
|
[string]$OS = "",
|
||||||
|
|
@ -1543,17 +1565,17 @@ function dnvm-use {
|
||||||
|
|
||||||
if ($versionOrAlias -eq "none") {
|
if ($versionOrAlias -eq "none") {
|
||||||
_WriteOut "Removing all runtimes from process PATH"
|
_WriteOut "Removing all runtimes from process PATH"
|
||||||
Set-Path (Change-Path $env:Path "" ($RuntimeDirs))
|
Set-Path (Change-Path $env:Path "" $RuntimeDirs)
|
||||||
|
|
||||||
if ($Persistent) {
|
if ($Persistent) {
|
||||||
_WriteOut "Removing all runtimes from user PATH"
|
_WriteOut "Removing all runtimes from user PATH"
|
||||||
$userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
|
$userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
|
||||||
$userPath = Change-Path $userPath "" ($RuntimeDirs)
|
$userPath = Change-Path $userPath "" $RuntimeDirs
|
||||||
[Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
|
[Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS
|
$runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS
|
||||||
$runtimeFullName = $runtimeInfo.RuntimeName
|
$runtimeFullName = $runtimeInfo.RuntimeName
|
||||||
$runtimeBin = Get-RuntimePath $runtimeFullName
|
$runtimeBin = Get-RuntimePath $runtimeFullName
|
||||||
|
|
@ -1562,12 +1584,12 @@ function dnvm-use {
|
||||||
}
|
}
|
||||||
|
|
||||||
_WriteOut "Adding $runtimeBin to process PATH"
|
_WriteOut "Adding $runtimeBin to process PATH"
|
||||||
Set-Path (Change-Path $env:Path $runtimeBin ($RuntimeDirs))
|
Set-Path (Change-Path $env:Path $runtimeBin $RuntimeDirs)
|
||||||
|
|
||||||
if ($Persistent) {
|
if ($Persistent) {
|
||||||
_WriteOut "Adding $runtimeBin to user PATH"
|
_WriteOut "Adding $runtimeBin to user PATH"
|
||||||
$userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
|
$userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
|
||||||
$userPath = Change-Path $userPath $runtimeBin ($RuntimeDirs)
|
$userPath = Change-Path $userPath $runtimeBin $RuntimeDirs
|
||||||
[Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
|
[Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1667,7 +1689,7 @@ function dnvm-setup {
|
||||||
param(
|
param(
|
||||||
[switch]$SkipUserEnvironmentInstall)
|
[switch]$SkipUserEnvironmentInstall)
|
||||||
|
|
||||||
$DestinationHome = "$env:USERPROFILE\$DefaultUserDirectoryName"
|
$DestinationHome = [Environment]::ExpandEnvironmentVariables("$DefaultUserHome")
|
||||||
|
|
||||||
# Install scripts
|
# Install scripts
|
||||||
$Destination = "$DestinationHome\bin"
|
$Destination = "$DestinationHome\bin"
|
||||||
|
|
@ -1683,7 +1705,7 @@ function dnvm-setup {
|
||||||
# Also, clean old user home values if present
|
# Also, clean old user home values if present
|
||||||
# We'll be removing any existing homes, both
|
# We'll be removing any existing homes, both
|
||||||
$PathsToRemove = @(
|
$PathsToRemove = @(
|
||||||
"%USERPROFILE%\$DefaultUserDirectoryName",
|
"$DefaultUserHome",
|
||||||
[Environment]::ExpandEnvironmentVariables($OldUserHome),
|
[Environment]::ExpandEnvironmentVariables($OldUserHome),
|
||||||
$DestinationHome,
|
$DestinationHome,
|
||||||
$OldUserHome)
|
$OldUserHome)
|
||||||
|
|
@ -1699,21 +1721,8 @@ function dnvm-setup {
|
||||||
[Environment]::SetEnvironmentVariable("PATH", $userPath, "User")
|
[Environment]::SetEnvironmentVariable("PATH", $userPath, "User")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now the HomeEnvVar
|
# Now clean up the HomeEnvVar if currently set; script installed to default location.
|
||||||
_WriteOut "Adding $DestinationHome to Process $HomeEnvVar"
|
Clean-HomeEnv($SkipUserEnvironmentInstall)
|
||||||
$processHome = ""
|
|
||||||
if(Test-Path "env:\$HomeEnvVar") {
|
|
||||||
$processHome = Get-Content "env:\$HomeEnvVar"
|
|
||||||
}
|
|
||||||
$processHome = Change-Path $processHome "%USERPROFILE%\$DefaultUserDirectoryName" $PathsToRemove
|
|
||||||
Set-Content "env:\$HomeEnvVar" $processHome
|
|
||||||
|
|
||||||
if(!$SkipUserEnvironmentInstall) {
|
|
||||||
_WriteOut "Adding $DestinationHome to User $HomeEnvVar"
|
|
||||||
$userHomeVal = [Environment]::GetEnvironmentVariable($HomeEnvVar, "User")
|
|
||||||
$userHomeVal = Change-Path $userHomeVal "%USERPROFILE%\$DefaultUserDirectoryName" $PathsToRemove
|
|
||||||
[Environment]::SetEnvironmentVariable($HomeEnvVar, $userHomeVal, "User")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Check-Runtimes(){
|
function Check-Runtimes(){
|
||||||
|
|
@ -1726,19 +1735,19 @@ function Check-Runtimes(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $runtimesInstall){
|
if (-not $runtimesInstall){
|
||||||
$title = "Getting started"
|
$title = "Getting started"
|
||||||
$message = "It looks like you don't have any runtimes installed. Do you want us to install a $RuntimeShortFriendlyName to get you started?"
|
$message = "It looks like you don't have any runtimes installed. Do you want us to install a $RuntimeShortFriendlyName to get you started?"
|
||||||
|
|
||||||
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Install the latest runtime for you"
|
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Install the latest runtime for you"
|
||||||
|
|
||||||
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not install the latest runtime and continue"
|
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Do not install the latest runtime and continue"
|
||||||
|
|
||||||
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
||||||
|
|
||||||
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
|
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
|
||||||
|
|
||||||
if($result -eq 0){
|
if($result -eq 0){
|
||||||
dnvm-upgrade
|
dnvm-upgrade
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
dnvm.sh
2
dnvm.sh
|
|
@ -2,7 +2,7 @@
|
||||||
# Source this file from your .bash-profile or script to use
|
# Source this file from your .bash-profile or script to use
|
||||||
|
|
||||||
# "Constants"
|
# "Constants"
|
||||||
_DNVM_BUILDNUMBER="beta8-15516"
|
_DNVM_BUILDNUMBER="beta8-15517"
|
||||||
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
|
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
|
||||||
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
|
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
|
||||||
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
|
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue