Skip to content

Commit c6547cc

Browse files
ASP.NET Push Botunknown
authored andcommitted
⬆️ dnvm.ps1, dnvm.cmd, dnvm.sh
Source: aspnet/dnvm@82929ba
1 parent 8373764 commit c6547cc

File tree

2 files changed

+50
-27
lines changed

2 files changed

+50
-27
lines changed

dnvm.ps1

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function _WriteOut {
5959

6060
### Constants
6161
$ProductVersion="1.0.0"
62-
$BuildVersion="beta4-10347"
62+
$BuildVersion="beta5-10350"
6363
$Authors="Microsoft Open Technologies, Inc."
6464

6565
# If the Version hasn't been replaced...
@@ -511,7 +511,7 @@ function Unpack-Package([string]$DownloadFile, [string]$UnpackFolder) {
511511
try {
512512
# Shell will not recognize nupkg as a zip and throw, so rename it to zip
513513
$runtimeZip = [System.IO.Path]::ChangeExtension($DownloadFile, "zip")
514-
Rename-Item $runtimeFile $runtimeZip
514+
Rename-Item $DownloadFile $runtimeZip
515515
# Use the shell to uncompress the nupkg
516516
$shell_app=new-object -com shell.application
517517
$zip_file = $shell_app.namespace($runtimeZip)
@@ -1054,13 +1054,18 @@ function dnvm-install {
10541054
}
10551055
elseif ($Runtime -eq "coreclr") {
10561056
if ($NoNative) {
1057-
_WriteOut "Skipping native image compilation."
1057+
_WriteOut "Skipping native image compilation."
10581058
}
10591059
else {
1060-
_WriteOut "Compiling native images for $runtimeFullName to improve startup performance..."
1061-
Write-Progress -Activity "Installing runtime" "Generating runtime native images" -Id 1
1062-
Start-Process $CrossGenCommand -Wait -WindowStyle Hidden
1063-
_WriteOut "Finished native image compilation."
1060+
_WriteOut "Compiling native images for $runtimeFullName to improve startup performance..."
1061+
Write-Progress -Activity "Installing runtime" "Generating runtime native images" -Id 1
1062+
if ($DebugPreference -eq 'SilentlyContinue') {
1063+
Start-Process $CrossGenCommand -Wait -WindowStyle Hidden
1064+
}
1065+
else {
1066+
Start-Process $CrossGenCommand -Wait -NoNewWindow
1067+
}
1068+
_WriteOut "Finished native image compilation."
10641069
}
10651070
}
10661071
else {
@@ -1173,6 +1178,40 @@ function dnvm-name {
11731178
Get-RuntimeName $VersionOrAlias $Architecture $Runtime
11741179
}
11751180

1181+
1182+
# Checks if a specified file exists in the destination folder and if not, copies the file
1183+
# to the destination folder.
1184+
function Safe-Filecopy {
1185+
param(
1186+
[Parameter(Mandatory=$true, Position=0)] $Filename,
1187+
[Parameter(Mandatory=$true, Position=1)] $SourceFolder,
1188+
[Parameter(Mandatory=$true, Position=2)] $DestinationFolder)
1189+
1190+
# Make sure the destination folder is created if it doesn't already exist.
1191+
if(!(Test-Path $DestinationFolder)) {
1192+
_WriteOut "Creating destination folder '$DestinationFolder' ... "
1193+
1194+
New-Item -Type Directory $Destination | Out-Null
1195+
}
1196+
1197+
$sourceFilePath = Join-Path $SourceFolder $Filename
1198+
$destFilePath = Join-Path $DestinationFolder $Filename
1199+
1200+
if(Test-Path $sourceFilePath) {
1201+
_WriteOut "Installing '$Filename' to '$DestinationFolder' ... "
1202+
1203+
if (Test-Path $destFilePath) {
1204+
_WriteOut " Skipping: file already exists" -ForegroundColor Yellow
1205+
}
1206+
else {
1207+
Copy-Item $sourceFilePath $destFilePath -Force
1208+
}
1209+
}
1210+
else {
1211+
_WriteOut "WARNING: Unable to install: Could not find '$Filename' in '$SourceFolder'. "
1212+
}
1213+
}
1214+
11761215
<#
11771216
.SYNOPSIS
11781217
Installs the version manager into your User profile directory
@@ -1191,28 +1230,12 @@ function dnvm-setup {
11911230

11921231
$ScriptFolder = Split-Path -Parent $ScriptPath
11931232

1194-
if(!(Test-Path $Destination)) {
1195-
New-Item -Type Directory $Destination | Out-Null
1196-
}
1197-
1198-
$ps1Command = Join-Path $ScriptFolder "$CommandName.ps1"
1199-
if(Test-Path $ps1Command) {
1200-
_WriteOut "Installing '$CommandName.ps1' to '$Destination' ..."
1201-
Copy-Item $ps1Command $Destination -Force
1202-
} else {
1203-
_WriteOut "WARNING: Could not find '$CommandName.ps1' in '$ScriptFolder'. Unable to install!"
1204-
}
1205-
$cmdCommand = Join-Path $ScriptFolder "$CommandName.cmd"
1206-
if(Test-Path $cmdCommand) {
1207-
_WriteOut "Installing '$CommandName.cmd' to '$Destination' ..."
1208-
Copy-Item $cmdCommand $Destination -Force
1209-
} else {
1210-
_WriteOut "WARNING: Could not find '$CommandName.cmd' in '$ScriptFolder'. Unable to install!"
1211-
}
1233+
# Copy script files (if necessary):
1234+
Safe-Filecopy "$CommandName.ps1" $ScriptFolder $Destination
1235+
Safe-Filecopy "$CommandName.cmd" $ScriptFolder $Destination
12121236

12131237
# Configure Environment Variables
12141238
# Also, clean old user home values if present
1215-
12161239
# We'll be removing any existing homes, both
12171240
$PathsToRemove = @(
12181241
"%USERPROFILE%\$DefaultUserDirectoryName",

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="beta4-10347"
5+
_DNVM_BUILDNUMBER="beta5-10350"
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)