parent
a54c950860
commit
d8c28a177d
68
dnvm.ps1
68
dnvm.ps1
|
|
@ -67,7 +67,7 @@ function _WriteOut {
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
$ProductVersion="1.0.0"
|
$ProductVersion="1.0.0"
|
||||||
$BuildVersion="beta8-15518"
|
$BuildVersion="beta8-15519"
|
||||||
$Authors="Microsoft Open Technologies, Inc."
|
$Authors="Microsoft Open Technologies, Inc."
|
||||||
|
|
||||||
# If the Version hasn't been replaced...
|
# If the Version hasn't been replaced...
|
||||||
|
|
@ -1352,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
|
||||||
}
|
}
|
||||||
|
|
@ -1525,6 +1525,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")]
|
||||||
|
[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
|
||||||
|
|
|
||||||
90
dnvm.sh
90
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-15518"
|
_DNVM_BUILDNUMBER="beta8-15519"
|
||||||
_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
|
||||||
|
|
@ -439,6 +440,13 @@ __dnvm_help() {
|
||||||
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 to use (mono, coreclr)"
|
||||||
|
echo " -a|-arch architecture to use (x64)"
|
||||||
|
echo " -OS 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"
|
||||||
|
|
@ -660,7 +668,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 +684,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
|
||||||
|
|
||||||
|
|
@ -871,7 +952,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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue