parent
a053ece997
commit
5452c71585
388
dnvm.ps1
388
dnvm.ps1
|
|
@ -67,7 +67,7 @@ function _WriteOut {
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
$ProductVersion="1.0.0"
|
$ProductVersion="1.0.0"
|
||||||
$BuildVersion="beta6-10397"
|
$BuildVersion="beta7-10399"
|
||||||
$Authors="Microsoft Open Technologies, Inc."
|
$Authors="Microsoft Open Technologies, Inc."
|
||||||
|
|
||||||
# If the Version hasn't been replaced...
|
# If the Version hasn't been replaced...
|
||||||
|
|
@ -94,6 +94,7 @@ Set-Variable -Option Constant "CommandPrefix" "dnvm-"
|
||||||
Set-Variable -Option Constant "DefaultArchitecture" "x86"
|
Set-Variable -Option Constant "DefaultArchitecture" "x86"
|
||||||
Set-Variable -Option Constant "DefaultRuntime" "clr"
|
Set-Variable -Option Constant "DefaultRuntime" "clr"
|
||||||
Set-Variable -Option Constant "AliasExtension" ".txt"
|
Set-Variable -Option Constant "AliasExtension" ".txt"
|
||||||
|
Set-Variable -Option Constant "DefaultOperatingSystem" "win"
|
||||||
|
|
||||||
# These are intentionally using "%" syntax. The environment variables are expanded whenever the value is used.
|
# These are intentionally using "%" syntax. The environment variables are expanded whenever the value is used.
|
||||||
Set-Variable -Option Constant "OldUserHomes" @("%USERPROFILE%\.kre", "%USERPROFILE%\.k")
|
Set-Variable -Option Constant "OldUserHomes" @("%USERPROFILE%\.kre", "%USERPROFILE%\.k")
|
||||||
|
|
@ -134,6 +135,8 @@ if(!$ColorScheme) {
|
||||||
"Help_Executable"=[ConsoleColor]::DarkYellow
|
"Help_Executable"=[ConsoleColor]::DarkYellow
|
||||||
"Feed_Name"=[ConsoleColor]::Cyan
|
"Feed_Name"=[ConsoleColor]::Cyan
|
||||||
"Warning" = [ConsoleColor]::Yellow
|
"Warning" = [ConsoleColor]::Yellow
|
||||||
|
"Error" = [ConsoleColor]::Red
|
||||||
|
"ActiveRuntime" = [ConsoleColor]::Cyan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,22 +257,62 @@ function Safe-Filecopy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetArch($Architecture, $FallBackArch = $DefaultArchitecture) {
|
$OSRuntimeDefaults = @{
|
||||||
if(![String]::IsNullOrEmpty($Architecture)) {
|
"win"="clr";
|
||||||
$Architecture
|
"linux"="mono";
|
||||||
} elseif($CompatArch) {
|
"darwin"="mono";
|
||||||
$CompatArch
|
|
||||||
} else {
|
|
||||||
$FallBackArch
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetRuntime($Runtime) {
|
$RuntimeBitnessDefaults = @{
|
||||||
if(![String]::IsNullOrEmpty($Runtime)) {
|
"clr"="x86";
|
||||||
$Runtime
|
"coreclr"="x64";
|
||||||
} else {
|
}
|
||||||
$DefaultRuntime
|
|
||||||
|
function GetRuntimeInfo($Architecture, $Runtime, $OS, $Version) {
|
||||||
|
$runtimeInfo = @{
|
||||||
|
"Architecture"="$Architecture";
|
||||||
|
"Runtime"="$Runtime";
|
||||||
|
"OS"="$OS";
|
||||||
|
"Version"="$Version";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($runtimeInfo.OS)) {
|
||||||
|
if($runtimeInfo.Runtime -eq "mono"){
|
||||||
|
#If OS is empty and you are asking for mono, i.e `dnvm install latest -os mono` then we don't know what OS to pick. It could be Linux or Darwin.
|
||||||
|
#we could just arbitrarily pick one but it will probably be wrong as often as not.
|
||||||
|
#If Mono can run on Windows then this error doesn't make sense anymore.
|
||||||
|
throw "Unable to determine an operating system for a $($runtimeInfo.Runtime) runtime. You must specify which OS to use with the OS parameter."
|
||||||
|
}
|
||||||
|
$runtimeInfo.OS = $DefaultOperatingSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
if($runtimeInfo.OS -eq "osx") {
|
||||||
|
$runtimeInfo.OS = "darwin"
|
||||||
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($runtimeInfo.Runtime)) {
|
||||||
|
$runtimeInfo.Runtime = $OSRuntimeDefaults.Get_Item($runtimeInfo.OS)
|
||||||
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($runtimeInfo.Architecture)) {
|
||||||
|
$runtimeInfo.Architecture = $RuntimeBitnessDefaults.Get_Item($RuntimeInfo.Runtime)
|
||||||
|
}
|
||||||
|
|
||||||
|
$runtimeObject = New-Object PSObject -Property $runtimeInfo
|
||||||
|
|
||||||
|
$runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeId -Value {
|
||||||
|
if($this.Runtime -eq "mono") {
|
||||||
|
"$RuntimePackageName-$($this.Runtime)".ToLowerInvariant()
|
||||||
|
} else {
|
||||||
|
"$RuntimePackageName-$($this.Runtime)-$($this.OS)-$($this.Architecture)".ToLowerInvariant()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$runtimeObject | Add-Member -MemberType ScriptProperty -Name RuntimeName -Value {
|
||||||
|
"$($this.RuntimeId).$($this.Version)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$runtimeObject
|
||||||
}
|
}
|
||||||
|
|
||||||
function Write-Usage {
|
function Write-Usage {
|
||||||
|
|
@ -330,32 +373,24 @@ function IsOnPath {
|
||||||
$env:Path.Split(';') -icontains $dir
|
$env:Path.Split(';') -icontains $dir
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-RuntimeId(
|
function Get-RuntimeAliasOrRuntimeInfo(
|
||||||
[Parameter()][string]$Architecture,
|
|
||||||
[Parameter()][string]$Runtime) {
|
|
||||||
|
|
||||||
$Architecture = GetArch $Architecture
|
|
||||||
$Runtime = GetRuntime $Runtime
|
|
||||||
|
|
||||||
"$RuntimePackageName-$Runtime-win-$Architecture".ToLowerInvariant()
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-RuntimeName(
|
|
||||||
[Parameter(Mandatory=$true)][string]$Version,
|
[Parameter(Mandatory=$true)][string]$Version,
|
||||||
[Parameter()][string]$Architecture,
|
[Parameter()][string]$Architecture,
|
||||||
[Parameter()][string]$Runtime) {
|
[Parameter()][string]$Runtime,
|
||||||
|
[Parameter()][string]$OS) {
|
||||||
|
|
||||||
$aliasPath = Join-Path $AliasesDir "$Version$AliasExtension"
|
$aliasPath = Join-Path $AliasesDir "$Version$AliasExtension"
|
||||||
|
|
||||||
if(Test-Path $aliasPath) {
|
if(Test-Path $aliasPath) {
|
||||||
$BaseName = Get-Content $aliasPath
|
$BaseName = Get-Content $aliasPath
|
||||||
|
|
||||||
$Architecture = GetArch $Architecture (Get-PackageArch $BaseName)
|
$Architecture = Get-PackageArch $BaseName
|
||||||
$Runtime = GetRuntime $Runtime (Get-PackageArch $BaseName)
|
$Runtime = Get-PackageRuntime $BaseName
|
||||||
$Version = Get-PackageVersion $BaseName
|
$Version = Get-PackageVersion $BaseName
|
||||||
|
$OS = Get-PackageOS $BaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
"$(Get-RuntimeId $Architecture $Runtime).$Version"
|
GetRuntimeInfo $Architecture $Runtime $OS $Version
|
||||||
}
|
}
|
||||||
|
|
||||||
filter List-Parts {
|
filter List-Parts {
|
||||||
|
|
@ -379,6 +414,12 @@ filter List-Parts {
|
||||||
|
|
||||||
$parts1 = $_.Name.Split('.', 2)
|
$parts1 = $_.Name.Split('.', 2)
|
||||||
$parts2 = $parts1[0].Split('-', 4)
|
$parts2 = $parts1[0].Split('-', 4)
|
||||||
|
|
||||||
|
if($parts1[0] -eq "$RuntimePackageName-mono") {
|
||||||
|
$parts2 += "linux/darwin"
|
||||||
|
$parts2 += "x86/x64"
|
||||||
|
}
|
||||||
|
|
||||||
return New-Object PSObject -Property @{
|
return New-Object PSObject -Property @{
|
||||||
Active = $active
|
Active = $active
|
||||||
Version = $parts1[1]
|
Version = $parts1[1]
|
||||||
|
|
@ -411,14 +452,16 @@ function Write-Alias {
|
||||||
[Parameter(Mandatory=$true)][string]$Name,
|
[Parameter(Mandatory=$true)][string]$Name,
|
||||||
[Parameter(Mandatory=$true)][string]$Version,
|
[Parameter(Mandatory=$true)][string]$Version,
|
||||||
[Parameter(Mandatory=$false)][string]$Architecture,
|
[Parameter(Mandatory=$false)][string]$Architecture,
|
||||||
[Parameter(Mandatory=$false)][string]$Runtime)
|
[Parameter(Mandatory=$false)][string]$Runtime,
|
||||||
|
[Parameter(Mandatory=$false)][string]$OS)
|
||||||
|
|
||||||
# If the first character is non-numeric, it's a full runtime name
|
# If the first character is non-numeric, it's a full runtime name
|
||||||
if(![Char]::IsDigit($Version[0])) {
|
if(![Char]::IsDigit($Version[0])) {
|
||||||
$runtimeFullName = $Version
|
$runtimeInfo = GetRuntimeInfo $(Get-PackageArch $Version) $(Get-PackageRuntime $Version) $(Get-PackageOS $Version) $(Get-PackageVersion $Version)
|
||||||
} else {
|
} else {
|
||||||
$runtimeFullName = Get-RuntimeName $Version $Architecture $Runtime
|
$runtimeInfo = GetRuntimeInfo $Architecture $Runtime $OS $Version
|
||||||
}
|
}
|
||||||
|
|
||||||
$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" }
|
||||||
|
|
||||||
|
|
@ -426,8 +469,8 @@ function Write-Alias {
|
||||||
_WriteDebug "Creating alias directory: $AliasesDir"
|
_WriteDebug "Creating alias directory: $AliasesDir"
|
||||||
New-Item -Type Directory $AliasesDir | Out-Null
|
New-Item -Type Directory $AliasesDir | Out-Null
|
||||||
}
|
}
|
||||||
_WriteOut "$action alias '$Name' to '$runtimeFullName'"
|
_WriteOut "$action alias '$Name' to '$($runtimeInfo.RuntimeName)'"
|
||||||
$runtimeFullName | Out-File $aliasFilePath ascii
|
$runtimeInfo.RuntimeName | Out-File $aliasFilePath ascii
|
||||||
}
|
}
|
||||||
|
|
||||||
function Delete-Alias {
|
function Delete-Alias {
|
||||||
|
|
@ -468,16 +511,15 @@ param(
|
||||||
|
|
||||||
function Find-Latest {
|
function Find-Latest {
|
||||||
param(
|
param(
|
||||||
[string]$runtime = "",
|
$runtimeInfo,
|
||||||
[string]$architecture = "",
|
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$Feed,
|
[string]$Feed,
|
||||||
[string]$Proxy
|
[string]$Proxy
|
||||||
)
|
)
|
||||||
|
|
||||||
_WriteOut "Determining latest version"
|
_WriteOut "Determining latest version"
|
||||||
|
$RuntimeId = $runtimeInfo.RuntimeId
|
||||||
$RuntimeId = Get-RuntimeId -Architecture:"$architecture" -Runtime:"$runtime"
|
_WriteDebug "Latest RuntimeId: $RuntimeId"
|
||||||
$url = "$Feed/GetUpdates()?packageIds=%27$RuntimeId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
|
$url = "$Feed/GetUpdates()?packageIds=%27$RuntimeId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
|
||||||
# NOTE: DO NOT use Invoke-WebRequest. It requires PowerShell 4.0!
|
# NOTE: DO NOT use Invoke-WebRequest. It requires PowerShell 4.0!
|
||||||
|
|
||||||
|
|
@ -522,18 +564,23 @@ function Get-PackageArch() {
|
||||||
return $runtimeFullName -replace "$RuntimePackageName-[^-]*-[^-]*-([^.]*).*", '$1'
|
return $runtimeFullName -replace "$RuntimePackageName-[^-]*-[^-]*-([^.]*).*", '$1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-PackageOS() {
|
||||||
|
param(
|
||||||
|
[string] $runtimeFullName
|
||||||
|
)
|
||||||
|
$runtimeFullName -replace "$RuntimePackageName-[^-]*-([^-]*)-[^.]*.*", '$1'
|
||||||
|
}
|
||||||
|
|
||||||
function Download-Package(
|
function Download-Package(
|
||||||
[string]$Version,
|
$runtimeInfo,
|
||||||
[string]$Architecture,
|
|
||||||
[string]$Runtime,
|
|
||||||
[string]$DestinationFile,
|
[string]$DestinationFile,
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$Feed,
|
[string]$Feed,
|
||||||
[string]$Proxy) {
|
[string]$Proxy) {
|
||||||
|
|
||||||
$url = "$Feed/package/" + (Get-RuntimeId $Architecture $Runtime) + "/" + $Version
|
|
||||||
|
|
||||||
_WriteOut "Downloading $runtimeFullName from $feed"
|
$url = "$Feed/package/" + ($runtimeInfo.RuntimeId) + "/" + $runtimeInfo.Version
|
||||||
|
_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
|
||||||
|
|
@ -736,8 +783,19 @@ function dnvm-update-self {
|
||||||
_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"
|
||||||
$wc.DownloadFile($DNVMUpgradeUrl, $dnvmFile)
|
$tempDnvmFile = Join-Path $PSScriptRoot "dnvm.ps1" "temp"
|
||||||
|
$backupFilePath = Join-Path $PSSCriptRoot "dnvm.ps1.bak"
|
||||||
|
|
||||||
|
$wc.DownloadFile($DNVMUpgradeUrl, $tempDnvmFile)
|
||||||
|
|
||||||
|
if(Test-Path $backupFilePath) {
|
||||||
|
Remove-Item $backupFilePath -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
Rename-Item $dnvmFile $backupFilePath
|
||||||
|
Rename-Item $tempDnvmFile $dnvmFile
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
@ -861,17 +919,36 @@ function dnvm-help {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter ColorActive {
|
||||||
|
param([string] $color)
|
||||||
|
$lines = $_.Split("`n")
|
||||||
|
foreach($line in $lines) {
|
||||||
|
if($line.Contains("*")){
|
||||||
|
_WriteOut -ForegroundColor $ColorScheme.ActiveRuntime $line
|
||||||
|
} else {
|
||||||
|
_WriteOut $line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists available runtimes
|
Lists available runtimes
|
||||||
|
.PARAMETER Detailed
|
||||||
|
Display more detailed information on each runtime
|
||||||
.PARAMETER PassThru
|
.PARAMETER PassThru
|
||||||
Set this switch to return unformatted powershell objects for use in scripting
|
Set this switch to return unformatted powershell objects for use in scripting
|
||||||
#>
|
#>
|
||||||
function dnvm-list {
|
function dnvm-list {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$false)][switch]$PassThru)
|
[Parameter(Mandatory=$false)][switch]$PassThru,
|
||||||
|
[Parameter(Mandatory=$false)][switch]$Detailed)
|
||||||
$aliases = Get-RuntimeAlias
|
$aliases = Get-RuntimeAlias
|
||||||
|
|
||||||
|
if(-not $PassThru) {
|
||||||
|
Check-Runtimes
|
||||||
|
}
|
||||||
|
|
||||||
$items = @()
|
$items = @()
|
||||||
$RuntimeHomes | ForEach-Object {
|
$RuntimeHomes | ForEach-Object {
|
||||||
_WriteDebug "Scanning $_ for runtimes..."
|
_WriteDebug "Scanning $_ for runtimes..."
|
||||||
|
|
@ -883,9 +960,20 @@ function dnvm-list {
|
||||||
if($PassThru) {
|
if($PassThru) {
|
||||||
$items
|
$items
|
||||||
} else {
|
} else {
|
||||||
$items |
|
if($items) {
|
||||||
Sort-Object Version, Runtime, Architecture, Alias |
|
#TODO: Probably a better way to do this.
|
||||||
Format-Table -AutoSize -Property @{name="Active";expression={if($_.Active) { "*" } else { "" }};alignment="center"}, "Version", "Runtime", "Architecture", "Location", "Alias"
|
if($Detailed) {
|
||||||
|
$items |
|
||||||
|
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
|
||||||
|
} else {
|
||||||
|
$items |
|
||||||
|
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
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_WriteOut "No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -900,6 +988,8 @@ function dnvm-list {
|
||||||
The architecture of the runtime to assign to this alias
|
The architecture of the runtime to assign to this alias
|
||||||
.PARAMETER Runtime
|
.PARAMETER Runtime
|
||||||
The flavor of the runtime to assign to this alias
|
The flavor of the runtime to assign to this alias
|
||||||
|
.PARAMETER OS
|
||||||
|
The operating system that the runtime targets
|
||||||
.PARAMETER Delete
|
.PARAMETER Delete
|
||||||
Set this switch to delete the alias with the specified name
|
Set this switch to delete the alias with the specified name
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
|
|
@ -909,14 +999,20 @@ 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
|
||||||
|
an alias to help make it easier to switch the runtime, and you cannot use a non-windows
|
||||||
|
runtime on a windows machine.
|
||||||
#>
|
#>
|
||||||
function dnvm-alias {
|
function dnvm-alias {
|
||||||
param(
|
param(
|
||||||
[Alias("d")]
|
[Alias("d")]
|
||||||
[switch]$Delete,
|
[switch]$Delete,
|
||||||
|
|
||||||
|
[Parameter(Position=0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(Position=1)]
|
||||||
[string]$Version,
|
[string]$Version,
|
||||||
|
|
||||||
[Alias("arch")]
|
[Alias("arch")]
|
||||||
|
|
@ -924,11 +1020,23 @@ function dnvm-alias {
|
||||||
[string]$Architecture = "",
|
[string]$Architecture = "",
|
||||||
|
|
||||||
[Alias("r")]
|
[Alias("r")]
|
||||||
[ValidateSet("", "clr", "coreclr")]
|
[ValidateSet("", "clr","coreclr", "mono")]
|
||||||
[string]$Runtime = "")
|
[Parameter(ParameterSetName="Write")]
|
||||||
|
[string]$Runtime = "",
|
||||||
|
|
||||||
|
[ValidateSet("win", "osx", "darwin", "linux")]
|
||||||
|
[Parameter(Mandatory=$false,ParameterSetName="Write")]
|
||||||
|
[string]$OS = "")
|
||||||
|
|
||||||
|
if($Name -like "help" -or $Name -like "/?") {
|
||||||
|
#It is unlikely that the user is trying to read an alias called help, so lets just help them out by displaying help text.
|
||||||
|
#If people need an alias called help or one that contains a `?` then we can change this to a prompt.
|
||||||
|
dnvm help alias
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if($Version) {
|
if($Version) {
|
||||||
Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime
|
Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime -OS:$OS
|
||||||
} elseif ($Delete) {
|
} elseif ($Delete) {
|
||||||
Delete-Alias $Name
|
Delete-Alias $Name
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -958,6 +1066,8 @@ function dnvm-unalias {
|
||||||
The processor architecture of the runtime to install (default: x86)
|
The processor architecture of the runtime to install (default: x86)
|
||||||
.PARAMETER Runtime
|
.PARAMETER Runtime
|
||||||
The runtime flavor to install (default: clr)
|
The runtime flavor to install (default: clr)
|
||||||
|
.PARAMETER OS
|
||||||
|
The operating system that the runtime targets (default: win)
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Overwrite an existing runtime if it already exists
|
Overwrite an existing runtime if it already exists
|
||||||
.PARAMETER Proxy
|
.PARAMETER Proxy
|
||||||
|
|
@ -985,6 +1095,10 @@ function dnvm-upgrade {
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
|
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$OS = "",
|
||||||
|
|
||||||
[Alias("f")]
|
[Alias("f")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Force,
|
[switch]$Force,
|
||||||
|
|
@ -1001,7 +1115,15 @@ function dnvm-upgrade {
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Unstable)
|
[switch]$Unstable)
|
||||||
|
|
||||||
dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true
|
if($OS -ne "win") {
|
||||||
|
#We could remove OS as an option from upgrade, but I want to take this opporunty to educate users about the difference between install and upgrade
|
||||||
|
#It's possible we should just do install here instead.
|
||||||
|
_WriteOut -ForegroundColor $ColorScheme.Error "You cannot upgrade to a non-windows runtime. Upgrade will download the latest version of the $RuntimeShortFriendlyName and also set it as your machines default. You cannot set the default $RuntimeShortFriendlyName to a non-windows version because you cannot use it to run an application. If you want to install a non-windows $RuntimeShortFriendlyName to package with your application then use 'dnvm install latest -OS:$OS' instead. Install will download the package but not set it as your default."
|
||||||
|
$Script:ExitCode = $ExitCodes.OtherError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
@ -1015,6 +1137,8 @@ function dnvm-upgrade {
|
||||||
The processor architecture of the runtime to install (default: x86)
|
The processor architecture of the runtime to install (default: x86)
|
||||||
.PARAMETER Runtime
|
.PARAMETER Runtime
|
||||||
The runtime flavor to install (default: clr)
|
The runtime flavor to install (default: clr)
|
||||||
|
.PARAMETER OS
|
||||||
|
The operating system that the runtime targets (default: win)
|
||||||
.PARAMETER Alias
|
.PARAMETER Alias
|
||||||
Set alias <Alias> to the installed runtime
|
Set alias <Alias> to the installed runtime
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
|
|
@ -1043,10 +1167,14 @@ function dnvm-install {
|
||||||
[string]$Architecture = "",
|
[string]$Architecture = "",
|
||||||
|
|
||||||
[Alias("r")]
|
[Alias("r")]
|
||||||
[ValidateSet("", "clr", "coreclr")]
|
[ValidateSet("", "clr","coreclr","mono")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
|
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$OS = "",
|
||||||
|
|
||||||
[Alias("a")]
|
[Alias("a")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Alias,
|
[string]$Alias,
|
||||||
|
|
@ -1095,11 +1223,6 @@ function dnvm-install {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($VersionNuPkgOrAlias -eq "latest") {
|
|
||||||
Write-Progress -Status "Determining Latest Runtime" -Activity "Installing runtime" -Id 1
|
|
||||||
$VersionNuPkgOrAlias = Find-Latest $Runtime $Architecture -Feed:$selectedFeed
|
|
||||||
}
|
|
||||||
|
|
||||||
$IsNuPkg = $VersionNuPkgOrAlias.EndsWith(".nupkg")
|
$IsNuPkg = $VersionNuPkgOrAlias.EndsWith(".nupkg")
|
||||||
|
|
||||||
if ($IsNuPkg) {
|
if ($IsNuPkg) {
|
||||||
|
|
@ -1110,18 +1233,52 @@ function dnvm-install {
|
||||||
$runtimeFullName = [System.IO.Path]::GetFileNameWithoutExtension($VersionNuPkgOrAlias)
|
$runtimeFullName = [System.IO.Path]::GetFileNameWithoutExtension($VersionNuPkgOrAlias)
|
||||||
$Architecture = Get-PackageArch $runtimeFullName
|
$Architecture = Get-PackageArch $runtimeFullName
|
||||||
$Runtime = Get-PackageRuntime $runtimeFullName
|
$Runtime = Get-PackageRuntime $runtimeFullName
|
||||||
|
$OS = Get-PackageOS $runtimeFullName
|
||||||
|
$Version = Get-PackageVersion $VersionNuPkgOrAlias
|
||||||
} else {
|
} else {
|
||||||
$runtimeFullName = Get-RuntimeName $VersionNuPkgOrAlias -Architecture:$Architecture -Runtime:$Runtime
|
$aliasPath = Join-Path $AliasesDir "$VersionNuPkgOrAlias$AliasExtension"
|
||||||
|
if(Test-Path $aliasPath) {
|
||||||
|
$BaseName = Get-Content $aliasPath
|
||||||
|
#Check empty checks let us override a given alias property when installing the same again. e.g. `dnvm install default -x64`
|
||||||
|
if([String]::IsNullOrEmpty($Architecture)) {
|
||||||
|
$Architecture = Get-PackageArch $BaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($Runtime)) {
|
||||||
|
$Runtime = Get-PackageRuntime $BaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($Version)) {
|
||||||
|
$Version = Get-PackageVersion $BaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
if([String]::IsNullOrEmpty($Architecture)) {
|
||||||
|
$OS = Get-PackageOS $BaseName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$PackageVersion = Get-PackageVersion $runtimeFullName
|
$runtimeInfo = GetRuntimeInfo $Architecture $Runtime $OS $VersionNupkgOrAlias
|
||||||
|
|
||||||
_WriteDebug "Preparing to install runtime '$runtimeFullName'"
|
if ($VersionNuPkgOrAlias -eq "latest") {
|
||||||
_WriteDebug "Architecture: $Architecture"
|
Write-Progress -Activity "Installing runtime" -Status "Determining latest runtime" -Id 1
|
||||||
_WriteDebug "Runtime: $Runtime"
|
$Version = Find-Latest -runtimeInfo:$runtimeInfo -Feed:$selectedFeed
|
||||||
_WriteDebug "Version: $PackageVersion"
|
}
|
||||||
|
|
||||||
$RuntimeFolder = Join-Path $RuntimesDir $runtimeFullName
|
#If the version is still empty at this point then VersionOrNupkgOrAlias is an actual version.
|
||||||
|
if([String]::IsNullOrEmpty($Version)) {
|
||||||
|
$Version = $VersionNuPkgOrAlias
|
||||||
|
}
|
||||||
|
|
||||||
|
$runtimeInfo.Version = $Version
|
||||||
|
|
||||||
|
_WriteDebug "Preparing to install runtime '$($runtimeInfo.RuntimeName)'"
|
||||||
|
_WriteDebug "Architecture: $($runtimeInfo.Architecture)"
|
||||||
|
_WriteDebug "Runtime: $($runtimeInfo.Runtime)"
|
||||||
|
_WriteDebug "Version: $($runtimeInfo.Version)"
|
||||||
|
_WriteDebug "OS: $($runtimeInfo.OS)"
|
||||||
|
|
||||||
|
$RuntimeFolder = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName)
|
||||||
_WriteDebug "Destination: $RuntimeFolder"
|
_WriteDebug "Destination: $RuntimeFolder"
|
||||||
|
|
||||||
if((Test-Path $RuntimeFolder) -and $Force) {
|
if((Test-Path $RuntimeFolder) -and $Force) {
|
||||||
|
|
@ -1130,12 +1287,17 @@ function dnvm-install {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Test-Path $RuntimeFolder) {
|
if(Test-Path $RuntimeFolder) {
|
||||||
_WriteOut "'$runtimeFullName' is already installed."
|
_WriteOut "'$($runtimeInfo.RuntimeName)' is already installed."
|
||||||
dnvm-use $PackageVersion -Architecture:$Architecture -Runtime:$Runtime -Persistent:$Persistent
|
if($runtimeInfo.OS -eq "win") {
|
||||||
|
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$Architecture = GetArch $Architecture
|
|
||||||
$Runtime = GetRuntime $Runtime
|
$Architecture = $runtimeInfo.Architecture
|
||||||
|
$Runtime = $runtimeInfo.Runtime
|
||||||
|
$OS = $runtimeInfo.OS
|
||||||
|
|
||||||
$TempFolder = Join-Path $RuntimesDir "temp"
|
$TempFolder = Join-Path $RuntimesDir "temp"
|
||||||
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
||||||
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
||||||
|
|
@ -1153,9 +1315,9 @@ function dnvm-install {
|
||||||
} else {
|
} else {
|
||||||
# Download the package
|
# Download the package
|
||||||
Write-Progress -Activity "Installing runtime" -Status "Downloading runtime" -Id 1
|
Write-Progress -Activity "Installing runtime" -Status "Downloading runtime" -Id 1
|
||||||
_WriteDebug "Downloading version $VersionNuPkgOrAlias to $DownloadFile"
|
_WriteDebug "Downloading version $($runtimeInfo.Version) to $DownloadFile"
|
||||||
|
|
||||||
Download-Package $PackageVersion $Architecture $Runtime $DownloadFile -Proxy:$Proxy -Feed:$selectedFeed
|
Download-Package -RuntimeInfo:$runtimeInfo -DestinationFile:$DownloadFile -Proxy:$Proxy -Feed:$selectedFeed
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Progress -Activity "Installing runtime" -Status "Unpacking runtime" -Id 1
|
Write-Progress -Activity "Installing runtime" -Status "Unpacking runtime" -Id 1
|
||||||
|
|
@ -1163,7 +1325,7 @@ function dnvm-install {
|
||||||
|
|
||||||
if(Test-Path $RuntimeFolder) {
|
if(Test-Path $RuntimeFolder) {
|
||||||
# Ensure the runtime hasn't been installed in the time it took to download the package.
|
# Ensure the runtime hasn't been installed in the time it took to download the package.
|
||||||
_WriteOut "'$runtimeFullName' is already installed."
|
_WriteOut "'$($runtimeInfo.RuntimeName)' is already installed."
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_WriteOut "Installing to $RuntimeFolder"
|
_WriteOut "Installing to $RuntimeFolder"
|
||||||
|
|
@ -1178,31 +1340,33 @@ function dnvm-install {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#If there is nothing left in the temp folder remove it. There could be other installs happening at the same time as this.
|
#If there is nothing left in the temp folder remove it. There could be other installs happening at the same time as this.
|
||||||
if(-Not(Test-Path $(Join-Path $TempFolder "*"))) {
|
if(Test-Path $(Join-Path $TempFolder "*")) {
|
||||||
Remove-Item $TempFolder -Recurse
|
Remove-Item $TempFolder -Recurse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dnvm-use $PackageVersion -Architecture:$Architecture -Runtime:$Runtime -Persistent:$Persistent
|
if($runtimeInfo.OS -eq "win") {
|
||||||
|
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
||||||
|
}
|
||||||
|
|
||||||
if ($Runtime -eq "clr") {
|
if ($runtimeInfo.Runtime -eq "clr") {
|
||||||
if (-not $NoNative) {
|
if (-not $NoNative) {
|
||||||
if ((Is-Elevated) -or $Ngen) {
|
if ((Is-Elevated) -or $Ngen) {
|
||||||
$runtimeBin = Get-RuntimePath $runtimeFullName
|
$runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName
|
||||||
Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1
|
Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1
|
||||||
Ngen-Library $runtimeBin $Architecture
|
Ngen-Library $runtimeBin $runtimeInfo.Architecture
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_WriteOut "Native image generation (ngen) is skipped. Include -Ngen switch to turn on native image generation to improve application startup time."
|
_WriteOut "Native image generation (ngen) is skipped. Include -Ngen switch to turn on native image generation to improve application startup time."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($Runtime -eq "coreclr") {
|
elseif ($runtimeInfo.Runtime -eq "coreclr") {
|
||||||
if ($NoNative) {
|
if ($NoNative -or $runtimeInfo.OS -ne "win") {
|
||||||
_WriteOut "Skipping native image compilation."
|
_WriteOut "Skipping native image compilation."
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_WriteOut "Compiling native images for $runtimeFullName 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) {
|
||||||
|
|
@ -1221,13 +1385,17 @@ function dnvm-install {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_WriteOut "Unexpected platform: $Runtime. No optimization would be performed on the package installed."
|
_WriteOut "Unexpected platform: $($runtimeInfo.Runtime). No optimization would be performed on the package installed."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($Alias) {
|
if($Alias) {
|
||||||
_WriteDebug "Aliasing installed runtime to '$Alias'"
|
if($runtimeInfo.OS -eq "win") {
|
||||||
dnvm-alias $Alias $PackageVersion -Architecture:$Architecture -Runtime:$Runtime
|
_WriteDebug "Aliasing installed runtime to '$Alias'"
|
||||||
|
dnvm-alias $Alias $runtimeInfo.Version -Architecture:$RuntimeInfo.Architecture -Runtime:$RuntimeInfo.Runtime -OS:$RuntimeInfo.OS
|
||||||
|
} else {
|
||||||
|
_WriteOut "Unable to set an alias for a non-windows runtime. Installing non-windows runtimes on Windows are meant only for publishing, not running."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Progress -Status "Done" -Activity "Install complete" -Id 1 -Complete
|
Write-Progress -Status "Done" -Activity "Install complete" -Id 1 -Complete
|
||||||
|
|
@ -1243,6 +1411,8 @@ function dnvm-install {
|
||||||
The processor architecture of the runtime to place on the PATH (default: x86, or whatever the alias specifies in the case of use-ing an alias)
|
The processor architecture of the runtime to place on the PATH (default: x86, or whatever the alias specifies in the case of use-ing an alias)
|
||||||
.PARAMETER Runtime
|
.PARAMETER Runtime
|
||||||
The runtime flavor of the runtime to place on the PATH (default: clr, or whatever the alias specifies in the case of use-ing an alias)
|
The runtime flavor of the runtime to place on the PATH (default: clr, or whatever the alias specifies in the case of use-ing an alias)
|
||||||
|
.PARAMETER OS
|
||||||
|
The operating system that the runtime targets (default: win)
|
||||||
.PARAMETER Persistent
|
.PARAMETER Persistent
|
||||||
Make the change persistent across all processes run by the current user
|
Make the change persistent across all processes run by the current user
|
||||||
#>
|
#>
|
||||||
|
|
@ -1261,6 +1431,10 @@ function dnvm-use {
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[string]$Runtime = "",
|
[string]$Runtime = "",
|
||||||
|
|
||||||
|
[ValidateSet("", "win", "osx", "darwin", "linux")]
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[string]$OS = "",
|
||||||
|
|
||||||
[Alias("p")]
|
[Alias("p")]
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Persistent)
|
[switch]$Persistent)
|
||||||
|
|
@ -1278,7 +1452,8 @@ function dnvm-use {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime
|
$runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS
|
||||||
|
$runtimeFullName = $runtimeInfo.RuntimeName
|
||||||
$runtimeBin = Get-RuntimePath $runtimeFullName
|
$runtimeBin = Get-RuntimePath $runtimeFullName
|
||||||
if ($runtimeBin -eq $null) {
|
if ($runtimeBin -eq $null) {
|
||||||
throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?"
|
throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?"
|
||||||
|
|
@ -1321,10 +1496,11 @@ function dnvm-run {
|
||||||
[Parameter(Mandatory=$false, Position=1, ValueFromRemainingArguments=$true)]
|
[Parameter(Mandatory=$false, Position=1, ValueFromRemainingArguments=$true)]
|
||||||
[object[]]$DnxArguments)
|
[object[]]$DnxArguments)
|
||||||
|
|
||||||
$runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime
|
$runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias
|
||||||
$runtimeBin = Get-RuntimePath $runtimeFullName
|
|
||||||
|
$runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName
|
||||||
if ($runtimeBin -eq $null) {
|
if ($runtimeBin -eq $null) {
|
||||||
throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?"
|
throw "Cannot find $($runtimeInfo.Name), do you need to run '$CommandName install $versionOrAlias'?"
|
||||||
}
|
}
|
||||||
$dnxExe = Join-Path $runtimeBin "dnx.exe"
|
$dnxExe = Join-Path $runtimeBin "dnx.exe"
|
||||||
if(!(Test-Path $dnxExe)) {
|
if(!(Test-Path $dnxExe)) {
|
||||||
|
|
@ -1361,10 +1537,11 @@ function dnvm-exec {
|
||||||
[Parameter(Mandatory=$false, Position=2, ValueFromRemainingArguments=$true)]
|
[Parameter(Mandatory=$false, Position=2, ValueFromRemainingArguments=$true)]
|
||||||
[object[]]$Arguments)
|
[object[]]$Arguments)
|
||||||
|
|
||||||
$runtimeFullName = Get-RuntimeName $VersionOrAlias $Architecture $Runtime
|
$runtimeInfo = Get-RuntimeAliasOrRuntimeInfo -Version:$VersionOrAlias
|
||||||
$runtimeBin = Get-RuntimePath $runtimeFullName
|
$runtimeBin = Get-RuntimePath $runtimeInfo.RuntimeName
|
||||||
|
|
||||||
if ($runtimeBin -eq $null) {
|
if ($runtimeBin -eq $null) {
|
||||||
throw "Cannot find $runtimeFullName, do you need to run '$CommandName install $versionOrAlias'?"
|
throw "Cannot find $($runtimeInfo.RuntimeName), do you need to run '$CommandName install $versionOrAlias'?"
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldPath = $env:PATH
|
$oldPath = $env:PATH
|
||||||
|
|
@ -1435,6 +1612,35 @@ function dnvm-setup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Check-Runtimes(){
|
||||||
|
$runtimesInstall = $false;
|
||||||
|
foreach($runtimeHomeDir in $RuntimeHomes) {
|
||||||
|
if (Test-Path "$runtimeHomeDir\runtimes") {
|
||||||
|
if(Test-Path "$runtimeHomeDir\runtimes\$RuntimePackageName-*"){
|
||||||
|
$runtimesInstall = $true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $runtimesInstall){
|
||||||
|
$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?"
|
||||||
|
|
||||||
|
$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"
|
||||||
|
|
||||||
|
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
||||||
|
|
||||||
|
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
|
||||||
|
|
||||||
|
if($result -eq 0){
|
||||||
|
dnvm-upgrade
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
### The main "entry point"
|
### The main "entry point"
|
||||||
|
|
||||||
# Check for old DNX_HOME values
|
# Check for old DNX_HOME values
|
||||||
|
|
@ -1475,7 +1681,7 @@ if($cmdargs -icontains "-amd64") {
|
||||||
$cmdargs = @($cmdargs | Where-Object { @("-amd64", "-x86", "-x64") -notcontains $_ })
|
$cmdargs = @($cmdargs | Where-Object { @("-amd64", "-x86", "-x64") -notcontains $_ })
|
||||||
|
|
||||||
if(!$cmd) {
|
if(!$cmd) {
|
||||||
_WriteOut "You must specify a command!"
|
Check-Runtimes
|
||||||
$cmd = "help"
|
$cmd = "help"
|
||||||
$Script:ExitCode = $ExitCodes.InvalidArguments
|
$Script:ExitCode = $ExitCodes.InvalidArguments
|
||||||
}
|
}
|
||||||
|
|
|
||||||
145
dnvm.sh
145
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="beta6-10397"
|
_DNVM_BUILDNUMBER="beta7-10399"
|
||||||
_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"
|
||||||
|
|
@ -67,13 +67,37 @@ __dnvm_current_os()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__dnvm_os_runtime_defaults()
|
||||||
|
{
|
||||||
|
local os=$1
|
||||||
|
|
||||||
|
if [[ $os == "win" ]]; then
|
||||||
|
echo "clr"
|
||||||
|
elif [[ $os == "linux" ]]; then
|
||||||
|
echo "mono"
|
||||||
|
elif [[ $os == "darwin" ]]; then
|
||||||
|
echo "mono"
|
||||||
|
else
|
||||||
|
echo "unknown os"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__dnvm_runtime_bitness_defaults()
|
||||||
|
{
|
||||||
|
local runtime=$1
|
||||||
|
if [[ $runtime == "clr" ]]; then
|
||||||
|
echo "x86"
|
||||||
|
elif [[ $runtime == "coreclr" ]]; then
|
||||||
|
echo "x64"
|
||||||
|
else
|
||||||
|
echo "unknown runtime"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
__dnvm_find_latest() {
|
__dnvm_find_latest() {
|
||||||
local platform=$1
|
local platform=$1
|
||||||
local arch=$2
|
local arch=$2
|
||||||
|
local os=$3
|
||||||
if [ -z $platform ]; then
|
|
||||||
local platform="mono"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! __dnvm_has "curl"; then
|
if ! __dnvm_has "curl"; then
|
||||||
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
|
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
|
||||||
|
|
@ -85,12 +109,14 @@ __dnvm_find_latest() {
|
||||||
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform"
|
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform"
|
||||||
else
|
else
|
||||||
#dnx-coreclr-linux-x64
|
#dnx-coreclr-linux-x64
|
||||||
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$(__dnvm_current_os)-$arch"
|
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$os-$arch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
|
local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
|
||||||
xml="$(curl $url 2>/dev/null)"
|
xml="$(curl $url 2>/dev/null)"
|
||||||
echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1
|
echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1
|
||||||
version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')"
|
version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')"
|
||||||
|
|
||||||
echo $version
|
echo $version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,6 +155,15 @@ __dnvm_package_arch() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__dnvm_package_os() {
|
||||||
|
local runtimeFullName="$1"
|
||||||
|
if [[ "$runtimeFullName" =~ "mono" ]]; then
|
||||||
|
echo "linux/darwin"
|
||||||
|
else
|
||||||
|
echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-[^-.]*-\([^.-]*\).*/\1/"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
__dnvm_update_self() {
|
__dnvm_update_self() {
|
||||||
local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh"
|
local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh"
|
||||||
if [ ! -e $dnvmFileLocation ]; then
|
if [ ! -e $dnvmFileLocation ]; then
|
||||||
|
|
@ -212,16 +247,19 @@ __dnvm_unpack() {
|
||||||
|
|
||||||
#Set shell commands as executable
|
#Set shell commands as executable
|
||||||
find "$runtimeFolder/bin/" -type f \
|
find "$runtimeFolder/bin/" -type f \
|
||||||
-exec sh -c "head -c 20 {} | grep '/usr/bin/env bash\|/bin/bash' > /dev/null" \; -print | xargs chmod 775
|
-exec sh -c "head -c 20 {} | grep '/usr/bin/env bash\|/bin/bash' > /dev/null" \; -print | xargs -r chmod 775
|
||||||
|
|
||||||
#Set dnx to be executable
|
#Set dnx to be executable
|
||||||
chmod 775 "$runtimeFolder/bin/dnx"
|
if [[ -s "$runtimeFolder/bin/dnx" ]]; then
|
||||||
|
chmod 775 "$runtimeFolder/bin/dnx"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__dnvm_requested_version_or_alias() {
|
__dnvm_requested_version_or_alias() {
|
||||||
local versionOrAlias="$1"
|
local versionOrAlias="$1"
|
||||||
local runtime="$2"
|
local runtime="$2"
|
||||||
local arch="$3"
|
local arch="$3"
|
||||||
|
local os="$4"
|
||||||
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias")
|
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias")
|
||||||
|
|
||||||
# If the name specified is an existing package, just use it as is
|
# If the name specified is an existing package, just use it as is
|
||||||
|
|
@ -233,18 +271,17 @@ __dnvm_requested_version_or_alias() {
|
||||||
echo "$runtimeFullName"
|
echo "$runtimeFullName"
|
||||||
else
|
else
|
||||||
local pkgVersion=$versionOrAlias
|
local pkgVersion=$versionOrAlias
|
||||||
|
local pkgArchitecture="x64"
|
||||||
|
local pkgSystem=$os
|
||||||
|
|
||||||
if [[ -z $runtime || "$runtime" == "mono" ]]; then
|
if [[ -z $runtime || "$runtime" == "mono" ]]; then
|
||||||
echo "$_DNVM_RUNTIME_PACKAGE_NAME-mono.$pkgVersion"
|
echo "$_DNVM_RUNTIME_PACKAGE_NAME-mono.$pkgVersion"
|
||||||
elif [[ "$runtime" == "coreclr" ]]; then
|
else
|
||||||
local pkgArchitecture="x64"
|
|
||||||
local pkgSystem=$(__dnvm_current_os)
|
|
||||||
|
|
||||||
if [ "$arch" != "" ]; then
|
if [ "$arch" != "" ]; then
|
||||||
local pkgArchitecture="$arch"
|
local pkgArchitecture="$arch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$_DNVM_RUNTIME_PACKAGE_NAME-coreclr-$pkgSystem-$pkgArchitecture.$pkgVersion"
|
echo "$_DNVM_RUNTIME_PACKAGE_NAME-$runtime-$pkgSystem-$pkgArchitecture.$pkgVersion"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
@ -303,10 +340,11 @@ __dnvm_help() {
|
||||||
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed"
|
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed"
|
||||||
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
|
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
|
||||||
echo ""
|
echo ""
|
||||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}"
|
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-r <runtime>] [-OS <OS>] [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}"
|
||||||
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
|
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||||
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
|
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
|
||||||
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed"
|
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||||
|
echo " -OS the operating system that the runtime targets (default:$(__dnvm_current_os)"
|
||||||
echo " -a|-alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
|
echo " -a|-alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
|
||||||
echo " -p|-persistent set installed version as default"
|
echo " -p|-persistent set installed version as default"
|
||||||
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
||||||
|
|
@ -336,7 +374,9 @@ __dnvm_help() {
|
||||||
echo " runs the specified command in the context of the specified version of the runtime without affecting the current PATH"
|
echo " runs the specified command in the context of the specified version of the runtime without affecting the current PATH"
|
||||||
echo " example: $_DNVM_COMMAND_NAME exec 1.0.0-beta4 $_DNVM_PACKAGE_MANAGER_NAME build"
|
echo " example: $_DNVM_COMMAND_NAME exec 1.0.0-beta4 $_DNVM_PACKAGE_MANAGER_NAME build"
|
||||||
echo ""
|
echo ""
|
||||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME list ${RCol}"
|
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME list [-detailed]${RCol}"
|
||||||
|
echo " -detailed display more detailed information on each runtime"
|
||||||
|
echo ""
|
||||||
echo " list $_DNVM_RUNTIME_SHORT_NAME versions installed "
|
echo " list $_DNVM_RUNTIME_SHORT_NAME versions installed "
|
||||||
echo ""
|
echo ""
|
||||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias ${RCol}"
|
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias ${RCol}"
|
||||||
|
|
@ -391,8 +431,9 @@ dnvm()
|
||||||
local alias=
|
local alias=
|
||||||
local force=
|
local force=
|
||||||
local unstable=
|
local unstable=
|
||||||
local runtime="mono"
|
local os=
|
||||||
local arch="x64"
|
local runtime=
|
||||||
|
local arch=
|
||||||
while [ $# -ne 0 ]
|
while [ $# -ne 0 ]
|
||||||
do
|
do
|
||||||
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
||||||
|
|
@ -407,6 +448,9 @@ dnvm()
|
||||||
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
|
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
|
||||||
local runtime=$2
|
local runtime=$2
|
||||||
shift
|
shift
|
||||||
|
elif [[ $1 == "-OS" ]]; then
|
||||||
|
local os=$2
|
||||||
|
shift
|
||||||
elif [[ $1 == "-arch" ]]; then
|
elif [[ $1 == "-arch" ]]; then
|
||||||
local arch=$2
|
local arch=$2
|
||||||
shift
|
shift
|
||||||
|
|
@ -416,11 +460,6 @@ dnvm()
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $arch == "x86" && $runtime == "coreclr" ]]; then
|
|
||||||
printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64.${RCol}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ -n $1 ]]; then
|
elif [[ -n $1 ]]; then
|
||||||
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
||||||
local versionOrAlias=$1
|
local versionOrAlias=$1
|
||||||
|
|
@ -428,6 +467,11 @@ dnvm()
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ $arch == "x86" && $runtime == "coreclr" && $os != "win" ]]; then
|
||||||
|
printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64.${RCol}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z $unstable ]; then
|
if [ -z $unstable ]; then
|
||||||
DNX_ACTIVE_FEED="$DNX_FEED"
|
DNX_ACTIVE_FEED="$DNX_FEED"
|
||||||
if [ -z "$DNX_ACTIVE_FEED" ]; then
|
if [ -z "$DNX_ACTIVE_FEED" ]; then
|
||||||
|
|
@ -444,13 +488,28 @@ dnvm()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $os ]]; then
|
||||||
|
os=$(__dnvm_current_os)
|
||||||
|
fi
|
||||||
|
if [[ $os == "osx" ]]; then
|
||||||
|
os="darwin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $runtime ]]; then
|
||||||
|
runtime=$(__dnvm_os_runtime_defaults "$os")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $arch ]]; then
|
||||||
|
arch=$(__dnvm_runtime_bitness_defaults "$runtime")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $runtime == "mono" ]] && ! __dnvm_has "mono"; then
|
if [[ $runtime == "mono" ]] && ! __dnvm_has "mono"; then
|
||||||
printf "%b\n" "${Yel}It appears you don't have Mono available. Remember to get Mono before trying to run $DNVM_RUNTIME_SHORT_NAME application. ${RCol}" >&2;
|
printf "%b\n" "${Yel}It appears you don't have Mono available. Remember to get Mono before trying to run $DNVM_RUNTIME_SHORT_NAME application. ${RCol}" >&2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$versionOrAlias" == "latest" ]]; then
|
if [[ "$versionOrAlias" == "latest" ]]; then
|
||||||
echo "Determining latest version"
|
echo "Determining latest version"
|
||||||
versionOrAlias=$(__dnvm_find_latest "$runtime" "$arch")
|
versionOrAlias=$(__dnvm_find_latest "$runtime" "$arch" "$os")
|
||||||
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
|
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
|
||||||
printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}"
|
printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}"
|
||||||
fi
|
fi
|
||||||
|
|
@ -478,12 +537,14 @@ dnvm()
|
||||||
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
|
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
|
||||||
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion"
|
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion"
|
||||||
else
|
else
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
||||||
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName"
|
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName"
|
||||||
__dnvm_download "$runtimeFullName" "$runtimeFolder" "$force"
|
__dnvm_download "$runtimeFullName" "$runtimeFolder" "$force"
|
||||||
[[ $? == 1 ]] && return 1
|
[[ $? == 1 ]] && return 1
|
||||||
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch"
|
if [[ "$os" == $(__dnvm_current_os) ]]; then
|
||||||
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias"
|
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch"
|
||||||
|
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
@ -533,7 +594,7 @@ dnvm()
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$(__dnvm_current_os)")
|
||||||
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$runtimeFullName")
|
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$runtimeFullName")
|
||||||
|
|
||||||
if [[ -z $runtimeBin ]]; then
|
if [[ -z $runtimeBin ]]; then
|
||||||
|
|
@ -612,11 +673,14 @@ dnvm()
|
||||||
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
|
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
|
||||||
local runtime=$2
|
local runtime=$2
|
||||||
shift
|
shift
|
||||||
|
elif [[ $1 == "-OS" ]]; then
|
||||||
|
local os=$2
|
||||||
|
shift
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
||||||
|
|
||||||
[[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
|
[[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
|
||||||
|
|
||||||
|
|
@ -642,10 +706,6 @@ dnvm()
|
||||||
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
|
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
|
||||||
|
|
||||||
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
|
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
|
||||||
if [ $# == 2 ]; then
|
|
||||||
local versionOrAlias=$2
|
|
||||||
local searchGlob=$(__dnvm_requested_version_or_alias "$versionOrAlias")
|
|
||||||
fi
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Separate empty array declaration from initialization
|
# Separate empty array declaration from initialization
|
||||||
|
|
@ -663,9 +723,15 @@ dnvm()
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local formatString="%-6s %-20s %-7s %-4s %-20s %s\n"
|
if [[ $2 == "-detailed" ]]; then
|
||||||
printf "$formatString" "Active" "Version" "Runtime" "Arch" "Location" "Alias"
|
local formatString="%-6s %-20s %-7s %-4s %-15s %-20s %s\n"
|
||||||
printf "$formatString" "------" "-------" "-------" "----" "--------" "-----"
|
printf "$formatString" "Active" "Version" "Runtime" "Arch" "OperatingSystem" "Location" "Alias"
|
||||||
|
printf "$formatString" "------" "-------" "-------" "----" "---------------" "--------" "-----"
|
||||||
|
else
|
||||||
|
local formatString="%-6s %-20s %-7s %-4s %-15s %s\n"
|
||||||
|
printf "$formatString" "Active" "Version" "Runtime" "Arch" "OperatingSystem" "Alias"
|
||||||
|
printf "$formatString" "------" "-------" "-------" "----" "---------------" "-----"
|
||||||
|
fi
|
||||||
|
|
||||||
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
|
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
|
||||||
for f in $(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;); do
|
for f in $(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;); do
|
||||||
|
|
@ -675,6 +741,7 @@ dnvm()
|
||||||
local pkgName=$(__dnvm_package_name "$f")
|
local pkgName=$(__dnvm_package_name "$f")
|
||||||
local pkgVersion=$(__dnvm_package_version "$f")
|
local pkgVersion=$(__dnvm_package_version "$f")
|
||||||
local pkgArch=$(__dnvm_package_arch "$f")
|
local pkgArch=$(__dnvm_package_arch "$f")
|
||||||
|
local pkgOs=$(__dnvm_package_os "$f")
|
||||||
|
|
||||||
local alias=""
|
local alias=""
|
||||||
local delim=""
|
local delim=""
|
||||||
|
|
@ -685,12 +752,14 @@ dnvm()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$formattedHome" "$alias"
|
if [[ $2 == "-detailed" ]]; then
|
||||||
[[ $# == 2 ]] && echo "" && return 0
|
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$formattedHome" "$alias"
|
||||||
|
else
|
||||||
|
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
[[ $# == 2 ]] && echo "$versionOrAlias not found" && return 1
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue