Use a fixed version of CLI

This commit is contained in:
Pranav K 2016-01-20 10:35:39 -08:00
parent 10964cc04f
commit 786530fcb3
2 changed files with 45 additions and 18 deletions

View File

@ -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%

View File

@ -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
}
}