Skip to content

Commit dae3f14

Browse files
authored
Cache nuget packages and dotnet tools in AppVeyor (#777)
1 parent 1d8dd4a commit dae3f14

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

PSReadLine.build.ps1

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ else
3030
}
3131
Write-Verbose "Building for '$target'" -Verbose
3232

33+
$CLI_VERSION = "2.1.300"
34+
3335
<#
3436
Synopsis: Ensure dotnet is installed
3537
#>
@@ -49,9 +51,22 @@ task CheckDotnetInstalled `
4951
break
5052
}
5153
}
54+
5255
if (!$foundDotnet)
5356
{
54-
throw "Could not find 'dotnet' command. Install DotNetCore SDK and ensure it is in the path."
57+
if ($env:APPVEYOR)
58+
{
59+
# Install dotnet to the default location, it will be cached via appveyor.yml
60+
$installScriptUri = "https://raw.githubusercontent.com/dotnet/cli/release/2.1/scripts/obtain/dotnet-install.ps1"
61+
$installDir = "${env:LOCALAPPDATA}\Microsoft\dotnet"
62+
Invoke-WebRequest -Uri $installScriptUri -OutFile "${env:TEMP}/dotnet-install.ps1"
63+
& "$env:TEMP/dotnet-install.ps1" -Version $CLI_VERSION -InstallDir $installDir
64+
$script:dotnet = Join-Path $installDir "dotnet.exe"
65+
}
66+
else
67+
{
68+
throw "Could not find 'dotnet' command. Install DotNetCore SDK and ensure it is in the path."
69+
}
5570
}
5671
}
5772
}
@@ -198,8 +213,8 @@ task RunTests BuildMainModule, {
198213
Pop-Location
199214
}
200215

201-
Remove-Item env:PSREADLINE_TESTRUN
202-
}
216+
Remove-Item env:PSREADLINE_TESTRUN
217+
}
203218

204219
<#
205220
Synopsis: Copy all of the files that belong in the module to one place in the layout for installation

appveyor.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
image: Visual Studio 2017
33

4-
install:
5-
- ps: |
6-
$env:DOTNET_INSTALL_DIR = "$pwd\.dotnet"
7-
$env:CLI_VERSION = "2.1.300"
8-
mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null
9-
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dotnet/cli/release/2.1/scripts/obtain/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1"
10-
'& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version $env:CLI_VERSION -InstallDir $env:DOTNET_INSTALL_DIR'
11-
$env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
4+
environment:
5+
POWERSHELL_TELEMETRY_OPTOUT: 1
6+
# Avoid expensive initialization of dotnet cli, see: http://donovanbrown.com/post/Stop-wasting-time-during-NET-Core-builds
7+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
8+
9+
cache:
10+
- '%HOMEDRIVE%%HOMEPATH%\.nuget\packages -> PSReadLine.build.ps1'
11+
- '%LocalAppData%\Microsoft\dotnet -> PSReadLine.build.ps1'
1212

1313
before_build:
1414
- ps: |

0 commit comments

Comments
 (0)