@@ -59,7 +59,7 @@ function _WriteOut {
59
59
60
60
# ## Constants
61
61
$ProductVersion = " 1.0.0"
62
- $BuildVersion = " beta4-10346 "
62
+ $BuildVersion = " beta4-10347 "
63
63
$Authors = " Microsoft Open Technologies, Inc."
64
64
65
65
# If the Version hasn't been replaced...
@@ -88,6 +88,8 @@ Set-Variable -Option Constant "OldUserHomes" @("%USERPROFILE%\.kre","%USERPROFIL
88
88
Set-Variable - Option Constant " DefaultUserHome" " %USERPROFILE%\$DefaultUserDirectoryName "
89
89
Set-Variable - Option Constant " HomeEnvVar" " DNX_HOME"
90
90
91
+ Set-Variable - Option Constant " RuntimeShortFriendlyName" " DNX"
92
+
91
93
Set-Variable - Option Constant " AsciiArt" @"
92
94
___ _ ___ ____ ___
93
95
/ _ \/ |/ / | / / |/ /
@@ -337,7 +339,12 @@ function Write-Alias {
337
339
[Parameter (Mandatory = $false )][string ]$Architecture ,
338
340
[Parameter (Mandatory = $false )][string ]$Runtime )
339
341
340
- $runtimeFullName = Get-RuntimeName $Version $Architecture $Runtime
342
+ # If the first character is non-numeric, it's a full runtime name
343
+ if (! [Char ]::IsDigit($Version [0 ])) {
344
+ $runtimeFullName = $Version
345
+ } else {
346
+ $runtimeFullName = Get-RuntimeName $Version $Architecture $Runtime
347
+ }
341
348
$aliasFilePath = Join-Path $AliasesDir " $Name .txt"
342
349
$action = if (Test-Path $aliasFilePath ) { " Updating" } else { " Setting" }
343
350
@@ -453,15 +460,45 @@ function Download-Package(
453
460
$url = " $Feed /package/" + (Get-RuntimeId $Architecture $Runtime ) + " /" + $Version
454
461
455
462
_WriteOut " Downloading $runtimeFullName from $feed "
456
-
457
463
$wc = New-Object System.Net.WebClient
458
- Apply- Proxy $wc - Proxy:$Proxy
459
- _WriteDebug " Downloading $url ..."
460
464
try {
461
- $wc.DownloadFile ($url , $DestinationFile )
462
- } catch {
463
- $Script :ExitCode = $ExitCodes.NoSuchPackage
464
- throw " Could not find $runtimeFullName .$Version on feed: $Feed "
465
+ Apply- Proxy $wc - Proxy:$Proxy
466
+ _WriteDebug " Downloading $url ..."
467
+
468
+ Register-ObjectEvent $wc DownloadProgressChanged - SourceIdentifier WebClient.ProgressChanged - action {
469
+ $Global :downloadData = $eventArgs
470
+ } | Out-Null
471
+
472
+ Register-ObjectEvent $wc DownloadFileCompleted - SourceIdentifier WebClient.ProgressComplete - action {
473
+ $Global :downloadData = $eventArgs
474
+ $Global :downloadCompleted = $true
475
+ } | Out-Null
476
+
477
+ $wc.DownloadFileAsync ($url , $DestinationFile )
478
+
479
+ while (-not $Global :downloadCompleted ){
480
+ $percent = $Global :downloadData.ProgressPercentage
481
+ $totalBytes = $Global :downloadData.TotalBytesToReceive
482
+ $receivedBytes = $Global :downloadData.BytesReceived
483
+ If ($percent -ne $null ) {
484
+ Write-Progress - Activity (" Downloading $RuntimeShortFriendlyName from $url " ) `
485
+ - Status (" Downloaded $ ( $Global :downloadData.BytesReceived ) of $ ( $Global :downloadData.TotalBytesToReceive ) bytes" ) `
486
+ - PercentComplete $percent - Id 2 - ParentId 1
487
+ }
488
+ }
489
+
490
+ if ($Global :downloadData.Error ){
491
+ throw " Unable to download package: {0}" -f $Global :downloadData.Error.Message
492
+ }
493
+
494
+ Write-Progress - Activity (" Downloading $RuntimeShortFriendlyName from $url " ) - Id 2 - ParentId 1 - Completed
495
+ }
496
+ finally {
497
+ Remove-Variable downloadData - Scope " Global"
498
+ Remove-Variable downloadCompleted - Scope " Global"
499
+ Unregister-Event - SourceIdentifier WebClient.ProgressChanged
500
+ Unregister-Event - SourceIdentifier WebClient.ProgressComplete
501
+ $wc.Dispose ()
465
502
}
466
503
}
467
504
@@ -597,7 +634,7 @@ function Ngen-Library(
597
634
$ngenCmds += " $ngenExe install $ ( $bin.FullName ) ;"
598
635
}
599
636
600
- $ngenProc = Start-Process " $psHome \powershell.exe" - Verb runAs - ArgumentList " -ExecutionPolicy unrestricted & $ngenCmds " - Wait - PassThru
637
+ $ngenProc = Start-Process " $psHome \powershell.exe" - Verb runAs - ArgumentList " -ExecutionPolicy unrestricted & $ngenCmds " - Wait - PassThru - WindowStyle Hidden
601
638
}
602
639
603
640
function Is-Elevated () {
@@ -859,7 +896,7 @@ function dnvm-upgrade {
859
896
[Parameter (Mandatory = $false )]
860
897
[switch ]$Ngen )
861
898
862
- dnvm- install " latest" - Alias:$Alias - Architecture:$Architecture - Runtime:$Runtime - Force:$Force - Proxy:$Proxy - NoNative:$NoNative - Ngen:$Ngen
899
+ dnvm- install " latest" - Alias:$Alias - Architecture:$Architecture - Runtime:$Runtime - Force:$Force - Proxy:$Proxy - NoNative:$NoNative - Ngen:$Ngen - Persistent: $true
863
900
}
864
901
865
902
<#
@@ -883,6 +920,8 @@ function dnvm-upgrade {
883
920
Skip generation of native images
884
921
. PARAMETER Ngen
885
922
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.
923
+ . PARAMETER Persistent
924
+ Make the installed runtime useable across all processes run by the current user
886
925
. DESCRIPTION
887
926
A proxy can also be specified by using the 'http_proxy' environment variable
888
927
@@ -917,7 +956,10 @@ function dnvm-install {
917
956
[switch ]$NoNative ,
918
957
919
958
[Parameter (Mandatory = $false )]
920
- [switch ]$Ngen )
959
+ [switch ]$Ngen ,
960
+
961
+ [Parameter (Mandatory = $false )]
962
+ [switch ]$Persistent )
921
963
922
964
if (! $VersionNuPkgOrAlias ) {
923
965
_WriteOut " A version, nupkg path, or the string 'latest' must be provided."
@@ -927,6 +969,7 @@ function dnvm-install {
927
969
}
928
970
929
971
if ($VersionNuPkgOrAlias -eq " latest" ) {
972
+ Write-Progress - Activity " Installing runtime" " Determining latest runtime" - Id 1
930
973
$VersionNuPkgOrAlias = Find-Latest $Runtime $Architecture
931
974
}
932
975
@@ -936,6 +979,7 @@ function dnvm-install {
936
979
if (! (Test-Path $VersionNuPkgOrAlias )) {
937
980
throw " Unable to locate package file: '$VersionNuPkgOrAlias '"
938
981
}
982
+ Write-Progress - Activity " Installing runtime" " Parsing package file name" - Id 1
939
983
$runtimeFullName = [System.IO.Path ]::GetFileNameWithoutExtension($VersionNuPkgOrAlias )
940
984
$Architecture = Get-PackageArch $runtimeFullName
941
985
$Runtime = Get-PackageRuntime $runtimeFullName
@@ -974,14 +1018,17 @@ function dnvm-install {
974
1018
New-Item - Type Directory $UnpackFolder | Out-Null
975
1019
976
1020
if ($IsNuPkg ) {
1021
+ Write-Progress - Activity " Installing runtime" " Copying package" - Id 1
977
1022
_WriteDebug " Copying local nupkg $VersionNuPkgOrAlias to $DownloadFile "
978
1023
Copy-Item $VersionNuPkgOrAlias $DownloadFile
979
1024
} else {
980
1025
# Download the package
1026
+ Write-Progress - Activity " Installing runtime" " Downloading runtime" - Id 1
981
1027
_WriteDebug " Downloading version $VersionNuPkgOrAlias to $DownloadFile "
982
1028
Download- Package $PackageVersion $Architecture $Runtime $DownloadFile - Proxy:$Proxy
983
1029
}
984
1030
1031
+ Write-Progress - Activity " Installing runtime" " Unpacking runtime" - Id 1
985
1032
Unpack- Package $DownloadFile $UnpackFolder
986
1033
987
1034
New-Item - Type Directory $RuntimeFolder - Force | Out-Null
@@ -991,12 +1038,13 @@ function dnvm-install {
991
1038
_WriteDebug " Cleaning temporary directory $UnpackFolder "
992
1039
Remove-Item $UnpackFolder - Force | Out-Null
993
1040
994
- dnvm- use $PackageVersion - Architecture:$Architecture - Runtime:$Runtime
1041
+ dnvm- use $PackageVersion - Architecture:$Architecture - Runtime:$Runtime - Persistent: $Persistent
995
1042
996
1043
if ($Runtime -eq " clr" ) {
997
1044
if (-not $NoNative ) {
998
1045
if ((Is- Elevated) -or $Ngen ) {
999
1046
$runtimeBin = Get-RuntimePath $runtimeFullName
1047
+ Write-Progress - Activity " Installing runtime" " Generating runtime native images" - Id 1
1000
1048
Ngen- Library $runtimeBin $Architecture
1001
1049
}
1002
1050
else {
@@ -1010,7 +1058,8 @@ function dnvm-install {
1010
1058
}
1011
1059
else {
1012
1060
_WriteOut " Compiling native images for $runtimeFullName to improve startup performance..."
1013
- Start-Process $CrossGenCommand - Wait
1061
+ Write-Progress - Activity " Installing runtime" " Generating runtime native images" - Id 1
1062
+ Start-Process $CrossGenCommand - Wait - WindowStyle Hidden
1014
1063
_WriteOut " Finished native image compilation."
1015
1064
}
1016
1065
}
@@ -1023,6 +1072,8 @@ function dnvm-install {
1023
1072
_WriteDebug " Aliasing installed runtime to '$Alias '"
1024
1073
dnvm- alias $Alias $PackageVersion - Architecture:$Architecture - Runtime:$Runtime
1025
1074
}
1075
+
1076
+ Write-Progress - Activity " Install complete" - Id 1 - Complete
1026
1077
}
1027
1078
1028
1079
0 commit comments