-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdotnet-build
executable file
·293 lines (281 loc) · 12.8 KB
/
dotnet-build
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!/bin/bash
set -e -u -x -o pipefail
shopt -s extglob
pushd "$(dirname "$0")"
. dotnet-versions
popd
BASEDIR=$(pwd)
PACKAGESDIR=$BASEDIR/local-packages
DOWNLOADDIR=$BASEDIR/local-downloads
OUTPUTDIR=$BASEDIR/output
mkdir -p "$PACKAGESDIR"
mkdir -p "$DOWNLOADDIR"
mkdir -p "$OUTPUTDIR"
ARCH=${ARCH-s390x}
case "$ARCH on $(uname -m)" in
"ppc64le on ppc64le" | "s390x on s390x" | "x64 on x86_64")
CROSS=false
;;
*)
CROSS=true
;;
esac
runtime_conf=Release
runtime_flavor=Mono
msbuild_conf=Release
roslyn_conf=Release
aspnetcore_conf=Release
sdk_conf=Release
function build_runtime {
runtime_build_flags=(
--ci
-c "$runtime_conf"
-clang
-keepnativesymbols true
"/p:PrimaryRuntimeFlavor=$runtime_flavor"
"/p:DotNetUseShippingVersions=true"
"/p:DeterministicSourcePaths=false"
"/p:SkipArchivesBuild=false"
)
if [ "$ARCH" = s390x ] || [ "$ARCH" = ppc64le ]; then
runtime_build_flags+=(
--cmakeargs "-DFEATURE_GDBJIT=true"
--cmakeargs "-DFEATURE_GDBJIT_FRAME=true"
--cmakeargs "-DFEATURE_GDBJIT_SYMTAB=true"
)
fi
if [ "$runtime_build_id" != "" ]; then
runtime_build_flags+=(
"/p:ContinuousIntegrationBuild=true"
"/p:OfficialBuildId=$runtime_build_id"
)
fi
if "$CROSS"; then
runtime_build_flags+=(
-arch "$ARCH"
-cross
)
fi
# https://github.com/dotnet/arcade/issues/9846
if { [ "$ARCH" = "s390x" ] || [ "$ARCH" = "ppc64le" ]; } && ! "$CROSS"; then
runtime_build_flags+=("/p:RunApiCompat=false")
fi
pushd runtime
if [ -z ${SKIP_BUILD_RUNTIME+x} ] && [ ! -e .skip-build ]; then
ROOTFS_DIR=/ ./build.sh "${runtime_build_flags[@]}"
fi
if [ -z ${SKIP_PACKAGE_RUNTIME+x} ] && [ ! -e .skip-package ]; then
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Host.linux-$ARCH.$runtime_version.nupkg" "$PACKAGESDIR"
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Runtime.linux-$ARCH.$runtime_version.nupkg" "$PACKAGESDIR"
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Ref.$runtime_version.nupkg" "$PACKAGESDIR"
mkdir -p "$DOWNLOADDIR/Runtime/$runtime_version"
cp "artifacts/packages/$runtime_conf/Shipping/dotnet-runtime-$runtime_version-linux-$ARCH.tar.gz" "$DOWNLOADDIR/Runtime/$runtime_version"
# Necessary for incoherent packages: pretend that the runtime that we built
# has the version that ASP.NET requires.
# https://devblogs.microsoft.com/dotnet/a-deep-dive-into-how-net-builds-and-ships/
mkdir -p "$DOWNLOADDIR/Runtime/$aspnetcore_transport_version"
cp \
"artifacts/packages/$runtime_conf/Shipping/dotnet-runtime-$runtime_version-linux-$ARCH.tar.gz" \
"$DOWNLOADDIR/Runtime/$aspnetcore_transport_version/dotnet-runtime-$aspnetcore_runtime_version-linux-$ARCH.tar.gz"
cp "artifacts/packages/$runtime_conf/Shipping/dotnet-runtime-$runtime_version-linux-$ARCH.tar.gz" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Host.linux-$ARCH.$runtime_version.nupkg" "$OUTPUTDIR"
if ! git merge-base --is-ancestor e68313e HEAD; then
cp "artifacts/packages/$runtime_conf/Shipping/dotnet-runtime-symbols-linux-$ARCH-$runtime_version.tar.gz" "$OUTPUTDIR"
else
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Host.linux-$ARCH.$runtime_version.symbols.nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Runtime.linux-$ARCH.$runtime_version.symbols.nupkg" "$OUTPUTDIR"
fi
cp "artifacts/packages/$runtime_conf/Shipping/Microsoft.NETCore.App.Runtime.linux-$ARCH.$runtime_version.nupkg" "$OUTPUTDIR"
if [ "$runtime_major_version" -lt 9 ]; then
# https://github.com/dotnet/runtime/pull/91655
cp "artifacts/packages/$runtime_conf/Shipping/runtime.linux-$ARCH.Microsoft.NETCore.DotNetHost.$runtime_version.nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/Shipping/runtime.linux-$ARCH.Microsoft.NETCore.DotNetHostPolicy.$runtime_version.nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/Shipping/runtime.linux-$ARCH.Microsoft.NETCore.DotNetHostResolver.$runtime_version.nupkg" "$OUTPUTDIR"
fi
if [ "$runtime_version_label" = servicing ]; then
cp "artifacts/packages/$runtime_conf/NonShipping/Microsoft.NETCore.ILAsm.$runtime_version_prefix-"@(dev|ci)*".nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/NonShipping/Microsoft.NETCore.ILDAsm.$runtime_version_prefix-"@(dev|ci)**".nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/NonShipping/runtime.linux-$ARCH.Microsoft.NETCore.ILAsm.$runtime_version_prefix-"@(dev|ci)*".nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/NonShipping/runtime.linux-$ARCH.Microsoft.NETCore.ILDAsm.$runtime_version_prefix-"@(dev|ci)*".nupkg" "$OUTPUTDIR"
else
cp "artifacts/packages/$runtime_conf/Shipping/runtime.linux-$ARCH.Microsoft.NETCore.ILAsm.$runtime_version.nupkg" "$OUTPUTDIR"
cp "artifacts/packages/$runtime_conf/Shipping/runtime.linux-$ARCH.Microsoft.NETCore.ILDAsm.$runtime_version.nupkg" "$OUTPUTDIR"
fi
if [ "$ARCH" = s390x ]; then
tar -C artifacts/obj/mono/[Ll]inux."$ARCH"."$runtime_conf"/out/lib -czf "$OUTPUTDIR"/libmono-profiler-log-"$ARCH".tar.gz libmono-profiler-log.so
fi
fi
popd
}
function build_msbuild {
msbuild_build_flags=(
--ci
--restore
--pack
--configuration "$msbuild_conf"
"/p:EnableNgenOptimization=false"
)
if [ "$msbuild_build_id" != "" ]; then
msbuild_build_flags+=(
"/p:ContinuousIntegrationBuild=true"
"/p:OfficialBuildId=$msbuild_build_id"
)
fi
pushd msbuild
if [ -z ${SKIP_BUILD_MSBUILD+x} ] && [ ! -e .skip-build ]; then
./build.sh "${msbuild_build_flags[@]}"
fi
if [ -z ${SKIP_PACKAGE_MSBUILD+x} ] && [ ! -e .skip-package ]; then
for I in artifacts/packages/Release/*/*; do cp "$I" "$PACKAGESDIR"; done
fi
popd
}
function build_roslyn {
pushd roslyn
roslyn_build_flags=(
--ci
--restore
--build
--pack
--binaryLog
--configuration "$roslyn_conf"
"/p:EnableNgenOptimization=false"
)
if [ "$roslyn_build_id" != "" ]; then
roslyn_build_flags+=(
"/p:ContinuousIntegrationBuild=true"
"/p:OfficialBuildId=$roslyn_build_id"
)
fi
if [ -z ${SKIP_BUILD_ROSLYN+x} ] && [ ! -e .skip-build ]; then
./eng/build.sh "${roslyn_build_flags[@]}"
fi
if [ -z ${SKIP_PACKAGE_ROSLYN+x} ] && [ ! -e .skip-package ]; then
for I in artifacts/packages/Release/*/*.nupkg; do cp "$I" "$PACKAGESDIR"; done
fi
popd
}
function build_sdk {
SDK_CONF=Release
SDK_VERSION=$sdk_version_prefix
sdk_build_flags=(
--ci
--pack
--configuration "$SDK_CONF"
"/p:Architecture=$ARCH"
"/p:HostRid=linux-x64"
"/p:BundleRuntimePacks=true"
"/p:PublicBaseURL=file://$DOWNLOADDIR/"
"/p:CoreSetupBlobRootUrl=file://$DOWNLOADDIR/"
"/p:DotnetToolsetBlobRootUrl=file://$DOWNLOADDIR/"
)
if [ "$sdk_build_id" != "" ]; then
sdk_build_flags+=(
"/p:ContinuousIntegrationBuild=true"
"/p:OfficialBuildId=$sdk_build_id"
)
fi
if [ "$runtime_flavor" = Mono ]; then
sdk_build_flags+=("/p:DISABLE_CROSSGEN=true")
fi
if [ "$sdk_version_suffix" != "" ]; then
SDK_VERSION=$SDK_VERSION-$sdk_version_suffix
fi
pushd sdk
if [ -z ${SKIP_BUILD_SDK+x} ] && [ ! -e .skip-build ]; then
./build.sh "${sdk_build_flags[@]}"
fi
if [ -z ${SKIP_PACKAGE_SDK+x} ] && [ ! -e .skip-package ]; then
mkdir -p "$DOWNLOADDIR/Sdk/$SDK_VERSION"
cp "artifacts/packages/Release/NonShipping/dotnet-toolset-internal-$SDK_VERSION.zip" "$DOWNLOADDIR/Sdk/$SDK_VERSION"
cp "artifacts/packages/$sdk_conf/Shipping/dotnet-sdk-$SDK_VERSION-linux-$ARCH.tar.gz" "$OUTPUTDIR"
fi
popd
}
function build_aspnetcore {
ASPNETCORE_VERSION=$aspnetcore_version_prefix
aspnetcore_major_minor_version=$aspnetcore_major_version.$aspnetcore_minor_version
aspnetcore_build_flags=(
--ci
--configuration "$aspnetcore_conf"
--pack
"/p:DotNetAssetRootUrl=file://$DOWNLOADDIR/"
)
if [ "$runtime_major_version" -gt 9 ]; then
aspnetcore_build_flags+=(
"/p:PublicBaseURL=file://$DOWNLOADDIR/"
"/p:MicrosoftNETCoreAppRuntimeVersion=$runtime_version"
"/p:DotNetRuntimeDownloadPath=Runtime/$runtime_version/dotnet-runtime-$runtime_version-linux-$ARCH.tar.gz"
)
fi
if [ "$aspnetcore_build_id" != "" ]; then
aspnetcore_build_flags+=(
"/p:ContinuousIntegrationBuild=true"
"/p:OfficialBuildId=$aspnetcore_build_id"
)
fi
if [ "$aspnetcore_version_suffix" != "" ]; then
ASPNETCORE_VERSION=$ASPNETCORE_VERSION-$aspnetcore_version_suffix
fi
if "$CROSS"; then
aspnetcore_build_flags+=(-arch "$ARCH")
fi
pushd aspnetcore
if [ -z ${SKIP_BUILD_ASPNETCORE+x} ] && [ ! -e .skip-build ]; then
# Since commit 243f90d0bec5 ("Use Arcade's DownloadFiles task (#46039)")
# aspnetcore no longer supports downloading runtime from custom URLs.
mkdir -p artifacts/obj/Microsoft.AspNetCore.App.Runtime
cp "$DOWNLOADDIR/Runtime/$runtime_version/dotnet-runtime-$runtime_version-linux-$ARCH.tar.gz" \
artifacts/obj/Microsoft.AspNetCore.App.Runtime/
if [ "$runtime_version" != "$aspnetcore_runtime_version" ]; then
cp "$DOWNLOADDIR/Runtime/$aspnetcore_transport_version/dotnet-runtime-$aspnetcore_runtime_version-linux-$ARCH.tar.gz" \
artifacts/obj/Microsoft.AspNetCore.App.Runtime/
fi
# Run build script multiple times to work around yarn race condition
for i in $(seq 1 3); do
if ./eng/build.sh "${aspnetcore_build_flags[@]}"; then
break
fi
if [ "$i" -eq 3 ]; then
exit 1
fi
done
fi
if [ -z ${SKIP_PACKAGE_ASPNETCORE+x} ] && [ ! -e .skip-package ]; then
cp "artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.AspNetCore.App.Runtime.linux-$ARCH.$ASPNETCORE_VERSION.nupkg" "$PACKAGESDIR"
cp "artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.AspNetCore.App.Ref.$ASPNETCORE_VERSION.nupkg" "$PACKAGESDIR"
cp "artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.DotNet.Web.ItemTemplates.$aspnetcore_major_minor_version.$ASPNETCORE_VERSION.nupkg" "$PACKAGESDIR"
cp "artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.DotNet.Web.ProjectTemplates.$aspnetcore_major_minor_version.$ASPNETCORE_VERSION.nupkg" "$PACKAGESDIR"
spa_templates=artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.$aspnetcore_major_minor_version.$ASPNETCORE_VERSION.nupkg
if [ -e "$spa_templates" ]; then
cp "$spa_templates" "$PACKAGESDIR"
fi
if ! git merge-base --is-ancestor 7949421 HEAD; then
aspnetcore_tgz=artifacts/installers/$aspnetcore_conf/aspnetcore-runtime-internal-$ASPNETCORE_VERSION-linux-$ARCH.tar.gz
else
aspnetcore_tgz=artifacts/packages/$aspnetcore_conf/Shipping/aspnetcore-runtime-internal-$ASPNETCORE_VERSION-linux-$ARCH.tar.gz
fi
if [ ! -e "$aspnetcore_tgz" ]; then
if ! git merge-base --is-ancestor 7949421 HEAD; then
aspnetcore_tgz=artifacts/installers/$aspnetcore_conf/aspnetcore-runtime-$ASPNETCORE_VERSION-linux-$ARCH.tar.gz
else
aspnetcore_tgz=artifacts/packages/$aspnetcore_conf/Shipping/aspnetcore-runtime-$ASPNETCORE_VERSION-linux-$ARCH.tar.gz
fi
fi
mkdir -p "$DOWNLOADDIR/aspnetcore/Runtime/$aspnetcore_internal_version"
cp "$aspnetcore_tgz" "$DOWNLOADDIR/aspnetcore/Runtime/$aspnetcore_internal_version"
cp "$aspnetcore_tgz" "$DOWNLOADDIR/aspnetcore/Runtime/$aspnetcore_internal_version/aspnetcore-runtime-$ASPNETCORE_VERSION-linux-$ARCH.tar.gz"
cp "artifacts/installers/$aspnetcore_conf/aspnetcore_base_runtime.version" "$DOWNLOADDIR/aspnetcore/Runtime/$aspnetcore_internal_version"
cp "artifacts/packages/$aspnetcore_conf/Shipping/Microsoft.AspNetCore.App.Runtime.linux-$ARCH.$ASPNETCORE_VERSION.nupkg" "$OUTPUTDIR"
fi
popd
}
if [ "$#" -gt 0 ]; then
projects=("$@")
else
projects=(runtime msbuild roslyn aspnetcore sdk)
fi
export NuGetAudit=false
for project in "${projects[@]}"; do
eval "build_${project}"
done