From 786530fcb3bc2b6869487e4ba620e329258229cc Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 20 Jan 2016 10:35:39 -0800 Subject: [PATCH] Use a fixed version of CLI --- KoreBuild-dotnet/build/KoreBuild.cmd | 2 +- KoreBuild-dotnet/build/dotnet-install.ps1 | 61 ++++++++++++++++------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/KoreBuild-dotnet/build/KoreBuild.cmd b/KoreBuild-dotnet/build/KoreBuild.cmd index 9b97dc3660..3b91726b08 100644 --- a/KoreBuild-dotnet/build/KoreBuild.cmd +++ b/KoreBuild-dotnet/build/KoreBuild.cmd @@ -25,7 +25,7 @@ IF NOT EXIST xunit.core ( SET DOTNET_LOCAL_INSTALL_FOLDER=%LOCALAPPDATA%\Microsoft\dotnet\cli SET DOTNET_LOCAL_INSTALL_FOLDER_BIN=%DOTNET_LOCAL_INSTALL_FOLDER%\bin -CALL %~dp0dotnet-install.cmd +CALL %~dp0dotnet-install.cmd -version "1.0.0.000973" ECHO Adding %DOTNET_LOCAL_INSTALL_FOLDER_BIN% to PATH SET PATH=%DOTNET_LOCAL_INSTALL_FOLDER_BIN%;%PATH% ECHO Setting DOTNET_HOME to %DOTNET_LOCAL_INSTALL_FOLDER% diff --git a/KoreBuild-dotnet/build/dotnet-install.ps1 b/KoreBuild-dotnet/build/dotnet-install.ps1 index a30d4ed02e..76dd9513e9 100644 --- a/KoreBuild-dotnet/build/dotnet-install.ps1 +++ b/KoreBuild-dotnet/build/dotnet-install.ps1 @@ -3,19 +3,38 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. # +param ( + [string] $InstallDir = $null, + [string] $TargetPlatform = "x64", + [string] $Version = "Latest" +) + $ErrorActionPreference="Stop" $ProgressPreference="SilentlyContinue" $Feed="https://dotnetcli.blob.core.windows.net/dotnet" $Channel="dev" -$DotNetFileName="dotnet-win-x64.latest.zip" -$DotNetUrl="$Feed/$Channel/Binaries/Latest" +$fileVersion = $Version +if ($fileVersion -eq "Latest") { + $fileVersion = "latest" +} + +$DotNetFileName="dotnet-win-${TargetPlatform}.$fileVersion.zip" +$DotNetUrl="$Feed/$Channel/Binaries/$Version" + + +Write-Host $DotNetFileName function say($str) { Write-Host "dotnet_install: $str" } + +if (!$InstallDir) { + $InstallDir = "$env:LocalAppData\Microsoft\dotnet" +} + $InstallDir = $env:DOTNET_INSTALL_DIR if (!$InstallDir) { $InstallDir = "$env:LocalAppData\Microsoft\dotnet" @@ -25,28 +44,36 @@ say "Preparing to install .NET Tools to $InstallDir" # Check if we need to bother $LocalFile = "$InstallDir\cli\.version" -if (Test-Path $LocalFile) +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([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); - $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) + if ($Version -eq "Latest") { - say "You already have the latest version" + $RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version" + $RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); + $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 + } + } + elseif ($LocalVersion -eq $Version) + { + say "You already have the local version" exit 0 } }