Skip to content

Commit 1124e50

Browse files
ASP.NET Push Botunknown
authored andcommitted
⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh
Source: aspnet/dnvm@2697ee5
1 parent 67dc3f5 commit 1124e50

File tree

2 files changed

+68
-20
lines changed

2 files changed

+68
-20
lines changed

dnvm.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function _WriteOut {
6767

6868
### Constants
6969
$ProductVersion="1.0.0"
70-
$BuildVersion="beta5-10368"
70+
$BuildVersion="beta5-10370"
7171
$Authors="Microsoft Open Technologies, Inc."
7272

7373
# If the Version hasn't been replaced...

dnvm.sh

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Source this file from your .bash-profile or script to use
33

44
# "Constants"
5-
_DNVM_BUILDNUMBER="beta5-10368"
5+
_DNVM_BUILDNUMBER="beta5-10370"
66
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
77
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
88
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
@@ -64,14 +64,26 @@ __dnvm_current_os()
6464
}
6565

6666
__dnvm_find_latest() {
67-
local platform="mono"
67+
local platform=$1
68+
local arch=$2
69+
70+
if [ -z $platform ]; then
71+
local platform="mono"
72+
fi
6873

6974
if ! __dnvm_has "curl"; then
7075
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
7176
return 1
7277
fi
73-
74-
local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$_DNVM_RUNTIME_PACKAGE_NAME-$platform%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
78+
79+
if [[ $platform == "mono" ]]; then
80+
#dnx-mono
81+
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform"
82+
else
83+
#dnx-coreclr-linux-x64
84+
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$platform-$(__dnvm_current_os)-$arch"
85+
fi
86+
local url="$DNX_ACTIVE_FEED/GetUpdates()?packageIds=%27$packageId%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false"
7587
xml="$(curl $url 2>/dev/null)"
7688
echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1
7789
version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')"
@@ -164,7 +176,7 @@ __dnvm_download() {
164176

165177
if [[ $httpResult == "404" ]]; then
166178
printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}"
167-
printf "%b\n" "${Cya}This is most likely caused by the feed not having the version that you typed. Check that you typed the right version and try again. Other possible causes are the feed doesn't have a $DNVM_RUNTIME_SHORT_NAME of the right name format or some other error caused a 404 on the server.${RCol}"
179+
printf "%b\n" "${Cya}This is most likely caused by the feed not having the version that you typed. Check that you typed the right version and try again. Other possible causes are the feed doesn't have a $_DNVM_RUNTIME_SHORT_NAME of the right name format or some other error caused a 404 on the server.${RCol}"
168180
return 1
169181
fi
170182
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1
@@ -276,7 +288,7 @@ __dnvm_description() {
276288
}
277289

278290
__dnvm_help() {
279-
UNSTABLE___dnvm_description
291+
__dnvm_description
280292
printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}"
281293
echo ""
282294
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] ${RCol}"
@@ -285,6 +297,7 @@ __dnvm_help() {
285297
echo " set installed version as default"
286298
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
287299
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed"
300+
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
288301
echo ""
289302
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}"
290303
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
@@ -294,6 +307,7 @@ __dnvm_help() {
294307
echo " -p|-persistent set installed version as default"
295308
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
296309
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable unstable feed"
310+
echo " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)"
297311
echo ""
298312
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
299313
echo ""
@@ -362,7 +376,7 @@ dnvm()
362376

363377
"upgrade" )
364378
shift
365-
$_DNVM_COMMAND_NAME install latest -p $1
379+
$_DNVM_COMMAND_NAME install latest -p $@
366380
;;
367381

368382
"install" )
@@ -373,6 +387,8 @@ dnvm()
373387
local alias=
374388
local force=
375389
local unstable=
390+
local runtime="mono"
391+
local arch="x64"
376392
while [ $# -ne 0 ]
377393
do
378394
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
@@ -384,6 +400,23 @@ dnvm()
384400
local force="-f"
385401
elif [[ $1 == "-u" || $1 == "-unstable" ]]; then
386402
local unstable="-u"
403+
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
404+
local runtime=$2
405+
shift
406+
elif [[ $1 == "-arch" ]]; then
407+
local arch=$2
408+
shift
409+
410+
if [[ $arch != "x86" && $arch != "x64" ]]; then
411+
printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}"
412+
return 1
413+
fi
414+
415+
if [[ $arch == "x86" && $runtime == "coreclr" ]]; then
416+
printf "%b\n" "${Red}Core CLR doesn't currently have a 32 bit build. You must use x64."
417+
return 1
418+
fi
419+
387420
elif [[ -n $1 ]]; then
388421
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
389422
local versionOrAlias=$1
@@ -407,14 +440,14 @@ dnvm()
407440
fi
408441
fi
409442

410-
if ! __dnvm_has "mono"; then
443+
if [[ $runtime == "mono" ]] && ! __dnvm_has "mono"; then
411444
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;
412445
fi
413446

414447
if [[ "$versionOrAlias" == "latest" ]]; then
415-
echo "Determining latest version"
416-
versionOrAlias=$(__dnvm_find_latest)
417-
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
448+
echo "Determining latest version"
449+
versionOrAlias=$(__dnvm_find_latest "$runtime" "$arch")
450+
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
418451
printf "%b\n" "Latest version is ${Cya}$versionOrAlias ${RCol}"
419452
fi
420453

@@ -433,19 +466,19 @@ dnvm()
433466
if [ -e "$runtimeFolder" ]; then
434467
echo "$runtimeFullName already installed"
435468
else
436-
mkdir "$runtimeFolder" > /dev/null 2>&1
469+
mkdir -p "$runtimeFolder" > /dev/null 2>&1
437470
cp -a "$versionOrAlias" "$runtimeFile"
438471
__dnvm_unpack "$runtimeFile" "$runtimeFolder"
439472
[[ $? == 1 ]] && return 1
440473
fi
441474
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
442475
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion"
443476
else
444-
local runtimeFullName="$(__dnvm_requested_version_or_alias $versionOrAlias)"
477+
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch")
445478
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName"
446479
__dnvm_download "$runtimeFullName" "$runtimeFolder" "$force"
447480
[[ $? == 1 ]] && return 1
448-
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent"
481+
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch"
449482
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias"
450483
fi
451484
;;
@@ -535,7 +568,7 @@ dnvm()
535568
;;
536569

537570
"alias" )
538-
[[ $# -gt 3 ]] && __dnvm_help && return
571+
[[ $# -gt 7 ]] && __dnvm_help && return
539572

540573
[[ ! -e "$_DNVM_ALIAS_DIR/" ]] && mkdir "$_DNVM_ALIAS_DIR/" > /dev/null
541574

@@ -554,17 +587,32 @@ dnvm()
554587
echo ""
555588
return
556589
fi
590+
shift
591+
local name="$1"
557592

558-
local name="$2"
559-
560-
if [[ $# == 2 ]]; then
593+
if [[ $# == 1 ]]; then
561594
[[ ! -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && echo "There is no alias called '$name'" && return
562595
cat "$_DNVM_ALIAS_DIR/$name.alias"
563596
echo ""
564597
return
565598
fi
566599

567-
local runtimeFullName=$(__dnvm_requested_version_or_alias "$3")
600+
shift
601+
local versionOrAlias="$1"
602+
shift
603+
while [ $# -ne 0 ]
604+
do
605+
if [[ $1 == "-a" || $1 == "-arch" ]]; then
606+
local arch=$2
607+
shift
608+
elif [[ $1 == "-r" || $1 == "-runtime" ]]; then
609+
local runtime=$2
610+
shift
611+
fi
612+
shift
613+
done
614+
615+
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch")
568616

569617
[[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
570618

0 commit comments

Comments
 (0)