diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..edc70335220 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,6 @@ +version: 1.0.{build} +install: +- ps: fcs/installSDK.ps1 +build_script: +- cmd: fcs/build.cmd +test: off diff --git a/fcs/installSDK.ps1 b/fcs/installSDK.ps1 new file mode 100644 index 00000000000..288fd8c8dd1 --- /dev/null +++ b/fcs/installSDK.ps1 @@ -0,0 +1,27 @@ +# Ensures that .net core is up to date. +# first get the required version from global.json +$json = ConvertFrom-Json (Get-Content "$PSScriptRoot/global.json" -Raw) +$required_version = $json.sdk.version + +# Running dotnet --version stupidly fails if the required SDK version is higher +# than the currently installed version. So move global.json out the way +# and then put it back again +Rename-Item "$PSScriptRoot/global.json" "$PSScriptRoot/global.json.bak" +$current_version = (dotnet --version) +Rename-Item "$PSScriptRoot/global.json.bak" "$PSScriptRoot/global.json" +Write-Host "Required .NET version: $required_version, Installed: $current_version" + +if ($current_version -lt $required_version) { + # Current installed version is too low. + # Install new version as a local only dependency. + $urlCurrent = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$required_version/dotnet-sdk-$required_version-win-x64.zip" + Write-Host "Installing .NET Core $required_version from $urlCurrent" + $env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnetsdk" + New-Item -Type Directory $env:DOTNET_INSTALL_DIR -Force | Out-Null + (New-Object System.Net.WebClient).DownloadFile($urlCurrent, "dotnet.zip") + Write-Host "Unzipping to $env:DOTNET_INSTALL_DIR" + Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory("dotnet.zip", $env:DOTNET_INSTALL_DIR) + + Write-Host "Using .NET SDK from $env:DOTNET_INSTALL_DIR" + $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" +}