diff --git a/KoreBuild-dotnet/build/KoreBuild.cmd b/KoreBuild-dotnet/build/KoreBuild.cmd index 1eed668ab9..6316ea21a9 100644 --- a/KoreBuild-dotnet/build/KoreBuild.cmd +++ b/KoreBuild-dotnet/build/KoreBuild.cmd @@ -13,6 +13,10 @@ IF "%KOREBUILD_DOTNET_CHANNEL%"=="" ( SET KOREBUILD_DOTNET_CHANNEL=beta ) +IF "%KOREBUILD_DOTNET_VERSION%"=="" ( + SET KOREBUILD_DOTNET_VERSION=1.0.0.001248 +) + IF NOT EXIST Sake ( "%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0 ) @@ -33,7 +37,7 @@ IF "%KOREBUILD_SKIP_RUNTIME_INSTALL%"=="1" ( SET DOTNET_LOCAL_INSTALL_FOLDER=%LOCALAPPDATA%\Microsoft\dotnet\cli SET DOTNET_LOCAL_INSTALL_FOLDER_BIN=%DOTNET_LOCAL_INSTALL_FOLDER%\bin -CALL %~dp0dotnet-install.cmd -Channel %KOREBUILD_DOTNET_CHANNEL% +CALL %~dp0dotnet-install.cmd -Channel %KOREBUILD_DOTNET_CHANNEL% -Version %KOREBUILD_DOTNET_VERSION% ECHO Adding %DOTNET_LOCAL_INSTALL_FOLDER_BIN% to PATH SET PATH=%DOTNET_LOCAL_INSTALL_FOLDER_BIN%;%PATH% diff --git a/KoreBuild-dotnet/build/KoreBuild.sh b/KoreBuild-dotnet/build/KoreBuild.sh index 8761b29f8e..9b6d0b1aaf 100755 --- a/KoreBuild-dotnet/build/KoreBuild.sh +++ b/KoreBuild-dotnet/build/KoreBuild.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash [ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=beta +[ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=1.0.0.001248 targets="" filename=$0 @@ -60,7 +61,7 @@ else export DOTNET_HOME=$DOTNET_INSTALL_DIR/share/dotnet/cli export KOREBUILD_FOLDER="$(dirname $thisDir)" chmod +x $thisDir/dotnet-install.sh - $thisDir/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL + $thisDir/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION # ==== Temporary ==== if ! type dnvm > /dev/null 2>&1; then source $thisDir/dnvm.sh diff --git a/KoreBuild-dotnet/build/dotnet-install.ps1 b/KoreBuild-dotnet/build/dotnet-install.ps1 index 79980ad8c5..218f06ba14 100644 --- a/KoreBuild-dotnet/build/dotnet-install.ps1 +++ b/KoreBuild-dotnet/build/dotnet-install.ps1 @@ -3,15 +3,21 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. # -param([string]$Channel="dev") - +param( + [string]$Channel="dev", + [string]$version="Latest" +) $ErrorActionPreference="Stop" $ProgressPreference="SilentlyContinue" +$fileVersion = $Version +if ($fileVersion -eq "Latest") { + $fileVersion = "latest" +} $Feed="https://dotnetcli.blob.core.windows.net/dotnet" -$DotNetFileName="dotnet-win-x64.latest.zip" -$DotNetUrl="$Feed/$Channel/Binaries/Latest" +$DotNetFileName="dotnet-win-x64.$fileVersion.zip" +$DotNetUrl="$Feed/$Channel/Binaries/$Version" function say($str) { @@ -34,21 +40,29 @@ if (Test-Path $LocalFile) $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 "$Version is already installed." exit 0 } } diff --git a/KoreBuild-dotnet/build/dotnet-install.sh b/KoreBuild-dotnet/build/dotnet-install.sh index 38ad35240d..f38bd0ce19 100755 --- a/KoreBuild-dotnet/build/dotnet-install.sh +++ b/KoreBuild-dotnet/build/dotnet-install.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env sh -# # 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. # @@ -162,10 +160,17 @@ install_dotnet() say_err "Ending install due to missing pre-reqs" return 1; fi + + if [ "$VERSION" == "Latest" ]; then + local fileVersion=latest + else + local fileVersion=$VERSION + fi + local os=$(current_os) local installLocation="$PREFIX/share/dotnet" - local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/$CHANNEL/Binaries/Latest" - local dotnet_filename="dotnet-$os-x64.latest.tar.gz" + local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/$CHANNEL/Binaries/$VERSION" + local dotnet_filename="dotnet-$os-x64.$fileVersion.tar.gz" if [ "$RELINK" = "0" ]; then if [ "$FORCE" = "0" ]; then @@ -288,5 +293,6 @@ elif [ -z "$PREFIX" ]; then fi [ -z "$CHANNEL" ] && CHANNEL="dev" +[ -z "$VERSION" ] && VERSION="Latest" install_dotnet