⬆️ 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
$ProductVersion="1.0.0"
$BuildVersion="rc1-15522"
$BuildVersion="rc1-15523"
$Authors="Microsoft Open Technologies, Inc."
# If the Version hasn't been replaced...
@ -438,13 +438,13 @@ function Get-RuntimeAliasOrRuntimeInfo(
filter List-Parts {
param($aliases, $items)
$location = ""
$location = ""
$binDir = Join-Path $_.FullName "bin"
if ((Test-Path $binDir)) {
$binDir = Join-Path $_.FullName "bin"
if ((Test-Path $binDir)) {
$location = $_.Parent.FullName
}
$active = IsOnPath $binDir
$active = IsOnPath $binDir
$fullAlias=""
$delim=""
@ -1012,10 +1012,10 @@ filter ColorActive {
<#
.SYNOPSIS
Displays the DNVM version.
Displays the DNVM version.
#>
function dnvm-version {
_WriteOut "$FullVersion"
_WriteOut "$FullVersion"
}
<#
@ -1044,9 +1044,9 @@ function dnvm-list {
}
}
$aliases | Where-Object {$_.Orphan} | ForEach-Object {
$items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases
}
$aliases | Where-Object {$_.Orphan} | ForEach-Object {
$items += $_ | Select-Object @{label='Name';expression={$_.Name}}, @{label='FullName';expression={Join-Path $RuntimesDir $_.Name}} | List-Parts $aliases
}
if($PassThru) {
$items
@ -1106,12 +1106,12 @@ function dnvm-alias {
[Parameter(Position=1)]
[string]$Version,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[string]$Architecture = "",
[Alias("r")]
[ValidateSet("", "clr","coreclr", "mono")]
[ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(ParameterSetName="Write")]
[string]$Runtime = "",
@ -1174,17 +1174,16 @@ function dnvm-unalias {
#>
function dnvm-upgrade {
param(
[Alias("a")]
[Parameter(Mandatory=$false, Position=0)]
[string]$Alias = "default",
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[string]$Architecture = "",
[Alias("r")]
[ValidateSet("", "clr", "coreclr")]
[ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)]
[string]$Runtime = "",
@ -1205,9 +1204,11 @@ function dnvm-upgrade {
[Parameter(Mandatory=$false)]
[switch]$Ngen,
[Alias("u")]
[Parameter(Mandatory=$false)]
[switch]$Unstable,
[Alias("g")]
[Parameter(Mandatory=$false)]
[switch]$Global)
@ -1259,13 +1260,13 @@ function dnvm-install {
[Parameter(Mandatory=$false, Position=0)]
[string]$VersionNuPkgOrAlias,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[string]$Architecture = "",
[Alias("r")]
[ValidateSet("", "clr","coreclr","mono")]
[ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)]
[string]$Runtime = "",
@ -1273,7 +1274,6 @@ function dnvm-install {
[Parameter(Mandatory=$false)]
[string]$OS = "",
[Alias("a")]
[Parameter(Mandatory=$false)]
[string]$Alias,
@ -1290,12 +1290,15 @@ function dnvm-install {
[Parameter(Mandatory=$false)]
[switch]$Ngen,
[Alias("p")]
[Parameter(Mandatory=$false)]
[switch]$Persistent,
[Alias("u")]
[Parameter(Mandatory=$false)]
[switch]$Unstable,
[Alias("g")]
[Parameter(Mandatory=$false)]
[switch]$Global)
@ -1543,13 +1546,13 @@ function dnvm-uninstall {
[Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[string]$Architecture = "",
[Alias("r")]
[ValidateSet("", "clr","coreclr","mono")]
[ValidateSet("", "clr", "coreclr", "mono")]
[Parameter(Mandatory=$false)]
[string]$Runtime = "",
@ -1609,7 +1612,7 @@ function dnvm-use {
[Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[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
.PARAMETER VersionOrAlias
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
The arguments to pass to dnx.exe
#>
@ -1671,7 +1678,7 @@ function dnvm-run {
[Parameter(Mandatory=$true, Position=0)]
[string]$VersionOrAlias,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[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
.PARAMETER VersionOrAlias
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
The command to execute in the sub-shell
#>
@ -1714,7 +1725,7 @@ function dnvm-exec {
[Parameter(Mandatory=$false, Position=1)]
[string]$Command,
[Alias("arch")]
[Alias("arch", "a")]
[ValidateSet("", "x86", "x64", "arm")]
[Parameter(Mandatory=$false)]
[string]$Architecture = "",

61
dnvm.sh
View File

@ -2,7 +2,7 @@
# Source this file from your .bash-profile or script to use
# "Constants"
_DNVM_BUILDNUMBER="rc1-15522"
_DNVM_BUILDNUMBER="rc1-15523"
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
@ -419,40 +419,41 @@ __dnvm_help() {
echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
echo " set installed version as default"
echo " -f|forces 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 " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
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 " -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 " -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 " -y Assume Yes to all queries and do not prompt"
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}"
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 " 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 " -a|-alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
echo " -p|-persistent set installed version as default"
echo " -f|force force install. 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 " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)"
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"
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 " <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 " -OS <operating system> the operating system that the runtime targets (default:$(__dnvm_current_os))"
echo " -alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
echo " -a|-arch <architecture> architecture to use (x64)"
echo " -p|-persistent set installed version as default"
echo " -f|-force force install. 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 " -r|-runtime <runtime> runtime flavor to install [mono or coreclr] (default: mono)"
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 " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
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 " <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}"
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 " -p|-persistent set selected version as default"
echo " -r|-runtime runtime to use (mono, coreclr)"
echo " -a|-arch architecture to use (x64)"
echo " -r|-runtime <runtime> runtime flavor to use [mono or coreclr] (default: mono)"
echo " -a|-arch <architecture> architecture to use (x64)"
echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME run <semver>|<alias> <args...> ${RCol}"
echo " <semver>|<alias> the version or alias to run"
@ -480,8 +481,8 @@ __dnvm_help() {
echo " display value of the specified alias"
echo ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias <alias> <semver>|<alias>|<package> ${RCol}"
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 " <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 ""
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias [-d|-delete] <alias> ${RCol}"
echo " remove the specified alias"
@ -541,7 +542,7 @@ dnvm()
do
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
local persistent="-p"
elif [[ $1 == "-a" || $1 == "-alias" ]]; then
elif [[ $1 == "-alias" ]]; then
local alias=$2
shift
elif [[ $1 == "-f" || $1 == "-force" ]]; then
@ -554,9 +555,9 @@ dnvm()
elif [[ $1 == "-OS" ]]; then
local os=$2
shift
elif [[ $1 == "-y" ]]; then
elif [[ $1 == "-y" ]]; then
local acceptSudo=1
elif [[ $1 == "-arch" ]]; then
elif [[ $1 == "-a" || $1 == "-arch" ]]; then
local arch=$2
shift