@@ -67,7 +67,7 @@ function _WriteOut {
67
67
68
68
# ## Constants
69
69
$ProductVersion = " 1.0.0"
70
- $BuildVersion = " beta8-15502 "
70
+ $BuildVersion = " beta8-15506 "
71
71
$Authors = " Microsoft Open Technologies, Inc."
72
72
73
73
# If the Version hasn't been replaced...
@@ -82,6 +82,7 @@ $FullVersion="$ProductVersion-$BuildVersion"
82
82
Set-Variable - Option Constant " CommandName" ([IO.Path ]::GetFileNameWithoutExtension($ScriptPath ))
83
83
Set-Variable - Option Constant " CommandFriendlyName" " .NET Version Manager"
84
84
Set-Variable - Option Constant " DefaultUserDirectoryName" " .dnx"
85
+ Set-Variable - Option Constant " DefaultGlobalDirectoryName" " Microsoft DNX"
85
86
Set-Variable - Option Constant " OldUserDirectoryNames" @ (" .kre" , " .k" )
86
87
Set-Variable - Option Constant " RuntimePackageName" " dnx"
87
88
Set-Variable - Option Constant " DefaultFeed" " https://www.nuget.org/api/v2"
@@ -155,6 +156,7 @@ $DeprecatedCommands = @("unalias")
155
156
# Load Environment variables
156
157
$RuntimeHomes = $env: DNX_HOME
157
158
$UserHome = $env: DNX_USER_HOME
159
+ $GlobalHome = $env: DNX_GLOBAL_HOME
158
160
$ActiveFeed = $env: DNX_FEED
159
161
$ActiveUnstableFeed = $env: DNX_UNSTABLE_FEED
160
162
@@ -182,11 +184,24 @@ if($CmdPathFile) {
182
184
# Determine where runtimes can exist (RuntimeHomes)
183
185
if (! $RuntimeHomes ) {
184
186
# Set up a default value for the runtime home
185
- $UnencodedHomes = " % USERPROFILE% \$DefaultUserDirectoryName "
187
+ $UnencodedHomes = " $ env: USERPROFILE \$DefaultUserDirectoryName ; $GlobalHome \ $DefaultGlobalDirectoryName "
186
188
} else {
187
189
$UnencodedHomes = $RuntimeHomes
188
190
}
189
191
192
+ # Determine the default global installation directory (GlobalHome)
193
+ if (! $GlobalHome ) {
194
+ if ($env: ProgramData ) {
195
+ $GlobalHome = " $env: ProgramData \$DefaultGlobalDirectoryName "
196
+ } else {
197
+ $GlobalHome = " $env: AllUsersProfile \$DefaultGlobalDirectoryName "
198
+ }
199
+
200
+ $env: DNX_GLOBAL_HOME = " $GlobalHome "
201
+ $env: DNX_HOME = " $env: DNX_HOME ;$env: DNX_GLOBAL_HOME "
202
+ $UnencodedHomes = " $UnencodedHomes ;$GlobalHome "
203
+ }
204
+
190
205
$UnencodedHomes = $UnencodedHomes.Split (" ;" )
191
206
$RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment ]::ExpandEnvironmentVariables($_ ) }
192
207
$RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ " runtimes" }
@@ -221,6 +236,7 @@ _WriteDebug "Runtime Homes: $RuntimeHomes"
221
236
_WriteDebug " User Home: $UserHome "
222
237
$AliasesDir = Join-Path $UserHome " alias"
223
238
$RuntimesDir = Join-Path $UserHome " runtimes"
239
+ $GlobalRuntimesDir = Join-Path $GlobalHome " runtimes"
224
240
$Aliases = $null
225
241
226
242
# ## Helper Functions
@@ -394,7 +410,7 @@ function Get-RuntimeAliasOrRuntimeInfo(
394
410
}
395
411
396
412
filter List-Parts {
397
- param ($aliases )
413
+ param ($aliases , $items )
398
414
399
415
$location = " "
400
416
@@ -422,6 +438,20 @@ filter List-Parts {
422
438
$parts2 += " x86/x64"
423
439
}
424
440
441
+ $aliasUsed = " "
442
+ if ($items ) {
443
+ $aliasUsed = $items | ForEach-Object {
444
+ if ($_.Architecture -eq $parts2 [3 ] -and $_.Runtime -eq $parts2 [1 ] -and $_.OperatingSystem -eq $parts2 [2 ] -and $_.Version -eq $parts1 [1 ]) {
445
+ return $true ;
446
+ }
447
+ return $false ;
448
+ }
449
+ }
450
+
451
+ if ($aliasUsed -eq $true ) {
452
+ $fullAlias = " "
453
+ }
454
+
425
455
return New-Object PSObject - Property @ {
426
456
Active = $active
427
457
Version = $parts1 [1 ]
@@ -693,7 +723,7 @@ function Get-RuntimePath($runtimeFullName) {
693
723
foreach ($RuntimeHome in $RuntimeHomes ) {
694
724
$runtimeBin = " $RuntimeHome \runtimes\$runtimeFullName \bin"
695
725
_WriteDebug " Candidate $runtimeBin "
696
- if (Test-Path " $runtimeBin " ) {
726
+ if (Test-Path $runtimeBin ) {
697
727
_WriteDebug " Found in $runtimeBin "
698
728
return $runtimeBin
699
729
}
@@ -976,7 +1006,7 @@ function dnvm-list {
976
1006
$RuntimeHomes | ForEach-Object {
977
1007
_WriteDebug " Scanning $_ for runtimes..."
978
1008
if (Test-Path " $_ \runtimes" ) {
979
- $items += Get-ChildItem " $_ \runtimes\$RuntimePackageName -*" | List- Parts $aliases
1009
+ $items += Get-ChildItem " $_ \runtimes\$RuntimePackageName -*" | List- Parts $aliases $items
980
1010
}
981
1011
}
982
1012
@@ -1104,7 +1134,9 @@ function dnvm-unalias {
1104
1134
. PARAMETER Ngen
1105
1135
For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
1106
1136
. PARAMETER Unstable
1107
- Upgrade from our unstable dev feed. This will give you the latest development version of the runtime.
1137
+ Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
1138
+ . PARAMETER Global
1139
+ Installs to configured global dnx file location (default: C:\ProgramData)
1108
1140
#>
1109
1141
function dnvm-upgrade {
1110
1142
param (
@@ -1140,7 +1172,10 @@ function dnvm-upgrade {
1140
1172
[switch ]$Ngen ,
1141
1173
1142
1174
[Parameter (Mandatory = $false )]
1143
- [switch ]$Unstable )
1175
+ [switch ]$Unstable ,
1176
+
1177
+ [Parameter (Mandatory = $false )]
1178
+ [switch ]$Global )
1144
1179
1145
1180
if ($OS -ne " win" -and ! [String ]::IsNullOrEmpty($OS )) {
1146
1181
# We could remove OS as an option from upgrade, but I want to take this opporunty to educate users about the difference between install and upgrade
@@ -1150,7 +1185,7 @@ function dnvm-upgrade {
1150
1185
return
1151
1186
}
1152
1187
1153
- dnvm- install " latest" - Alias:$Alias - Architecture:$Architecture - Runtime:$Runtime - OS:$OS - Force:$Force - Proxy:$Proxy - NoNative:$NoNative - Ngen:$Ngen - Unstable:$Unstable - Persistent:$true
1188
+ dnvm- install " latest" - Alias:$Alias - Architecture:$Architecture - Runtime:$Runtime - OS:$OS - Force:$Force - Proxy:$Proxy - NoNative:$NoNative - Ngen:$Ngen - Unstable:$Unstable - Persistent:$true - Global: $Global
1154
1189
}
1155
1190
1156
1191
<#
@@ -1179,7 +1214,9 @@ function dnvm-upgrade {
1179
1214
. PARAMETER Persistent
1180
1215
Make the installed runtime useable across all processes run by the current user
1181
1216
. PARAMETER Unstable
1182
- Upgrade from our unstable dev feed. This will give you the latest development version of the runtime.
1217
+ Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
1218
+ . PARAMETER Global
1219
+ Installs to configured global dnx file location (default: C:\ProgramData)
1183
1220
. DESCRIPTION
1184
1221
A proxy can also be specified by using the 'http_proxy' environment variable
1185
1222
#>
@@ -1223,7 +1260,10 @@ function dnvm-install {
1223
1260
[switch ]$Persistent ,
1224
1261
1225
1262
[Parameter (Mandatory = $false )]
1226
- [switch ]$Unstable )
1263
+ [switch ]$Unstable ,
1264
+
1265
+ [Parameter (Mandatory = $false )]
1266
+ [switch ]$Global )
1227
1267
1228
1268
$selectedFeed = " "
1229
1269
@@ -1279,7 +1319,7 @@ function dnvm-install {
1279
1319
$Version = Get-PackageVersion $BaseName
1280
1320
}
1281
1321
1282
- if ([String ]::IsNullOrEmpty($Architecture )) {
1322
+ if ([String ]::IsNullOrEmpty($OS )) {
1283
1323
$OS = Get-PackageOS $BaseName
1284
1324
}
1285
1325
} else {
@@ -1313,16 +1353,31 @@ function dnvm-install {
1313
1353
_WriteDebug " Version: $ ( $runtimeInfo.Version ) "
1314
1354
_WriteDebug " OS: $ ( $runtimeInfo.OS ) "
1315
1355
1316
- $RuntimeFolder = Join-Path $RuntimesDir $ ($runtimeInfo.RuntimeName )
1356
+ $installDir = $RuntimesDir
1357
+ if (! $Global ) {
1358
+ $RuntimeFolder = Join-Path $RuntimesDir $ ($runtimeInfo.RuntimeName )
1359
+ }
1360
+ else {
1361
+ $installDir = $GlobalRuntimesDir
1362
+ $RuntimeFolder = Join-Path $GlobalRuntimesDir $ ($runtimeInfo.RuntimeName )
1363
+ }
1364
+
1317
1365
_WriteDebug " Destination: $RuntimeFolder "
1318
1366
1319
1367
if ((Test-Path $RuntimeFolder ) -and $Force ) {
1320
1368
_WriteOut " Cleaning existing installation..."
1321
1369
Remove-Item $RuntimeFolder - Recurse - Force
1322
1370
}
1323
1371
1324
- if (Test-Path $RuntimeFolder ) {
1325
- _WriteOut " '$ ( $runtimeInfo.RuntimeName ) ' is already installed."
1372
+ $installed = " "
1373
+ if (Test-Path (Join-Path $RuntimesDir $ ($runtimeInfo.RuntimeName ))) {
1374
+ $installed = Join-Path $RuntimesDir $ ($runtimeInfo.RuntimeName )
1375
+ }
1376
+ if (Test-Path (Join-Path $GlobalRuntimesDir $ ($runtimeInfo.RuntimeName ))) {
1377
+ $installed = Join-Path $GlobalRuntimesDir $ ($runtimeInfo.RuntimeName )
1378
+ }
1379
+ if ($installed -ne " " ) {
1380
+ _WriteOut " '$ ( $runtimeInfo.RuntimeName ) ' is already installed in $installed ."
1326
1381
if ($runtimeInfo.OS -eq " win" ) {
1327
1382
dnvm- use $runtimeInfo.Version - Architecture:$runtimeInfo.Architecture - Runtime:$runtimeInfo.Runtime - Persistent:$Persistent - OS:$runtimeInfo.OS
1328
1383
}
@@ -1333,7 +1388,7 @@ function dnvm-install {
1333
1388
$Runtime = $runtimeInfo.Runtime
1334
1389
$OS = $runtimeInfo.OS
1335
1390
1336
- $TempFolder = Join-Path $RuntimesDir " temp"
1391
+ $TempFolder = Join-Path $installDir " temp"
1337
1392
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
1338
1393
$DownloadFile = Join-Path $UnpackFolder " $runtimeFullName .nupkg"
1339
1394
0 commit comments