⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh

Source: aspnet/dnvm@f0a8ba2897
This commit is contained in:
ASP.NET Push Bot 2015-09-30 19:21:22 -07:00 committed by unknown
parent 36968d5cc3
commit cc903dde20
2 changed files with 65 additions and 53 deletions

View File

@ -67,7 +67,7 @@ function _WriteOut {
### Constants ### Constants
$ProductVersion="1.0.0" $ProductVersion="1.0.0"
$BuildVersion="rc1-15522" $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)
@ -1543,13 +1546,13 @@ function dnvm-uninstall {
[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 = "",
[Alias("r")] [Alias("r")]
[ValidateSet("", "clr","coreclr","mono")] [ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string]$Runtime = "", [string]$Runtime = "",
@ -1609,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 = "",
@ -1663,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
#> #>
@ -1671,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 = "",
@ -1704,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
#> #>
@ -1714,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 = "",

61
dnvm.sh
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="rc1-15522" _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"
@ -419,40 +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}" 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 " <semver> the version to uninstall"
echo " -r|-runtime runtime to use (mono, coreclr)" echo " -r|-runtime <runtime> runtime flavor to uninstall [mono or coreclr] (default: mono)"
echo " -a|-arch architecture to use (x64)" echo " -a|-arch <architecture> architecture to use (x64)"
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 " -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 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"
@ -480,8 +481,8 @@ __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 alias [-d|-delete] <alias> ${RCol}" printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias [-d|-delete] <alias> ${RCol}"
echo " remove the specified alias" echo " remove the specified alias"
@ -541,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
@ -554,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