From b1c2447073487fab09fa907b88ffa11a9b74cc51 Mon Sep 17 00:00:00 2001 From: Brennan Date: Mon, 26 Oct 2015 14:12:16 -0700 Subject: [PATCH] Update dnvm --- build/dnvm.cmd | 2 +- build/dnvm.ps1 | 34 +++++++++++++++++++++++++--------- build/dnvm.sh | 34 +++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/build/dnvm.cmd b/build/dnvm.cmd index d2a6f5f6a3..0307ad71a1 100644 --- a/build/dnvm.cmd +++ b/build/dnvm.cmd @@ -1,6 +1,6 @@ @Echo off -set DNVM_CMD_PATH_FILE="%USERPROFILE%\.dnx\temp-set-envvars.cmd" +for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set DNVM_CMD_PATH_FILE=%%i PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm.ps1' %*" diff --git a/build/dnvm.ps1 b/build/dnvm.ps1 index a3d947ce08..0b28a8b9d2 100644 --- a/build/dnvm.ps1 +++ b/build/dnvm.ps1 @@ -67,7 +67,7 @@ function _WriteOut { ### Constants $ProductVersion="1.0.0" -$BuildVersion="rc1-15523" +$BuildVersion="rc1-15533" $Authors="Microsoft Open Technologies, Inc." # If the Version hasn't been replaced... @@ -846,6 +846,14 @@ function Is-Elevated() { return $user.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") } +function Get-ScriptRoot() { + if ($PSVersionTable.PSVersion.Major -ge 3) { + return $PSScriptRoot + } + + return Split-Path $script:MyInvocation.MyCommand.Path -Parent +} + ### Commands <# @@ -863,9 +871,10 @@ function dnvm-update-self { $wc = New-Object System.Net.WebClient Apply-Proxy $wc -Proxy:$Proxy - $dnvmFile = Join-Path $PSScriptRoot "dnvm.ps1" - $tempDnvmFile = Join-Path $PSScriptRoot "temp" - $backupFilePath = Join-Path $PSSCriptRoot "dnvm.ps1.bak" + $CurrentScriptRoot = Get-ScriptRoot + $dnvmFile = Join-Path $CurrentScriptRoot "dnvm.ps1" + $tempDnvmFile = Join-Path $CurrentScriptRoot "temp" + $backupFilePath = Join-Path $CurrentScriptRoot "dnvm.ps1.bak" $wc.DownloadFile($DNVMUpgradeUrl, $tempDnvmFile) @@ -1369,10 +1378,10 @@ function dnvm-install { if (!$IsNuPkg) { if ($VersionNuPkgOrAlias -eq "latest") { Write-Progress -Activity "Installing runtime" -Status "Determining latest runtime" -Id 1 - $findPackageResult = Find-Latest -runtimeInfo:$runtimeInfo -Feed:$selectedFeed + $findPackageResult = Find-Latest -runtimeInfo:$runtimeInfo -Feed:$selectedFeed -Proxy:$Proxy } else { - $findPackageResult = Find-Package -runtimeInfo:$runtimeInfo -Feed:$selectedFeed + $findPackageResult = Find-Package -runtimeInfo:$runtimeInfo -Feed:$selectedFeed -Proxy:$Proxy } $Version = $findPackageResult.Version } @@ -1848,10 +1857,17 @@ if(Test-Path env:\KRE_HOME) { $cmd = $args[0] +$cmdargs = @() if($args.Length -gt 1) { - $cmdargs = @($args[1..($args.Length-1)]) -} else { - $cmdargs = @() + # Combine arguments, ensuring any containing whitespace or parenthesis are correctly quoted + ForEach ($arg In $args[1..($args.Length-1)]) { + if ($arg -match "[\s\(\)]") { + $cmdargs += """$arg""" + } else { + $cmdargs += $arg + } + $cmdargs += " " + } } # Can't add this as script-level arguments because they mask '-a' arguments in subcommands! diff --git a/build/dnvm.sh b/build/dnvm.sh index 739350641b..ed4523e086 100644 --- a/build/dnvm.sh +++ b/build/dnvm.sh @@ -2,7 +2,7 @@ # Source this file from your .bash-profile or script to use # "Constants" -_DNVM_BUILDNUMBER="rc1-15523" +_DNVM_BUILDNUMBER="rc1-15533" _DNVM_AUTHORS="Microsoft Open Technologies, Inc." _DNVM_RUNTIME_PACKAGE_NAME="dnx" _DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment" @@ -38,6 +38,10 @@ __dnvm_has() { return $? } +__dnvm_to_lower() { + echo "$1" | tr '[:upper:]' '[:lower:]' +} + if __dnvm_has "unsetopt"; then unsetopt nomatch 2>/dev/null fi @@ -550,15 +554,15 @@ dnvm() elif [[ $1 == "-u" || $1 == "-unstable" ]]; then local unstable="-u" elif [[ $1 == "-r" || $1 == "-runtime" ]]; then - local runtime=$2 + local runtime=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-OS" ]]; then - local os=$2 + local os=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-y" ]]; then local acceptSudo=1 elif [[ $1 == "-a" || $1 == "-arch" ]]; then - local arch=$2 + local arch=$(__dnvm_to_lower "$2") shift if [[ $arch != "x86" && $arch != "x64" ]]; then @@ -697,13 +701,13 @@ dnvm() while [ $# -ne 0 ] do if [[ $1 == "-r" || $1 == "-runtime" ]]; then - local runtime=$2 + local runtime=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-a" || $1 == "-arch" ]]; then - local architecture=$2 + local architecture=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-OS" ]]; then - local os=$2 + local os=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-y" ]]; then local acceptSudo=1 @@ -774,10 +778,10 @@ dnvm() if [[ $1 == "-p" || $1 == "-persistent" ]]; then local persistent="true" elif [[ $1 == "-a" || $1 == "-arch" ]]; then - local arch=$2 + local arch=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-r" || $1 == "-runtime" ]]; then - local runtime=$2 + local runtime=$(__dnvm_to_lower "$2") shift elif [[ $1 == -* ]]; then echo "Invalid option $1" && __dnvm_help && return 1 @@ -791,10 +795,10 @@ dnvm() while [ $# -ne 0 ] do if [[ $1 == "-a" || $1 == "-arch" ]]; then - local arch=$2 + local arch=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-r" || $1 == "-runtime" ]]; then - local runtime=$2 + local runtime=$(__dnvm_to_lower "$2") shift elif [[ -n $1 ]]; then [[ -n $versionOrAlias ]] && break @@ -857,7 +861,7 @@ dnvm() ;; "alias" ) - [[ $# -gt 7 ]] && __dnvm_help && return + [[ $# -gt 9 ]] && __dnvm_help && return [[ ! -e "$_DNVM_ALIAS_DIR/" ]] && mkdir "$_DNVM_ALIAS_DIR/" > /dev/null @@ -902,13 +906,13 @@ dnvm() while [ $# -ne 0 ] do if [[ $1 == "-a" || $1 == "-arch" ]]; then - local arch=$2 + local arch=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-r" || $1 == "-runtime" ]]; then - local runtime=$2 + local runtime=$(__dnvm_to_lower "$2") shift elif [[ $1 == "-OS" ]]; then - local os=$2 + local os=$(__dnvm_to_lower "$2") shift fi shift