Skip to content

Commit 1c09412

Browse files
ASP.NET Push Botunknown
authored andcommitted
⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh
Source: aspnet/dnvm@21ce03f
1 parent 7613b7e commit 1c09412

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

dnvm.ps1

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function _WriteOut {
6767

6868
### Constants
6969
$ProductVersion="1.0.0"
70-
$BuildVersion="beta6-10383"
70+
$BuildVersion="beta6-10386"
7171
$Authors="Microsoft Open Technologies, Inc."
7272

7373
# If the Version hasn't been replaced...
@@ -87,6 +87,7 @@ Set-Variable -Option Constant "RuntimePackageName" "dnx"
8787
Set-Variable -Option Constant "DefaultFeed" "https://www.nuget.org/api/v2"
8888
Set-Variable -Option Constant "DefaultUnstableFeed" "https://www.myget.org/F/aspnetvnext/api/v2"
8989
Set-Variable -Option Constant "CrossGenCommand" "dnx-crossgen"
90+
Set-Variable -Option Constant "OldCrossGenCommand" "k-crossgen"
9091
Set-Variable -Option Constant "CommandPrefix" "dnvm-"
9192
Set-Variable -Option Constant "DefaultArchitecture" "x86"
9293
Set-Variable -Option Constant "DefaultRuntime" "clr"
@@ -751,7 +752,11 @@ function dnvm-help {
751752
$Script:ExitCodes = $ExitCodes.UnknownCommand
752753
return
753754
}
754-
$help = Get-Help "dnvm-$Command" -ShowWindow:$false
755+
if($Host.Version.Major -lt 3) {
756+
$help = Get-Help "dnvm-$Command"
757+
} else {
758+
$help = Get-Help "dnvm-$Command" -ShowWindow:$false
759+
}
755760
if($PassThru -Or $Host.Version.Major -lt 3) {
756761
$help
757762
} else {
@@ -833,7 +838,11 @@ function dnvm-help {
833838
_WriteOut -ForegroundColor $ColorScheme.Help_Header "commands: "
834839
Get-Command "$CommandPrefix*" |
835840
ForEach-Object {
836-
$h = Get-Help $_.Name -ShowWindow:$false
841+
if($Host.Version.MajorVersion -lt 3) {
842+
$h = Get-Help $_.Name
843+
} else {
844+
$h = Get-Help $_.Name -ShowWindow:$false
845+
}
837846
$name = $_.Name.Substring($CommandPrefix.Length)
838847
if($DeprecatedCommands -notcontains $name) {
839848
_WriteOut -NoNewLine " "
@@ -896,31 +905,26 @@ function dnvm-list {
896905
function dnvm-alias {
897906
param(
898907
[Alias("d")]
899-
[Parameter(ParameterSetName="Delete",Mandatory=$true)]
900908
[switch]$Delete,
901909

902-
[Parameter(ParameterSetName="Read",Mandatory=$false,Position=0)]
903-
[Parameter(ParameterSetName="Write",Mandatory=$true,Position=0)]
904-
[Parameter(ParameterSetName="Delete",Mandatory=$true,Position=0)]
905910
[string]$Name,
906-
907-
[Parameter(ParameterSetName="Write",Mandatory=$true,Position=1)]
911+
908912
[string]$Version,
909913

910914
[Alias("arch")]
911915
[ValidateSet("", "x86","x64")]
912-
[Parameter(ParameterSetName="Write", Mandatory=$false)]
913916
[string]$Architecture = "",
914917

915918
[Alias("r")]
916919
[ValidateSet("", "clr","coreclr")]
917-
[Parameter(ParameterSetName="Write")]
918920
[string]$Runtime = "")
919921

920-
switch($PSCmdlet.ParameterSetName) {
921-
"Read" { Read-Alias $Name }
922-
"Write" { Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime }
923-
"Delete" { Delete-Alias $Name }
922+
if($Version) {
923+
Write-Alias $Name $Version -Architecture $Architecture -Runtime $Runtime
924+
} elseif ($Delete) {
925+
Delete-Alias $Name
926+
} else {
927+
Read-Alias $Name
924928
}
925929
}
926930

@@ -1124,7 +1128,8 @@ function dnvm-install {
11241128
else {
11251129
$Architecture = GetArch $Architecture
11261130
$Runtime = GetRuntime $Runtime
1127-
$UnpackFolder = Join-Path $RuntimesDir "temp"
1131+
$TempFolder = Join-Path $RuntimesDir "temp"
1132+
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
11281133
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
11291134

11301135
if(Test-Path $UnpackFolder) {
@@ -1155,7 +1160,19 @@ function dnvm-install {
11551160
else {
11561161
_WriteOut "Installing to $RuntimeFolder"
11571162
_WriteDebug "Moving package contents to $RuntimeFolder"
1158-
Move-Item $UnpackFolder $RuntimeFolder
1163+
try {
1164+
Move-Item $UnpackFolder $RuntimeFolder
1165+
} catch {
1166+
if(Test-Path $RuntimeFolder) {
1167+
#Attempt to cleanup the runtime folder if it is there after a fail.
1168+
Remove-Item $RuntimeFolder -Recurse -Force
1169+
throw
1170+
}
1171+
}
1172+
#If there is nothing left in the temp folder remove it. There could be other installs happening at the same time as this.
1173+
if(-Not(Test-Path $(Join-Path $TempFolder "*"))) {
1174+
Remove-Item $TempFolder -Recurse
1175+
}
11591176
}
11601177

11611178
dnvm-use $PackageVersion -Architecture:$Architecture -Runtime:$Runtime -Persistent:$Persistent
@@ -1179,11 +1196,18 @@ function dnvm-install {
11791196
else {
11801197
_WriteOut "Compiling native images for $runtimeFullName to improve startup performance..."
11811198
Write-Progress -Activity "Installing runtime" -Status "Generating runtime native images" -Id 1
1199+
1200+
if(Get-Command $CrossGenCommand -ErrorAction SilentlyContinue) {
1201+
$crossGenCommand = $CrossGenCommand
1202+
} else {
1203+
$crossGenCommand = $OldCrossGenCommand
1204+
}
1205+
11821206
if ($DebugPreference -eq 'SilentlyContinue') {
1183-
Start-Process $CrossGenCommand -Wait -WindowStyle Hidden
1207+
Start-Process $crossGenCommand -Wait -WindowStyle Hidden
11841208
}
11851209
else {
1186-
Start-Process $CrossGenCommand -Wait -NoNewWindow
1210+
Start-Process $crossGenCommand -Wait -NoNewWindow
11871211
}
11881212
_WriteOut "Finished native image compilation."
11891213
}

dnvm.sh

Lines changed: 1 addition & 1 deletion
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="beta6-10383"
5+
_DNVM_BUILDNUMBER="beta6-10386"
66
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
77
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
88
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"

0 commit comments

Comments
 (0)