[2020-02] Bump msbuild to track mono-2019-12 (#19661)
[mono-project.git] / eng / common / dotnet-install.sh
blob50bc5e475c78f01b67b7765f7535232e0a6d806d
1 #!/usr/bin/env bash
3 source="${BASH_SOURCE[0]}"
4 # resolve $source until the file is no longer a symlink
5 while [[ -h "$source" ]]; do
6 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
7 source="$(readlink "$source")"
8 # if $source was a relative symlink, we need to resolve it relative to the path where the
9 # symlink file was located
10 [[ $source != /* ]] && source="$scriptroot/$source"
11 done
12 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
14 . "$scriptroot/tools.sh"
16 version='Latest'
17 architecture=''
18 runtime='dotnet'
19 runtimeSourceFeed=''
20 runtimeSourceFeedKey=''
21 while [[ $# > 0 ]]; do
22 opt="$(echo "$1" | awk '{print tolower($0)}')"
23 case "$opt" in
24 -version|-v)
25 shift
26 version="$1"
28 -architecture|-a)
29 shift
30 architecture="$1"
32 -runtime|-r)
33 shift
34 runtime="$1"
36 -runtimesourcefeed)
37 shift
38 runtimeSourceFeed="$1"
40 -runtimesourcefeedkey)
41 shift
42 runtimeSourceFeedKey="$1"
45 Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1"
46 exit 1
48 esac
49 shift
50 done
52 # Use uname to determine what the CPU is.
53 cpuname=$(uname -p)
54 # Some Linux platforms report unknown for platform, but the arch for machine.
55 if [[ "$cpuname" == "unknown" ]]; then
56 cpuname=$(uname -m)
59 case $cpuname in
60 aarch64)
61 buildarch=arm64
63 amd64|x86_64)
64 buildarch=x64
66 armv7l)
67 buildarch=arm
69 i686)
70 buildarch=x86
73 echo "Unknown CPU $cpuname detected, treating it as x64"
74 buildarch=x64
76 esac
78 dotnetRoot="$repo_root/.dotnet"
79 if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then
80 dotnetRoot="$dotnetRoot/$architecture"
83 InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || {
84 local exit_code=$?
85 Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
86 ExitWithExitCode $exit_code
89 ExitWithExitCode 0