forked from dotnet/source-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·139 lines (125 loc) · 6.11 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
usage() {
echo "usage: $0 [options]"
echo "options:"
echo " -test run supported individal repo unit tests"
echo " --run-smoke-test run smoke tests"
echo " --publish-prebuilt-report publish prebuilt report data to Azure Storage"
echo " --generate-prebuilt-data generate prebuilt burndown data"
echo " --with-sdk <dir> use the SDK in the specified directory for bootstrapping"
echo "extra arguments will be passed to MSBuild"
echo ""
}
# resolve $SOURCE until the file is no longer a symlink
source="${BASH_SOURCE[0]}"
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
if [ -z "${HOME:-}" ]; then
export HOME="$scriptroot/.home"
mkdir "$HOME"
fi
# If .git doesn't exist at the repo root, create it. It's required for the build to work. The very
# prominent source tar.gz and zip files created by GitHub don't include it, so it's worth having a
# fallback here. See https://github.com/dotnet/source-build/issues/1646 for details.
if [ ! -e "$scriptroot/.git" ]; then
(
cd "$scriptroot"
git init
)
fi
if grep -q '\(/docker/\|/docker-\)' "/proc/1/cgroup"; then
export DotNetRunningInDocker=1
fi
alternateTarget=false
CUSTOM_SDK_DIR=''
for arg do
shift
opt="$(echo "$arg" | awk '{print tolower($0)}')"
case $opt in
(-test) set -- "$@" "/t:RunTests"
alternateTarget=true
;;
(--run-smoke-test) set -- "$@" "/t:RunSmokeTest"
alternateTarget=true
;;
(--publish-prebuilt-report) set -- "$@" "/t:PublishPrebuiltReportData"
alternateTarget=true
;;
(--generate-prebuilt-data) set -- "$@" "/t:GeneratePrebuiltBurndownData"
alternateTarget=true
;;
(--with-sdk)
CUSTOM_SDK_DIR="$(cd -P "$1" && pwd)"
if [ ! -d "$CUSTOM_SDK_DIR" ]; then
echo "Custom SDK directory '$CUSTOM_SDK_DIR' does not exist"
exit 1
fi
if [ ! -x "$CUSTOM_SDK_DIR/dotnet" ]; then
echo "Custom SDK '$CUSTOM_SDK_DIR/dotnet' does not exist or is not executable"
exit 1
fi
shift
;;
(*) set -- "$@" "$arg" ;;
esac
done
arcadeLine=`grep -m 1 'Microsoft\.DotNet\.Arcade\.Sdk' "$scriptroot/global.json"`
sdkLine=`grep -m 1 'dotnet' "$scriptroot/global.json"`
arcadePattern="\"Microsoft\.DotNet\.Arcade\.Sdk\" *: *\"(.*)\""
sdkPattern="\"dotnet\" *: *\"(.*)\""
if [[ $arcadeLine =~ $arcadePattern ]]; then
export ARCADE_BOOTSTRAP_VERSION=${BASH_REMATCH[1]}
fi
if [ -d "$CUSTOM_SDK_DIR" ]; then
export SDK_VERSION=`"$CUSTOM_SDK_DIR/dotnet" --version`
echo "Using custom bootstrap SDK from '$CUSTOM_SDK_DIR', version $SDK_VERSION"
CLIPATH="$CUSTOM_SDK_DIR"
SDKPATH="$CLIPATH/sdk/$SDK_VERSION"
export _InitializeDotNetCli="$CLIPATH"
export CustomDotNetSdkDir="$CLIPATH"
else
if [[ $sdkLine =~ $sdkPattern ]]; then
export SDK_VERSION=${BASH_REMATCH[1]}
CLIPATH="$scriptroot/.dotnet"
SDKPATH="$CLIPATH/sdk/$SDK_VERSION"
fi
fi
echo "Found bootstrap SDK $SDK_VERSION, bootstrap Arcade $ARCADE_BOOTSTRAP_VERSION"
if [ "$alternateTarget" == "false" ] && [[ "${SOURCE_BUILD_SKIP_SUBMODULE_CHECK:-default}" == "default" || $SOURCE_BUILD_SKIP_SUBMODULE_CHECK == "0" || $SOURCE_BUILD_SKIP_SUBMODULE_CHECK == "false" ]]; then
source "$scriptroot/check-submodules.sh"
fi
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
export NUGET_PACKAGES="$scriptroot/packages/restored/"
if [ "${internalPackageFeedPat:-}" ]; then
echo "Setting up NuGet credential provider using PAT from env var 'internalPackageFeedPat'..."
. "$scriptroot/eng/install-nuget-credprovider.sh"
# TODO: Read these from nuget.config
# The internal transport isn't added by Darc, though, so it will still need special-casing.
export VSS_NUGET_EXTERNAL_FEED_ENDPOINTS='{"endpointCredentials": [
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-aspnetcore-8ca3954c/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-aspnetcore-tooling-b4f2d743/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-core-setup-dc339bd0/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-extensions-194782ed/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/darc-int-dotnet-templating-7116c61c/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-templating-f8760d03/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"},
{"endpoint":"https://pkgs.dev.azure.com/dnceng/internal/_packaging/3-1-13-2-18-21/nuget/v3/index.json", "username":"optional", "password":"'$internalPackageFeedPat'"}
]}'
fi
set -x
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
if [ "$alternateTarget" == "true" ]; then
"$CLIPATH/dotnet" $SDKPATH/MSBuild.dll "$scriptroot/build.proj" /bl:source-build-test.binlog /flp:v=diag /clp:v=m "$@"
else
"$scriptroot/eng/common/build.sh" --restore --build -c Release --warnaserror false /bl:$scriptroot/artifacts/log/Debug/Build_$(date +"%m%d%H%M%S").binlog /flp:v=diag "$@"
fi