diff options
author | Senthil <schellap@microsoft.com> | 2015-11-18 03:40:18 +0300 |
---|---|---|
committer | Senthil <schellap@microsoft.com> | 2015-12-02 05:34:21 +0300 |
commit | a8199d3bfeb14dd44e45bbd598eef75cf6e5ef70 (patch) | |
tree | 2cd661422184b4e74c55f5bab0b3cb15ae6f6bb7 /src/scripts | |
parent | 9dacc6dd120e6579ae84c9fd41cae48ddc63035f (diff) |
Switch to dotnet tools and add unix testing
- Fix few issues and produce xunit format
- Set HOME if undefined and DOTNET_HOME
- Enable CPP and JIT for all platforms except OSX
o CLI has no support for RyuJIT.
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/install-cli.ps1 | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/scripts/install-cli.ps1 b/src/scripts/install-cli.ps1 new file mode 100644 index 000000000..76ee087fb --- /dev/null +++ b/src/scripts/install-cli.ps1 @@ -0,0 +1,98 @@ +# +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +param ( + [string] $InstallDir = $null, + [string] $TargetPlatform = "x64" +) + +# The below code is from dotnet/cli install.ps1 + +$ErrorActionPreference="Stop" +$ProgressPreference="SilentlyContinue" + +$Feed="https://dotnetcli.blob.core.windows.net/dotnet" +$Channel="dev" +$DotNetFileName="dotnet-win-" + $TargetPlatform + ".latest.zip" +$DotNetUrl="$Feed/$Channel/Binaries/Latest" + +function say($str) +{ + Write-Host "dotnet_install: $str" +} + +if (!$InstallDir) { + $InstallDir = "$env:LocalAppData\Microsoft\dotnet" +} + +say "Preparing to install .NET Tools to $InstallDir" + +# Check if we need to bother +$LocalFile = "$InstallDir\cli\.version" +if (Test-Path $LocalFile) +{ + $LocalData = @(cat $LocalFile) + $LocalHash = $LocalData[0].Trim() + $LocalVersion = $LocalData[1].Trim() + if ($LocalVersion -and $LocalHash) + { + $RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version" + $RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split()); + $RemoteHash = $RemoteData[0].Trim() + $RemoteVersion = $RemoteData[1].Trim() + + if (!$RemoteVersion -or !$RemoteHash) { + throw "Invalid response from feed" + } + + say "Latest version: $RemoteVersion" + say "Local Version: $LocalVersion" + + if($LocalHash -eq $RemoteHash) + { + say "You already have the latest version" + exit 0 + } + } +} + +# Set up the install location +if (!(Test-Path $InstallDir)) { + mkdir $InstallDir | Out-Null +} + +# De-powershell the path before passing to .NET APIs +$InstallDir = Convert-Path $InstallDir + +say "Downloading $DotNetFileName from $DotNetUrl" +$resp = Invoke-WebRequest -UseBasicParsing "$DotNetUrl/$DotNetFileName" -OutFile "$InstallDir\$DotNetFileName" + +say "Extracting zip" + +# Create the destination +if (Test-Path "$InstallDir\cli_new") { + del -rec -for "$InstallDir\cli_new" +} +mkdir "$InstallDir\cli_new" | Out-Null + +Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null +[System.IO.Compression.ZipFile]::ExtractToDirectory("$InstallDir\$DotNetFileName", "$InstallDir\cli_new") + +# Replace the old installation (if any) +if (Test-Path "$InstallDir\cli") { + del -rec -for "$InstallDir\cli" +} +mv "$InstallDir\cli_new" "$InstallDir\cli" + +# Clean the zip +if (Test-Path "$InstallDir\$DotNetFileName") { + del -for "$InstallDir\$DotNetFileName" +} + +say "The .NET Tools have been installed to $InstallDir\cli!" + +# New layout +say "Add '$InstallDir\cli\bin' to your PATH to use dotnet" + |