Avoid redownloading the shared runtime when it's already installed. (#121)

Fixes #119
This commit is contained in:
Pranav K 2016-09-30 17:25:02 -07:00 коммит произвёл GitHub
Родитель 61ceb20eaf
Коммит a2ca41c39a
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -35,8 +35,12 @@ if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL)
$dotnetSharedRuntimeChannel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL $dotnetSharedRuntimeChannel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL
} }
$dotnetLocalInstallFolder = $env:DOTNET_INSTALL_DIR
if (!$dotnetLocalInstallFolder)
{
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
}
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
$newPath = "$dotnetLocalInstallFolder;$env:PATH" $newPath = "$dotnetLocalInstallFolder;$env:PATH"
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1") if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
{ {
@ -47,7 +51,12 @@ if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
else else
{ {
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64 & "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64
# Avoid redownloading the CLI if it's already installed.
$sharedRuntimePath = [IO.Path]::Combine($dotnetLocalInstallFolder, 'shared', 'Microsoft.NETCore.App', $dotnetSharedRuntimeVersion)
if (!(Test-Path $sharedRuntimePath))
{
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetSharedRuntimeChannel -SharedRuntime -Version $dotnetSharedRuntimeVersion -Architecture x64 & "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetSharedRuntimeChannel -SharedRuntime -Version $dotnetSharedRuntimeVersion -Architecture x64
}
} }
if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder)) if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
{ {

Просмотреть файл

@ -52,12 +52,16 @@ if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then
else else
# Need to set this variable because by default the install script # Need to set this variable because by default the install script
# requires sudo # requires sudo
export DOTNET_INSTALL_DIR=~/.dotnet [ -z "$DOTNET_INSTALL_DIR" ] && DOTNET_INSTALL_DIR=~/.dotnet
export DOTNET_INSTALL_DIR=$DOTNET_INSTALL_DIR
export KOREBUILD_FOLDER="$(dirname $koreBuildFolder)" export KOREBUILD_FOLDER="$(dirname $koreBuildFolder)"
chmod +x $koreBuildFolder/dotnet/dotnet-install.sh chmod +x $koreBuildFolder/dotnet/dotnet-install.sh
$koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION $koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
sharedRuntimePath="$DOTNET_INSTALL_DIR/shared/Microsoft.NETCore.App/$KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION"
if [ -d "$sharedRuntimePath" ]; then
$koreBuildFolder/dotnet/dotnet-install.sh --shared-runtime --channel $KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL --version $KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION $koreBuildFolder/dotnet/dotnet-install.sh --shared-runtime --channel $KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL --version $KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION
fi
# Add .NET installation directory to the path if it isn't yet included. # Add .NET installation directory to the path if it isn't yet included.
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH" [[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH"