|
1 | 1 | param (
|
2 | 2 | [string] $NuGetDownloadUrl = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe',
|
3 |
| - [string] $NuGetPath = "$PSScriptRoot/../tools/nuget.exe" |
| 3 | + [string] $NuGetPath = "$PSScriptRoot/../tools/nuget.exe", |
| 4 | + [switch] $ForBuild, |
| 5 | + [switch] $ForTests |
4 | 6 | )
|
5 | 7 |
|
6 | 8 | $ErrorActionPreference = 'Stop'
|
7 | 9 | Set-StrictMode -Version Latest
|
8 | 10 |
|
9 |
| -try { |
10 |
| - # The following command requires installing tzdata which is interactive, so let's forbid its interactivity. |
11 |
| - $oldDebianFrontend = $env:DEBIAN_FRONTEND |
12 |
| - $env:DEBIAN_FRONTEND = 'noninteractive' |
| 11 | +if ($ForBuild) { |
| 12 | + try { |
| 13 | + # The following command requires installing tzdata which is interactive, so let's forbid its interactivity. |
| 14 | + $oldDebianFrontend = $env:DEBIAN_FRONTEND |
| 15 | + $env:DEBIAN_FRONTEND = 'noninteractive' |
| 16 | + $dependencies = @( |
| 17 | + 'cmake' |
| 18 | + 'g++' |
| 19 | + 'git' |
| 20 | + 'gperf' |
| 21 | + 'gperf' |
| 22 | + 'libssl-dev' |
| 23 | + 'make' |
| 24 | + 'php-cli' |
| 25 | + 'zlib1g-dev' |
| 26 | + ) |
| 27 | + |
| 28 | + Write-Output 'Installing dependencies.' |
| 29 | + apt-get install -y @dependencies |
| 30 | + if (!$?) { |
| 31 | + throw 'Cannot install dependencies from apt-get' |
| 32 | + } |
| 33 | + } finally { |
| 34 | + $env:DEBIAN_FRONTEND = $oldDebianFrontend |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +if ($ForTests) { |
13 | 39 | $dependencies = @(
|
14 |
| - 'cmake' |
15 |
| - 'gperf' |
16 |
| - 'make' |
17 |
| - 'git' |
18 |
| - 'zlib1g-dev' |
19 |
| - 'libssl-dev' |
20 |
| - 'gperf' |
21 |
| - 'php-cli' |
22 |
| - 'cmake' |
23 |
| - 'g++' |
| 40 | + 'ca-certificates' |
| 41 | + 'gnupg' |
24 | 42 | )
|
25 | 43 |
|
26 | 44 | Write-Output 'Installing dependencies.'
|
27 | 45 | apt-get install -y @dependencies
|
28 | 46 | if (!$?) {
|
29 | 47 | throw 'Cannot install dependencies from apt-get'
|
30 | 48 | }
|
31 |
| -} finally { |
32 |
| - $env:DEBIAN_FRONTEND = $oldDebianFrontend |
33 |
| -} |
34 | 49 |
|
35 |
| -Write-Output "Downloading NuGet client to $NuGetPath" |
36 |
| -New-Item -Type Directory ([IO.Path]::GetDirectoryName($NuGetPath)) |
37 |
| -Invoke-WebRequest -OutFile $NuGetPath $NuGetDownloadUrl |
| 50 | + Write-Output 'Installing Mono.' |
| 51 | + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
| 52 | + if (!$?) { |
| 53 | + throw 'Cannot execute apt-key adv.' |
| 54 | + } |
| 55 | + |
| 56 | + echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list |
| 57 | + if (!$?) { |
| 58 | + throw 'Cannot add a package source.' |
| 59 | + } |
| 60 | + |
| 61 | + apt-get update && apt-get install -y mono-devel |
| 62 | + if (!$?) { |
| 63 | + throw 'Cannot execute apt-get update.' |
| 64 | + } |
| 65 | + |
| 66 | + Write-Output "Downloading NuGet client to $NuGetPath" |
| 67 | + New-Item -Type Directory ([IO.Path]::GetDirectoryName($NuGetPath)) |
| 68 | + Invoke-WebRequest -OutFile $NuGetPath $NuGetDownloadUrl |
| 69 | +} |
0 commit comments