update dotnet-install script and use beta channel

This commit is contained in:
Andrew Stanton-Nurse 2016-02-04 10:26:48 -08:00
parent c0ed67e96f
commit 95be6b9a51
4 changed files with 83 additions and 77 deletions

View File

@ -9,6 +9,9 @@ IF "%NUGET_PATH%"=="" (
ECHO Error: NUGET_PATH is not set. ECHO Error: NUGET_PATH is not set.
EXIT /B 1 EXIT /B 1
) )
IF "%KOREBUILD_DOTNET_CHANNEL%"=="" (
SET KOREBUILD_DOTNET_CHANNEL=beta
)
IF NOT EXIST Sake ( IF NOT EXIST Sake (
"%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0 "%NUGET_PATH%" install Sake -ExcludeVersion -Source https://api.nuget.org/v3/index.json -o %~dp0
@ -30,7 +33,7 @@ IF "%KOREBUILD_SKIP_RUNTIME_INSTALL%"=="1" (
SET DOTNET_LOCAL_INSTALL_FOLDER=%LOCALAPPDATA%\Microsoft\dotnet\cli SET DOTNET_LOCAL_INSTALL_FOLDER=%LOCALAPPDATA%\Microsoft\dotnet\cli
SET DOTNET_LOCAL_INSTALL_FOLDER_BIN=%DOTNET_LOCAL_INSTALL_FOLDER%\bin SET DOTNET_LOCAL_INSTALL_FOLDER_BIN=%DOTNET_LOCAL_INSTALL_FOLDER%\bin
CALL %~dp0dotnet-install.cmd CALL %~dp0dotnet-install.cmd -Channel %KOREBUILD_DOTNET_CHANNEL%
ECHO Adding %DOTNET_LOCAL_INSTALL_FOLDER_BIN% to PATH ECHO Adding %DOTNET_LOCAL_INSTALL_FOLDER_BIN% to PATH
SET PATH=%DOTNET_LOCAL_INSTALL_FOLDER_BIN%;%PATH% SET PATH=%DOTNET_LOCAL_INSTALL_FOLDER_BIN%;%PATH%
@ -59,4 +62,4 @@ ECHO Using makefile: %MAKEFILE_PATH%
REM Don't use full paths. Sake doesn't support them! REM Don't use full paths. Sake doesn't support them!
"%~dp0Sake\tools\Sake.exe" -I %KOREBUILD_FOLDER%\build -f %MAKEFILE_PATH% %* "%~dp0Sake\tools\Sake.exe" -I %KOREBUILD_FOLDER%\build -f %MAKEFILE_PATH% %*

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=beta
targets="" targets=""
filename=$0 filename=$0
while [[ $# > 0 ]]; do while [[ $# > 0 ]]; do
@ -57,7 +60,7 @@ else
export DOTNET_HOME=$DOTNET_INSTALL_DIR/share/dotnet/cli export DOTNET_HOME=$DOTNET_INSTALL_DIR/share/dotnet/cli
export KOREBUILD_FOLDER="$(dirname $thisDir)" export KOREBUILD_FOLDER="$(dirname $thisDir)"
chmod +x $thisDir/dotnet-install.sh chmod +x $thisDir/dotnet-install.sh
$thisDir/dotnet-install.sh $thisDir/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL
# ==== Temporary ==== # ==== Temporary ====
if ! type dnvm > /dev/null 2>&1; then if ! type dnvm > /dev/null 2>&1; then
source $thisDir/dnvm.sh source $thisDir/dnvm.sh

View File

@ -3,38 +3,21 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information. # Licensed under the MIT license. See LICENSE file in the project root for full license information.
# #
param ( param([string]$Channel="dev")
[string] $InstallDir = $null,
[string] $TargetPlatform = "x64",
[string] $Version = "Latest"
)
$ErrorActionPreference="Stop" $ErrorActionPreference="Stop"
$ProgressPreference="SilentlyContinue" $ProgressPreference="SilentlyContinue"
$Feed="https://dotnetcli.blob.core.windows.net/dotnet" $Feed="https://dotnetcli.blob.core.windows.net/dotnet"
$Channel="dev" $DotNetFileName="dotnet-win-x64.latest.zip"
$fileVersion = $Version $DotNetUrl="$Feed/$Channel/Binaries/Latest"
if ($fileVersion -eq "Latest") {
$fileVersion = "latest"
}
$DotNetFileName="dotnet-win-${TargetPlatform}.$fileVersion.zip"
$DotNetUrl="$Feed/$Channel/Binaries/$Version"
Write-Host $DotNetFileName
function say($str) function say($str)
{ {
Write-Host "dotnet_install: $str" Write-Host "dotnet_install: $str"
} }
if (!$InstallDir) {
$InstallDir = "$env:LocalAppData\Microsoft\dotnet"
}
$InstallDir = $env:DOTNET_INSTALL_DIR $InstallDir = $env:DOTNET_INSTALL_DIR
if (!$InstallDir) { if (!$InstallDir) {
$InstallDir = "$env:LocalAppData\Microsoft\dotnet" $InstallDir = "$env:LocalAppData\Microsoft\dotnet"
@ -44,36 +27,28 @@ say "Preparing to install .NET Tools to $InstallDir"
# Check if we need to bother # Check if we need to bother
$LocalFile = "$InstallDir\cli\.version" $LocalFile = "$InstallDir\cli\.version"
if ((Test-Path $LocalFile)) if (Test-Path $LocalFile)
{ {
$LocalData = @(cat $LocalFile) $LocalData = @(cat $LocalFile)
$LocalHash = $LocalData[0].Trim() $LocalHash = $LocalData[0].Trim()
$LocalVersion = $LocalData[1].Trim() $LocalVersion = $LocalData[1].Trim()
if ($LocalVersion -and $LocalHash) if ($LocalVersion -and $LocalHash)
{ {
if ($Version -eq "Latest") $RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version"
{ $RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries));
$RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version" $RemoteHash = $RemoteData[0].Trim()
$RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); $RemoteVersion = $RemoteData[1].Trim()
$RemoteHash = $RemoteData[0].Trim()
$RemoteVersion = $RemoteData[1].Trim()
if (!$RemoteVersion -or !$RemoteHash) { if (!$RemoteVersion -or !$RemoteHash) {
throw "Invalid response from feed" 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 "Latest version: $RemoteVersion"
say "Local Version: $LocalVersion"
if($LocalHash -eq $RemoteHash)
{ {
say "You already have the local version" say "You already have the latest version"
exit 0 exit 0
} }
} }
@ -115,4 +90,4 @@ if (Test-Path "$InstallDir\$DotNetFileName") {
say "The .NET Tools have been installed to $InstallDir\cli!" say "The .NET Tools have been installed to $InstallDir\cli!"
# New layout # New layout
say "Add '$InstallDir\cli\bin' to your PATH to use dotnet" say "Add '$InstallDir\cli\bin' to your PATH to use dotnet"

View File

@ -54,13 +54,6 @@ exec "$MY_TARGET" "$@"
EOF EOF
) )
#set default prefix (PREFIX is a fairly standard env-var, but we also want to allow the use the specific "DOTNET_INSTALL_DIR" one)
if [ ! -z "$DOTNET_INSTALL_DIR" ]; then
PREFIX=$DOTNET_INSTALL_DIR
elif [ -z "$PREFIX" ]; then
PREFIX=/usr/local
fi
#setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. #setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
#See if stdout is a terminal #See if stdout is a terminal
if [ -t 1 ]; then if [ -t 1 ]; then
@ -156,7 +149,7 @@ install_dotnet()
return 1 return 1
fi fi
say "Preparing to install .NET Tools to $PREFIX" say "Preparing to install .NET Tools from '$CHANNEL' channel to '$PREFIX'"
if [ -e "$PREFIX/share/dotnet/cli/dotnet" ] && [ ! -w "$PREFIX/share/dotnet/cli/dotnet" ]; then if [ -e "$PREFIX/share/dotnet/cli/dotnet" ] && [ ! -w "$PREFIX/share/dotnet/cli/dotnet" ]; then
say_err "dotnet cli is already installed and not writeable. Use 'curl -sSL <url> | sudo sh' to force install." say_err "dotnet cli is already installed and not writeable. Use 'curl -sSL <url> | sudo sh' to force install."
@ -171,13 +164,13 @@ install_dotnet()
fi fi
local os=$(current_os) local os=$(current_os)
local installLocation="$PREFIX/share/dotnet" local installLocation="$PREFIX/share/dotnet"
local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/dev/Binaries/Latest" local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/$CHANNEL/Binaries/Latest"
local dotnet_filename="dotnet-$os-x64.latest.tar.gz" local dotnet_filename="dotnet-$os-x64.latest.tar.gz"
if [ "$RELINK" = "0" ]; then if [ "$RELINK" = "0" ]; then
if [ "$FORCE" = "0" ]; then if [ "$FORCE" = "0" ]; then
# Check if we need to bother # Check if we need to bother
local remoteData="$(curl -s https://dotnetcli.blob.core.windows.net/dotnet/dev/dnvm/latest.$os.version)" local remoteData="$(curl -s https://dotnetcli.blob.core.windows.net/dotnet/$CHANNEL/dnvm/latest.$os.version)"
[ $? != 0 ] && say_err "Unable to determine latest version." && return 1 [ $? != 0 ] && say_err "Unable to determine latest version." && return 1
local remoteVersion=$(IFS="\n" && echo $remoteData | tail -n 1) local remoteVersion=$(IFS="\n" && echo $remoteData | tail -n 1)
@ -241,27 +234,59 @@ FORCE=0
RELINK=0 RELINK=0
while [ $# -ne 0 ] while [ $# -ne 0 ]
do do
if [ $1 = "-f" ] || [ $1 = "--force" ]; then name=$1
FORCE=1 case $name in
elif [ $1 = "-r" ] || [ $1 = "--relink" ]; then -f|--force)
RELINK=1 FORCE=1
elif [ $1 = "-?" ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then ;;
echo ".NET Tools Installer" -r|--relink)
echo "" RELINK=1
echo "Usage:" ;;
echo " $0 [-f]" -c|--channel)
echo " $0 -r" shift
echo " $0 -h" CHANNEL=$1
echo "" ;;
echo "Options:" -d|--destination)
echo " -f Force reinstallation even if you have the most recent version installed" shift
echo " -r Don't re-download, just recreate the links in $PREFIX/bin" DOTNET_INSTALL_DIR=$1
echo " -h Show this help message" ;;
echo "" -?|-h|--help)
echo "The PREFIX environment variable can be used to affect the root installation directory" echo ".NET Tools Installer"
exit 0 echo ""
fi echo "Usage:"
echo " $0 [-f|--force] [-r|--relink] [-c|--channel <CHANNEL>] [-d|--destination <DESTINATION>]"
echo " $0 -h|-?|--help"
echo ""
echo "Options:"
echo " -f,--force Force reinstallation even if you have the most recent version installed"
echo " -r,--relink Don't re-download, just recreate the links in $PREFIX/bin"
echo " -c,--channel <CHANNEL> Download from the CHANNEL specified (default: dev)"
echo " -d,--destination <PATH> Install under the specified root (see Install Location below)"
echo " -?,-h,--help Show this help message"
echo ""
echo "Install Location:"
echo " By default, this script installs the .NET Tools to /usr/local. However, if the PREFIX environment variable"
echo " is specified, that will be used as the installation root. If the DOTNET_INSTALL_DIR environment variable"
echo " is specified, it will be used as the installation root (overriding PREFIX). Finally, if the '--destination'"
echo " option is specified, it will override all environment variables and be used as the installation location"
echo ""
echo " After installation, the .NET Tools will be installed to the 'share/dotnet/cli' subdirectory of the "
echo " installation location (i.e. /usr/local/share/dotnet/cli). Binaries will be symlinked to the 'bin'"
echo " subdirectory of the installation location (i.e. /usr/local/bin/dotnet)"
exit 0
;;
esac
shift shift
done done
install_dotnet #set default prefix (PREFIX is a fairly standard env-var, but we also want to allow the use the specific "DOTNET_INSTALL_DIR" one)
if [ ! -z "$DOTNET_INSTALL_DIR" ]; then
PREFIX=$DOTNET_INSTALL_DIR
elif [ -z "$PREFIX" ]; then
PREFIX=/usr/local
fi
[ -z "$CHANNEL" ] && CHANNEL="dev"
install_dotnet