Address feedback to install.ps1

This commit is contained in:
Krzysztof Wicher 2016-03-02 14:03:17 -08:00
parent 8e3992660d
commit 4d165d78db

View file

@ -3,22 +3,59 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
<#
.SYNOPSIS
Installs dotnet cli
.DESCRIPTION
Installs dotnet cli. If dotnet installation already exists in the given directory
it will update it only if the requested version differs from the one already installed.
.PARAMETER Channel
Channel is the way of reasoning about stability and quality of dotnet. This parameter takes one of the values:
- nightly - Possibly unstable, frequently changing
- preview - Pre-release stable with known issues and feature gaps
- production - Most stable releases
.PARAMETER Version
Represents a build version on specific channel. Possible values:
- 4-part version in a format A.B.C.D - represents specific version of build
- latest - most latest build on specific channel
- lkg - last known good version on specific channel
.PARAMETER InstallDir
Path to where to install dotnet. Note that binaries will be placed directly in a given directory.
Defaults to %LocalAppData%\Microsoft\.dotnet
.PARAMETER Architecture
Architecture of dotnet binaries to be installed. Defaults to the OS architecture.
Possible values are: AMD64 and x86
.PARAMETER DebugSymbols
If set the installer will include symbols in the installation.
.PARAMETER DryRun
If set it will not perform installation but instead display what command line to use to consistently install
currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link
with specific version so that this command can be used deterministicly in a build script.
It also displays binaries location if you prefer to install or download it yourself.
.PARAMETER NoPath
By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder.
If set it will display binaries location but not set any environment variable.
.PARAMETER Verbose
Displays diagnostics information.
.PARAMETER AzureFeed
This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer.
#>
[cmdletbinding()]
param(
[string]$Channel="nightly",
[string]$Version="Latest",
[string]$InstallDir="<usershare>",
[string]$Architecture="auto",
[switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet.
[switch]$DryRun,
[bool]$DebugSymbols=$false, # TODO: There is no zip uploaded yet
[bool]$NoPath=$false
[switch]$NoPath,
[string]$AzureFeed="https://dotnetcli.blob.core.windows.net/dotnet"
)
Set-StrictMode -Version Latest
$ErrorActionPreference="Stop"
$ProgressPreference="SilentlyContinue"
$AzureFeed="https://dotnetcli.blob.core.windows.net/dotnet"
$LocalVersionFileRelativePath="\.version"
$BinFolderRelativePath="\bin"
@ -49,7 +86,7 @@ function Get-CLIArchitecture-From-Architecture([string]$Architecture) {
switch ($Architecture.ToLower()) {
{ $_ -eq "auto" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) }
{ ($_ -eq "amd64") -Or ($_ -eq "x64") } { return "x64" }
{ ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" }
{ $_ -eq "x86" } { return "x86" }
default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" }
}
@ -82,9 +119,10 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$AzureChannel, [str
function Get-Azure-Channel-From-Channel([string]$Channel) {
Say-Invocation $MyInvocation
# For compatibility with build scripts accept also directly Azure channels names
switch ($Channel.ToLower()) {
{ $_ -eq "nightly" } { return "dev" }
{ $_ -eq "preview" } { return "beta" }
{ ($_ -eq "nightly") -or ($_ -eq "dev") } { return "dev" }
{ ($_ -eq "preview") -or ($_ -eq "beta") } { return "beta" }
{ $_ -eq "production" } { throw "Production channel does not exist yet" }
default { throw "``$Channel`` is an invalid channel name. Use one of the following: ``nightly``, ``preview``, ``production``" }
}
@ -134,7 +172,7 @@ function Resolve-Installation-Path([string]$InstallDir) {
function Get-Installed-Version-Info([string]$InstallRoot) {
Say-Invocation $MyInvocation
$VersionFile = $InstallRoot + $LocalVersionFileRelativePath
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $LocalVersionFileRelativePath
Say-Verbose "Local version file: $VersionFile"
if (Test-Path $VersionFile) {
@ -212,10 +250,13 @@ Extract-And-Override-Zip -ZipPath $ZipPath -OutPath $InstallRoot
Say "Removing installation artifacts"
Remove-Item $ZipPath
$BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath)
if (-Not $NoPath) {
$BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath)
Say "Adding to PATH: `"$BinPath`""
Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process."
$env:path += ";$BinPath"
}
else {
Say "Binaries of dotnet can be found in $BinPath"
}
Say "Installation finished"