Merge branch 'dougbu/update.dnvm' into dev

This commit is contained in:
Doug Bunting 2015-10-01 14:25:41 -07:00
commit 580fe5b651
2 changed files with 221 additions and 56 deletions

View File

@ -67,7 +67,7 @@ function _WriteOut {
### Constants ### Constants
$ProductVersion="1.0.0" $ProductVersion="1.0.0"
$BuildVersion="beta8-15518" $BuildVersion="rc1-15523"
$Authors="Microsoft Open Technologies, Inc." $Authors="Microsoft Open Technologies, Inc."
# If the Version hasn't been replaced... # If the Version hasn't been replaced...
@ -438,13 +438,13 @@ function Get-RuntimeAliasOrRuntimeInfo(
filter List-Parts { filter List-Parts {
param($aliases, $items) param($aliases, $items)
$location = "" $location = ""
$binDir = Join-Path $_.FullName "bin" $binDir = Join-Path $_.FullName "bin"
if ((Test-Path $binDir)) { if ((Test-Path $binDir)) {
$location = $_.Parent.FullName $location = $_.Parent.FullName
} }
$active = IsOnPath $binDir $active = IsOnPath $binDir
$fullAlias="" $fullAlias=""
$delim="" $delim=""
@ -1012,10 +1012,10 @@ filter ColorActive {
<# <#
.SYNOPSIS .SYNOPSIS
Displays the DNVM version. Displays the DNVM version.
#> #>
function dnvm-version { function dnvm-version {
_WriteOut "$FullVersion" _WriteOut "$FullVersion"
} }
<# <#
@ -1044,9 +1044,9 @@ function dnvm-list {
} }
} }
$aliases | Where-Object {$_.Orphan} | ForEach-Object { $aliases | Where-Object {$_.Orphan} | ForEach-Object {
$items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases $items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases
} }
if($PassThru) { if($PassThru) {
$items $items
@ -1106,12 +1106,12 @@ function dnvm-alias {
[Parameter(Position=1)] [Parameter(Position=1)]
[string]$Version, [string]$Version,
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[string]$Architecture = "", [string]$Architecture = "",
[Alias("r")] [Alias("r")]
[ValidateSet("", "clr","coreclr", "mono")] [ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(ParameterSetName="Write")] [Parameter(ParameterSetName="Write")]
[string]$Runtime = "", [string]$Runtime = "",
@ -1174,17 +1174,16 @@ function dnvm-unalias {
#> #>
function dnvm-upgrade { function dnvm-upgrade {
param( param(
[Alias("a")]
[Parameter(Mandatory=$false, Position=0)] [Parameter(Mandatory=$false, Position=0)]
[string]$Alias = "default", [string]$Alias = "default",
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[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 = "",
@ -1205,9 +1204,11 @@ function dnvm-upgrade {
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Ngen, [switch]$Ngen,
[Alias("u")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Unstable, [switch]$Unstable,
[Alias("g")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Global) [switch]$Global)
@ -1259,13 +1260,13 @@ function dnvm-install {
[Parameter(Mandatory=$false, Position=0)] [Parameter(Mandatory=$false, Position=0)]
[string]$VersionNuPkgOrAlias, [string]$VersionNuPkgOrAlias,
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Architecture = "", [string]$Architecture = "",
[Alias("r")] [Alias("r")]
[ValidateSet("", "clr","coreclr","mono")] [ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Runtime = "", [string]$Runtime = "",
@ -1273,7 +1274,6 @@ function dnvm-install {
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$OS = "", [string]$OS = "",
[Alias("a")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Alias, [string]$Alias,
@ -1290,12 +1290,15 @@ function dnvm-install {
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Ngen, [switch]$Ngen,
[Alias("p")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Persistent, [switch]$Persistent,
[Alias("u")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Unstable, [switch]$Unstable,
[Alias("g")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch]$Global) [switch]$Global)
@ -1352,7 +1355,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
} }
@ -1525,6 +1528,70 @@ function dnvm-install {
Write-Progress -Status "Done" -Activity "Install complete" -Id 1 -Complete Write-Progress -Status "Done" -Activity "Install complete" -Id 1 -Complete
} }
<#
.SYNOPSIS
Uninstalls a version of the runtime
.PARAMETER VersionOrAlias
The version to uninstall from the current channel or an alias value to uninstall an alternate
runtime or architecture flavor of the specified alias.
.PARAMETER Architecture
The processor architecture of the runtime to uninstall (default: x86)
.PARAMETER Runtime
The runtime flavor to uninstall (default: clr)
.PARAMETER OS
The operating system that the runtime targets (default: win)
#>
function dnvm-uninstall {
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias,
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[string]$Architecture = "",
[Alias("r")]
[ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)]
[string]$Runtime = "",
[ValidateSet("", "win", "osx", "darwin", "linux")]
[Parameter(Mandatory=$false)]
[string]$OS = "")
$aliasPath = Join-Path $AliasesDir "$VersionOrAlias$AliasExtension"
if(Test-Path $aliasPath) {
$BaseName = Get-Content $aliasPath
} else {
$Version = $VersionOrAlias
$runtimeInfo = GetRuntimeInfo $Architecture $Runtime $OS $Version
$BaseName = $runtimeInfo.RuntimeName
}
$runtimeFolder=""
if(Test-Path (Join-Path $RuntimesDir $BaseName)) {
$runtimeFolder = Join-Path $RuntimesDir $BaseName
}
if(Test-Path (Join-Path $GlobalRuntimesDir $BaseName)) {
$runtimeFolder = Join-Path $GlobalRuntimesDir $BaseName
}
if($runtimeFolder -ne "") {
Remove-Item -literalPath $runtimeFolder -Force -Recurse
_WriteOut "Removed '$($runtimeFolder)'"
} else {
_WriteOut "'$($BaseName)' is not installed"
}
$aliases = Get-RuntimeAlias
$result = @($aliases | Where-Object { $_.Name.EndsWith($BaseName) })
foreach($alias in $result) {
dnvm-alias -Delete -Name $alias.Alias
}
}
<# <#
.SYNOPSIS .SYNOPSIS
@ -1545,7 +1612,7 @@ function dnvm-use {
[Parameter(Mandatory=$true, Position=0)] [Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias, [string]$VersionOrAlias,
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Architecture = "", [string]$Architecture = "",
@ -1599,6 +1666,10 @@ function dnvm-use {
Locates the dnx.exe for the specified version or alias and executes it, providing the remaining arguments to dnx.exe Locates the dnx.exe for the specified version or alias and executes it, providing the remaining arguments to dnx.exe
.PARAMETER VersionOrAlias .PARAMETER VersionOrAlias
The version of alias of the runtime to execute The version of alias of the runtime to execute
.PARAMETER Architecture
The processor architecture of the runtime to use (default: x86, or whatever the alias specifies in the case of running an alias)
.PARAMETER Runtime
The runtime flavor of the runtime to use (default: clr, or whatever the alias specifies in the case of running an alias)
.PARAMETER DnxArguments .PARAMETER DnxArguments
The arguments to pass to dnx.exe The arguments to pass to dnx.exe
#> #>
@ -1607,7 +1678,7 @@ function dnvm-run {
[Parameter(Mandatory=$true, Position=0)] [Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias, [string]$VersionOrAlias,
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Architecture = "", [string]$Architecture = "",
@ -1640,6 +1711,10 @@ function dnvm-run {
Executes the specified command in a sub-shell where the PATH has been augmented to include the specified DNX Executes the specified command in a sub-shell where the PATH has been augmented to include the specified DNX
.PARAMETER VersionOrAlias .PARAMETER VersionOrAlias
The version of alias of the runtime to make active in the sub-shell The version of alias of the runtime to make active in the sub-shell
.PARAMETER Architecture
The processor architecture of the runtime to use (default: x86, or whatever the alias specifies in the case of exec-ing an alias)
.PARAMETER Runtime
The runtime flavor of the runtime to use (default: clr, or whatever the alias specifies in the case of exec-ing an alias)
.PARAMETER Command .PARAMETER Command
The command to execute in the sub-shell The command to execute in the sub-shell
#> #>
@ -1650,7 +1725,7 @@ function dnvm-exec {
[Parameter(Mandatory=$false, Position=1)] [Parameter(Mandatory=$false, Position=1)]
[string]$Command, [string]$Command,
[Alias("arch")] [Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")] [ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Architecture = "", [string]$Architecture = "",

View File

@ -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-15518" _DNVM_BUILDNUMBER="rc1-15523"
_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"
@ -220,10 +220,11 @@ __dnvm_update_self() {
__dnvm_promptSudo() { __dnvm_promptSudo() {
local acceptSudo="$1" local acceptSudo="$1"
local sudoMsg="$2"
local answer= local answer=
if [ "$acceptSudo" == "0" ]; then if [ "$acceptSudo" == "0" ]; then
echo "In order to install dnx globally, dnvm will have to temporarily run as root." echo $2
read -p "You may be prompted for your password via 'sudo' during this process. Is this Ok? (y/N) " answer read -p "You may be prompted for your password via 'sudo' during this process. Is this Ok? (y/N) " answer
else else
answer="y" answer="y"
@ -264,7 +265,7 @@ __dnvm_download() {
local useSudo= local useSudo=
mkdir -p "$runtimeFolder" > /dev/null 2>&1 mkdir -p "$runtimeFolder" > /dev/null 2>&1
if [ ! -d $runtimeFolder ]; then if [ ! -d $runtimeFolder ]; then
if ! __dnvm_promptSudo $acceptSudo ; then if ! __dnvm_promptSudo $acceptSudo "In order to install dnx globally, dnvm will have to temporarily run as root." ; then
useSudo=sudo useSudo=sudo
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1 sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
else else
@ -418,33 +419,41 @@ __dnvm_help() {
echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed" echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
echo " set installed version as default" echo " set installed version as default"
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed" echo " -f|-force force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed" echo " -u|-unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)" echo " -r|-runtime <runtime> runtime flavor to install [mono or coreclr] (default: mono)"
echo " -g|global Installs the latest $_DNVM_RUNTIME_SHORT_NAME in the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)" echo " -g|-global Installs the latest $_DNVM_RUNTIME_SHORT_NAME in the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)"
echo " -y Assume Yes to all queries and do not prompt" echo " -y Assume Yes to all queries and do not prompt"
echo "" echo ""
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] [-g|-global] [-y]${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-r <runtime>] [-OS <OS>] [-alias <alias>] [-a|-arch <architecture>] [-p|-persistent] [-f|-force] [-u|-unstable] [-g|-global] [-y]${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 " -OS <operating system> 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 " -alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
echo " -p|-persistent set installed version as default" echo " -a|-arch <architecture> architecture to use (x64)"
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed" echo " -p|-persistent set installed version as default"
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed" echo " -f|-force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
echo " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)" echo " -u|-unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
echo " -g|global Installs to the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)" echo " -r|-runtime <runtime> runtime flavor to install [mono or coreclr] (default: mono)"
echo " -y Assume Yes to all queries and do not prompt" echo " -g|-global Installs to the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)"
echo " -y Assume Yes to all queries and do not prompt"
echo "" echo ""
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line" echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME uninstall <semver> [-r|-runtime <runtime>] [-a|-arch <architecture>] [-OS <OS>]${RCol}"
echo " <semver> the version to uninstall"
echo " -r|-runtime <runtime> runtime flavor to uninstall [mono or coreclr] (default: mono)"
echo " -a|-arch <architecture> architecture to use (x64)"
echo " -OS <operating system> the operating system that the runtime targets (default:$(__dnvm_current_os))"
echo " -y Assume Yes to all queries and do not prompt"
echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME use <semver>|<alias>|<package>|none [-p|-persistent] [-r|-runtime <runtime>] [-a|-arch <architecture>] ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME use <semver>|<alias>|<package>|none [-p|-persistent] [-r|-runtime <runtime>] [-a|-arch <architecture>] ${RCol}"
echo " <semver>|<alias>|<package> add $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line " echo " <semver>|<alias>|<package> add $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line "
echo " none remove $_DNVM_RUNTIME_SHORT_NAME bin from path of current command line" echo " none remove $_DNVM_RUNTIME_SHORT_NAME bin from path of current command line"
echo " -p|-persistent set selected version as default" echo " -p|-persistent set selected version as default"
echo " -r|-runtime runtime to use (mono, coreclr)" echo " -r|-runtime <runtime> runtime flavor to use [mono or coreclr] (default: mono)"
echo " -a|-arch architecture to use (x64)" echo " -a|-arch <architecture> architecture to use (x64)"
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME run <semver>|<alias> <args...> ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME run <semver>|<alias> <args...> ${RCol}"
echo " <semver>|<alias> the version or alias to run" echo " <semver>|<alias> the version or alias to run"
@ -472,10 +481,10 @@ __dnvm_help() {
echo " display value of the specified alias" echo " display value of the specified alias"
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias <alias> <semver>|<alias>|<package> ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias <alias> <semver>|<alias>|<package> ${RCol}"
echo " <alias> the name of the alias to set" echo " <alias> the name of the alias to set"
echo " <semver>|<alias>|<package> the $_DNVM_RUNTIME_SHORT_NAME version to set the alias to. Alternatively use the version of the specified alias" echo " <semver>|<alias>|<package> the $_DNVM_RUNTIME_SHORT_NAME version to set the alias to. Alternatively use the version of the specified alias"
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME unalias <alias> ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias [-d|-delete] <alias> ${RCol}"
echo " remove the specified alias" echo " remove the specified alias"
echo "" echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol}"
@ -533,7 +542,7 @@ dnvm()
do do
if [[ $1 == "-p" || $1 == "-persistent" ]]; then if [[ $1 == "-p" || $1 == "-persistent" ]]; then
local persistent="-p" local persistent="-p"
elif [[ $1 == "-a" || $1 == "-alias" ]]; then elif [[ $1 == "-alias" ]]; then
local alias=$2 local alias=$2
shift shift
elif [[ $1 == "-f" || $1 == "-force" ]]; then elif [[ $1 == "-f" || $1 == "-force" ]]; then
@ -546,9 +555,9 @@ dnvm()
elif [[ $1 == "-OS" ]]; then elif [[ $1 == "-OS" ]]; then
local os=$2 local os=$2
shift shift
elif [[ $1 == "-y" ]]; then elif [[ $1 == "-y" ]]; then
local acceptSudo=1 local acceptSudo=1
elif [[ $1 == "-arch" ]]; then elif [[ $1 == "-a" || $1 == "-arch" ]]; then
local arch=$2 local arch=$2
shift shift
@ -660,7 +669,7 @@ dnvm()
local useSudo= local useSudo=
mkdir -p "$runtimeFolder" > /dev/null 2>&1 mkdir -p "$runtimeFolder" > /dev/null 2>&1
if [ ! -d $runtimeFolder ]; then if [ ! -d $runtimeFolder ]; then
if ! __dnvm_promptSudo $acceptSudo ; then if ! __dnvm_promptSudo $acceptSudo "In order to install dnx globally, dnvm will have to temporarily run as root." ; then
useSudo=sudo useSudo=sudo
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1 sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
else else
@ -676,6 +685,79 @@ dnvm()
fi fi
;; ;;
"uninstall" )
[[ $# -lt 2 ]] && __dnvm_help && return
shift
local versionOrAlias=
local runtime=
local architecture=
local os=
local acceptSudo=0
while [ $# -ne 0 ]
do
if [[ $1 == "-r" || $1 == "-runtime" ]]; then
local runtime=$2
shift
elif [[ $1 == "-a" || $1 == "-arch" ]]; then
local architecture=$2
shift
elif [[ $1 == "-OS" ]]; then
local os=$2
shift
elif [[ $1 == "-y" ]]; then
local acceptSudo=1
elif [[ -n $1 ]]; then
local versionOrAlias=$1
fi
shift
done
if [[ -z $os ]]; then
os=$(__dnvm_current_os)
elif [[ $os == "osx" ]]; then
os="darwin"
fi
if [[ -z $runtime ]]; then
runtime=$(__dnvm_os_runtime_defaults "$os")
fi
if [[ -z $architecture ]]; then
architecture=$(__dnvm_runtime_bitness_defaults "$runtime")
fi
# dnx-coreclr-linux-x64.1.0.0-beta7-12290
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$architecture" "$os")
for folder in `echo $DNX_HOME | tr ":" "\n"`; do
if [ -e "$folder/runtimes/$runtimeFullName" ]; then
local runtimeFolder="$folder/runtimes/$runtimeFullName"
fi
done
if [[ -e $runtimeFolder ]]; then
if [[ $runtimeFolder == *"$DNX_GLOBAL_HOME"* ]] ; then
if ! __dnvm_promptSudo $acceptSudo "In order to uninstall a global dnx, dnvm will have to temporarily run as root." ; then
local useSudo=sudo
fi
fi
$useSudo rm -r $runtimeFolder
echo "Removed $runtimeFolder"
else
echo "$runtimeFolder is not installed"
fi
if [ -d "$_DNVM_ALIAS_DIR" ]; then
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
if [ $(cat $__dnvm_file) == "$runtimeFullName" ]; then
rm $__dnvm_file
fi
done
fi
;;
"use"|"run"|"exec" ) "use"|"run"|"exec" )
[[ $1 == "use" && $# -lt 2 ]] && __dnvm_help && return [[ $1 == "use" && $# -lt 2 ]] && __dnvm_help && return
@ -795,6 +877,16 @@ dnvm()
return return
fi fi
shift shift
if [[ $1 == "-d" || $1 == "-delete" ]]; then
local name=$2
local aliasPath="$_DNVM_ALIAS_DIR/$name.alias"
[[ ! -e "$aliasPath" ]] && echo "Cannot remove alias, '$name' is not a valid alias name" && return 1
echo "Removing alias $name"
rm "$aliasPath" >> /dev/null 2>&1
return
fi
local name="$1" local name="$1"
if [[ $# == 1 ]]; then if [[ $# == 1 ]]; then
@ -836,10 +928,9 @@ dnvm()
[[ $# -ne 2 ]] && __dnvm_help && return [[ $# -ne 2 ]] && __dnvm_help && return
local name=$2 local name=$2
local aliasPath="$_DNVM_ALIAS_DIR/$name.alias" echo "This command has been deprecated. Use '$_DNVM_COMMAND_NAME alias -d' instead"
[[ ! -e "$aliasPath" ]] && echo "Cannot remove alias, '$name' is not a valid alias name" && return 1 $_DNVM_COMMAND_NAME alias -d $name
echo "Removing alias $name" return $?
rm "$aliasPath" >> /dev/null 2>&1
;; ;;
"list" ) "list" )
@ -871,7 +962,6 @@ dnvm()
# Z shell array-index starts at one. # Z shell array-index starts at one.
local i=1 local i=1
local format="%-20s %s\n"
if [ -d "$_DNVM_ALIAS_DIR" ]; then if [ -d "$_DNVM_ALIAS_DIR" ]; then
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ] && [ ! -d "$_DNVM_GLOBAL_PACKAGES/$(cat $__dnvm_file)" ]; then if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ] && [ ! -d "$_DNVM_GLOBAL_PACKAGES/$(cat $__dnvm_file)" ]; then