Correct usages of Write-Output with Write-Host

This commit is contained in:
Nate McMaster 2017-06-21 16:20:51 -07:00
parent 3471d43796
commit 38f8f5b548
3 changed files with 19 additions and 19 deletions

View file

@ -10,12 +10,12 @@ try {
throw "You need to have a version of 'dotnet' on your path so we can determine the RID" throw "You need to have a version of 'dotnet' on your path so we can determine the RID"
} }
$rid = dotnet --version | where { $_ -match "^ Runtime Id:\s*(.*)$" } | foreach { $matches[1] } $rid = dotnet --version | where { $_ -match "^ Runtime Id:\s*(.*)$" } | foreach { $matches[1] }
$stage2 = "$PSScriptRoot\..\artifacts\$rid\stage2\bin" $stage2 = "$PSScriptRoot\..\artifacts\$rid\stage2\bin"
if (Test-Path $stage2) { if (Test-Path $stage2) {
$env:PATH="$stage2;$env:PATH" $env:PATH="$stage2;$env:PATH"
} else { } else {
Write-Output "You don't have a dev build in the 'artifacts\$rid\stage2' folder!" Write-Host "You don't have a dev build in the 'artifacts\$rid\stage2' folder!"
} }
dotnet @args dotnet @args

View file

@ -85,7 +85,7 @@ $VersionRegEx="/\d+\.\d+[^/]+/"
$OverrideNonVersionedFiles=$true $OverrideNonVersionedFiles=$true
function Say($str) { function Say($str) {
Write-Output "dotnet-install: $str" Write-Host "dotnet-install: $str"
} }
function Say-Verbose($str) { function Say-Verbose($str) {
@ -182,7 +182,7 @@ function GetHTTPResponse([Uri] $Uri)
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials} $HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
} }
else { else {
$HttpClient = New-Object System.Net.Http.HttpClient $HttpClient = New-Object System.Net.Http.HttpClient
} }
@ -208,7 +208,7 @@ function GetHTTPResponse([Uri] $Uri)
$HttpClient.Dispose() $HttpClient.Dispose()
} }
} }
}) })
} }
@ -227,7 +227,7 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
$VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version" $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version"
} }
} }
$Response = GetHTTPResponse -Uri $VersionFileUrl $Response = GetHTTPResponse -Uri $VersionFileUrl
$StringContent = $Response.Content.ReadAsStringAsync().Result $StringContent = $Response.Content.ReadAsStringAsync().Result
@ -262,7 +262,7 @@ function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel,
function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
if ($SharedRuntime) { if ($SharedRuntime) {
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip" $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip"
} }
@ -277,7 +277,7 @@ function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$Specif
function Get-LegacyDownload-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { function Get-LegacyDownload-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
if ($SharedRuntime) { if ($SharedRuntime) {
$PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip" $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip"
} }
@ -314,7 +314,7 @@ function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$Relat
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile $VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
Say-Verbose "Local version file: $VersionFile" Say-Verbose "Local version file: $VersionFile"
if (Test-Path $VersionFile) { if (Test-Path $VersionFile) {
$VersionText = cat $VersionFile $VersionText = cat $VersionFile
Say-Verbose "Local version file text: $VersionText" Say-Verbose "Local version file text: $VersionText"
@ -328,7 +328,7 @@ function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$Relat
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) { function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
$DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion $DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion
Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath" Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath"
return Test-Path $DotnetPackagePath -PathType Container return Test-Path $DotnetPackagePath -PathType Container
@ -346,13 +346,13 @@ function Get-Path-Prefix-With-Version($path) {
if ($match.Success) { if ($match.Success) {
return $entry.FullName.Substring(0, $match.Index + $match.Length) return $entry.FullName.Substring(0, $match.Index + $match.Length)
} }
return $null return $null
} }
function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) { function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
$ret = @() $ret = @()
foreach ($entry in $Zip.Entries) { foreach ($entry in $Zip.Entries) {
$dir = Get-Path-Prefix-With-Version $entry.FullName $dir = Get-Path-Prefix-With-Version $entry.FullName
@ -363,12 +363,12 @@ function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([Sys
} }
} }
} }
$ret = $ret | Sort-Object | Get-Unique $ret = $ret | Sort-Object | Get-Unique
$values = ($ret | foreach { "$_" }) -join ";" $values = ($ret | foreach { "$_" }) -join ";"
Say-Verbose "Directories to unpack: $values" Say-Verbose "Directories to unpack: $values"
return $ret return $ret
} }
@ -392,9 +392,9 @@ function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) {
Set-Variable -Name Zip Set-Variable -Name Zip
try { try {
$Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) $Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath)
$DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath $DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath
foreach ($entry in $Zip.Entries) { foreach ($entry in $Zip.Entries) {
$PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName $PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName
if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) { if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) {
@ -470,7 +470,7 @@ if ($IsSdkInstalled) {
New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null
$installDrive = $((Get-Item $InstallRoot).PSDrive.Name); $installDrive = $((Get-Item $InstallRoot).PSDrive.Name);
Write-Output "${installDrive}:"; Write-Host "${installDrive}:";
$free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "${installDrive}:" $free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "${installDrive}:"
if ($free.Freespace / 1MB -le 100 ) { if ($free.Freespace / 1MB -le 100 ) {
Say "There is not enough disk space on drive ${installDrive}:" Say "There is not enough disk space on drive ${installDrive}:"

View file

@ -12,5 +12,5 @@ if (Test-Path $stage2) {
$env:PATH="$stage2;$env:PATH" $env:PATH="$stage2;$env:PATH"
} }
} else { } else {
Write-Output "You don't have a dev build in the 'artifacts\win10-x64\stage2' folder!" Write-Host "You don't have a dev build in the 'artifacts\win10-x64\stage2' folder!"
} }