-
Notifications
You must be signed in to change notification settings - Fork 431
/
Copy pathcsharp.rb
433 lines (367 loc) · 21.5 KB
/
csharp.rb
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# Maintained by:
# Joshua Anderson @joshua-anderson j@joshua-anderson.com
# Alexander Köplinger @akoeplinger alex.koeplinger@outlook.com
# Nicholas Terry @nterry nick.i.terry@gmail.com
module Travis
module Build
class Script
class Csharp < Script
DEFAULTS = {
mono: 'latest',
dotnet: 'none'
}
def config_dotnet
config[:dotnet].to_s
end
def config_mono
config[:mono].to_s
end
def config_os
config[:os].to_s
end
def config_solution
config[:solution].to_s if config[:solution]
end
MONO_VERSION_REGEXP = /^(\d{1})\.(\d{1,2})\.\d{1,2}$/
DOTNET_VERSION_REGEXP = /^(?<major>\d{1})\.(?<minor>\d{1,2})(\.(?<patch>\d{1,3}))?(?<prerelease>-[\w-]+)?$/
def configure
super
sh.newline
sh.echo 'C# support for Travis-CI is community maintained.', ansi: :red
sh.echo 'Please open any issues at https://travis-ci.community/c/languages/37-category and cc @joshua-anderson @akoeplinger @nterry', ansi: :red
install_mono if is_mono_enabled
install_dotnet if is_dotnet_enabled
end
def install_mono
if !is_mono_version_valid?
sh.failure "\"#{config_mono()}\" is either an invalid version of \"mono\" or unsupported on this operating system.
View valid versions of \"mono\" at https://docs.travis-ci.com/user/languages/csharp/"
end
sh.fold('mono-install') do
sh.echo 'Installing Mono', ansi: :yellow
case config_os
when 'linux'
if is_mono_2_10_8
sh.cmd 'travis_apt_get_update', retry: true, timing: true, assert: true
sh.cmd 'sudo apt-get install -qq mono-complete mono-vbnc', timing: true, assert: true
elsif is_mono_3_2_8
sh.cmd 'sudo apt-add-repository ppa:directhex/ppa -y', assert: true # Official ppa of the mono debian maintainer
sh.cmd 'travis_apt_get_update', retry: true, timing: true, assert: true
sh.cmd 'sudo apt-get install -qq mono-complete mono-vbnc fsharp', timing: true, assert: true
else
setup_pgp_key "mono"
if is_mono_after_5_0
# new Mono repo layout
repo_prefix = is_mono_preview || is_mono_nightly ? 'preview-' : 'stable-'
repo_suffix = "/snapshots/#{config_mono}" if !is_mono_version_keyword?
# main packages
sh.if '$(lsb_release -cs) = precise' do
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu #{repo_prefix}precise#{repo_suffix} main' > /etc/apt/sources.list.d/mono-official.list\"", assert: true
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu nightly-precise main' >> /etc/apt/sources.list.d/mono-official.list\"", assert: true if is_mono_nightly
end
sh.elif '$(lsb_release -cs) = trusty' do
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu #{repo_prefix}trusty#{repo_suffix} main' > /etc/apt/sources.list.d/mono-official.list\"", assert: true
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu nightly-trusty main' >> /etc/apt/sources.list.d/mono-official.list\"", assert: true if is_mono_nightly
end
sh.elif '$(lsb_release -cs) = xenial' do
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu #{repo_prefix}xenial#{repo_suffix} main' > /etc/apt/sources.list.d/mono-official.list\"", assert: true
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu nightly-xenial main' >> /etc/apt/sources.list.d/mono-official.list\"", assert: true if is_mono_nightly
end
sh.elif '$(lsb_release -cs) = bionic' do
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu #{repo_prefix}bionic#{repo_suffix} main' > /etc/apt/sources.list.d/mono-official.list\"", assert: true
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/ubuntu nightly-bionic main' >> /etc/apt/sources.list.d/mono-official.list\"", assert: true if is_mono_nightly
end
sh.else do
sh.failure "The version of this operating system is not supported by Mono. View valid versions at https://docs.travis-ci.com/user/languages/csharp/"
end
else
# old Mono repo layout
sh.if '$(lsb_release -cs) = precise' do
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main' > /etc/apt/sources.list.d/mono-official.list\"", assert: true
end
sh.cmd "sudo sh -c \"echo 'deb http://download.mono-project.com/repo/debian wheezy/snapshots/#{config_mono} main' >> /etc/apt/sources.list.d/mono-official.list\"", assert: true
end
sh.cmd 'travis_apt_get_update', retry: true, timing: true, assert: true
sh.cmd "sudo apt-get install -qq mono-complete mono-vbnc fsharp nuget #{'referenceassemblies-pcl' if !is_mono_3_8_0}", timing: true, assert: true
# PCL Assemblies only supported on mono 3.10 and greater
end
when 'osx'
sh.cmd "wget --retry-connrefused --waitretry=1 -O /tmp/mdk.pkg #{mono_osx_url}", timing: true, assert: true, echo: true
sh.cmd 'sudo installer -package "/tmp/mdk.pkg" -target "/" -verboseR', timing: true, assert: true
sh.cmd 'eval $(/usr/libexec/path_helper -s)', timing: false, assert: true
else
sh.failure "Operating system not supported: #{config_os}"
end
if is_mono_before_3_12 && config_os == 'linux'
# we need to fetch an ancient version of certdata (from 2009) because newer versions run into a Mono bug: https://github.com/mono/mono/pull/1514
# this is the same file that was used in the old mozroots before https://github.com/mono/mono/pull/3188 so nothing really changes (but still less than ideal)
sh.cmd 'wget --retry-connrefused --waitretry=1 -O /tmp/certdata.txt https://hg.mozilla.org/releases/mozilla-release/raw-file/5d447d9abfdf/security/nss/lib/ckfw/builtins/certdata.txt'
sh.cmd 'mozroots --import --sync --quiet --file /tmp/certdata.txt', timing: true
end
end
end
def install_dotnet
if !is_dotnet_version_valid?
sh.failure "\"#{config_dotnet}\" is either an invalid version of \"dotnet\" or unsupported on this operating system.
View valid versions of \"dotnet\" at https://docs.travis-ci.com/user/languages/csharp/"
end
sh.fold('dotnet-install') do
sh.echo 'Installing .NET Core', ansi: :yellow
# the nuget cache initialization on first run doesn't make sense on Travis since it'd be cleared after the build is done
sh.export 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE', '1'
# opt out of dotnet-cli telemetry
sh.export 'DOTNET_CLI_TELEMETRY_OPTOUT', '1'
case config_os
when 'linux'
setup_pgp_key "dotnet"
sh.if '$(lsb_release -cs) = trusty' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/14.04/prod trusty main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.elif '$(lsb_release -cs) = xenial' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.elif '$(lsb_release -cs) = bionic' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.elif '$(lsb_release -cs) = focal' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/20.04/prod focal main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.elif '$(lsb_release -cs) = jammy' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/22.04/prod jammy main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.elif '$(lsb_release -cs) = noble' do
sh.cmd "sudo sh -c \"echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/24.04/prod noble main' > /etc/apt/sources.list.d/dotnet-official.list\"", assert: true
end
sh.else do
sh.failure "The version of this operating system is not supported by .NET Core. View valid versions at https://docs.travis-ci.com/user/languages/csharp/"
end
sh.cmd 'travis_apt_get_update', retry: true, timing: true, assert: true
sh.cmd "sudo apt-get install -qq dotnet-#{dotnet_package_prefix}-#{dotnet_package_version}", timing: true, assert: true
when 'osx'
min_osx_minor = 11
min_osx_minor = 12 if is_dotnet_after_2_0?
sh.if "$(sw_vers -productVersion | cut -d . -f 2) -lt #{min_osx_minor}" do
sh.failure "The version of this operating system is not supported by .NET Core. View valid versions at https://docs.travis-ci.com/user/languages/csharp/"
end
if !is_dotnet_after_2_0?
sh.cmd 'brew update', timing: true, assert: true
sh.cmd 'brew install openssl', timing: true, assert: true
sh.cmd 'mkdir -p /usr/local/lib', timing: false, assert: true
sh.cmd 'ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/', timing: false, assert: true
sh.cmd 'ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/', timing: false, assert: true
end
sh.cmd "wget --retry-connrefused --waitretry=1 -O /tmp/dotnet.pkg #{dotnet_osx_url}", timing: true, assert: true, echo: true
sh.cmd 'sudo installer -package "/tmp/dotnet.pkg" -target "/" -verboseR', timing: true, assert: true
sh.cmd 'eval $(/usr/libexec/path_helper -s)', timing: false, assert: true
else
sh.failure "Operating system not supported: #{config_os}"
end
end
end
def announce
super
sh.cmd 'mono --version', timing: true if is_mono_enabled
sh.cmd "#{mono_build_cmd} /version", timing: true if is_mono_enabled
sh.newline
sh.cmd 'dotnet --info', timing: true if is_dotnet_enabled
sh.newline
end
def export
super
sh.export 'TRAVIS_SOLUTION', config_solution.shellescape if config_solution
sh.export 'STANDARD_CI_SOURCE_REVISION_ID', '${TRAVIS_COMMIT}', echo: false
sh.export 'STANDARD_CI_REPOSITORY_URL', 'https://github.com/${TRAVIS_REPO_SLUG}', echo: false
sh.export 'STANDARD_CI_REPOSITORY_TYPE', 'git', echo: false
end
def install
sh.cmd "nuget restore #{config_solution.shellescape}", retry: true if is_mono_enabled && config_solution && !is_mono_2_10_8 && !is_mono_3_2_8
end
def script
if config_solution && is_mono_enabled
sh.cmd "#{mono_build_cmd} /p:Configuration=Release #{config_solution.shellescape}", timing: true
else
sh.failure 'No solution or script defined, exiting'
end
end
def setup_pgp_key(key_type)
if key_type == 'mono'
pgp_key = mono_pgp_key
elsif key_type == 'dotnet'
pgp_key = dotnet_pgp_key
else
return
end
pgp_key.each_line do |line|
sh.cmd "echo '#{line.chomp}' >> /tmp/#{key_type}.asc"
end
sh.cmd "gpg --dearmor < /tmp/#{key_type}.asc > /tmp/#{key_type}.gpg", assert: true
sh.cmd "sudo mv /tmp/#{key_type}.gpg /etc/apt/trusted.gpg.d/", assert: true
end
def mono_pgp_key
return "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
"Version: GnuPG v1\n" +
"\n" +
"mQENBFPfqCcBCADctOzyTxfWvf40Nlb+AMkcJyb505WSbzhWU8yPmBNAJ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"-----END PGP PUBLIC KEY BLOCK-----\n"
end
def dotnet_pgp_key
return "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
"Version: GnuPG v1\n" +
"\n" +
"mQENBFYxWIwBCADAKoZhZlJxGNGWzqV+1OG1xiQeoowKhssGAKvd+buXCGISZJwT\n" +
"LXZqIcIiLP7pqdcZWtE9bSc7yBY2MalDp9Liu0KekywQ6VVX1T72NPf5Ev6x6DLV\n" +
"7aVWsCzUAF+eb7DC9fPuFLEdxmOEYoPjzrQ7cCnSV4JQxAqhU4T6OjbvRazGl3ag\n" +
"OeizPXmRljMtUUttHQZnRhtlzkmwIrUivbfFPD+fEoHJ1+uIdfOzZX8/oKHKLe2j\n" +
"H632kvsNzJFlROVvGLYAk2WRcLu+RjjggixhwiB+Mu/A8Tf4V6b+YppS44q8EvVr\n" +
"M+QvY7LNSOffSO6Slsy9oisGTdfE39nC7pVRABEBAAG0N01pY3Jvc29mdCAoUmVs\n" +
"ZWFzZSBzaWduaW5nKSA8Z3Bnc2VjdXJpdHlAbWljcm9zb2Z0LmNvbT6JATUEEwEC\n" +
"AB8FAlYxWIwCGwMGCwkIBwMCBBUCCAMDFgIBAh4BAheAAAoJEOs+lK2+EinPGpsH\n" +
"/32vKy29Hg51H9dfFJMx0/a/F+5vKeCeVqimvyTM04C+XENNuSbYZ3eRPHGHFLqe\n" +
"MNGxsfb7C7ZxEeW7J/vSzRgHxm7ZvESisUYRFq2sgkJ+HFERNrqfci45bdhmrUsy\n" +
"7SWw9ybxdFOkuQoyKD3tBmiGfONQMlBaOMWdAsic965rvJsd5zYaZZFI1UwTkFXV\n" +
"KJt3bp3Ngn1vEYXwijGTa+FXz6GLHueJwF0I7ug34DgUkAFvAs8Hacr2DRYxL5RJ\n" +
"XdNgj4Jd2/g6T9InmWT0hASljur+dJnzNiNCkbn9KbX7J/qK1IbR8y560yRmFsU+\n" +
"NdCFTW7wY0Fb1fWJ+/KTsC4=\n" +
"=J6gs\n" +
"-----END PGP PUBLIC KEY BLOCK-----\n"
end
def mono_osx_url
base_url = 'http://download.mono-project.com/archive/'
case config_mono
when 'latest'
return base_url + 'mdk-latest.pkg'
when 'alpha', 'beta', 'preview'
return base_url + 'mdk-latest-preview.pkg'
when 'weekly', 'nightly'
return base_url + 'mdk-latest-nightly.pkg'
else
if is_mono_after_4_4
return base_url + config_mono + "/macos-10-universal/MonoFramework-MDK-#{config_mono}.macos10.xamarin.universal.pkg"
else
return base_url + config_mono + "/macos-10-x86/MonoFramework-MDK-#{config_mono}.macos10.xamarin.x86.pkg"
end
end
end
def dotnet_osx_url
if is_dotnet_after_2_0?
return "https://dotnetcli.azureedge.net/dotnet/Sdk/#{config_dotnet}/dotnet-#{dotnet_package_prefix}-#{config_dotnet}-osx-x64.pkg"
else
return "https://dotnetcli.azureedge.net/dotnet/Sdk/#{config_dotnet}/dotnet-#{dotnet_package_prefix}-osx-x64.#{config_dotnet}.pkg"
end
end
def dotnet_package_prefix
return is_dotnet_after_2_0? ? "sdk" : "dev"
end
def dotnet_package_version
return config_dotnet unless is_dotnet_after_2_1_300? # before 2.1.300, the package ID contains the full version
version = DOTNET_VERSION_REGEXP.match(config_dotnet)
return config_dotnet unless version[:patch] # if only major.minor is provided
"#{version[:major]}.#{version[:minor]}=#{config_dotnet}*" # if fully-qualified version is specified
end
def mono_build_cmd
is_mono_after_5_0 ? "msbuild" : "xbuild"
end
def is_mono_version_valid?
return false unless config_os == 'linux' || config_os == 'osx'
return true if is_mono_version_keyword?
return false unless MONO_VERSION_REGEXP === config_mono
return false if MONO_VERSION_REGEXP.match(config_mono)[1] == '2' && !is_mono_2_10_8 && config_os == 'linux'
return false if MONO_VERSION_REGEXP.match(config_mono)[1].to_i < 2 && config_os == 'linux'
true
end
def is_dotnet_version_valid?
return false unless config_os == 'linux' || config_os == 'osx'
return false unless DOTNET_VERSION_REGEXP === config_dotnet
true
end
def is_mono_enabled
config_mono != 'none'
end
def is_dotnet_enabled
config_dotnet != 'none'
end
def is_mono_version_keyword?
['latest', 'alpha', 'beta', 'preview', 'weekly', 'nightly', 'none'].include? config_mono
end
def is_mono_nightly
config_mono == 'nightly' || config_mono == 'weekly'
end
def is_mono_preview
config_mono == 'alpha' || config_mono == 'beta' || config_mono == 'preview'
end
def is_mono_2_10_8
config_mono == '2.10.8'
end
def is_mono_3_2_8
config_mono == '3.2.8'
end
def is_mono_3_8_0
config_mono == '3.8.0'
end
def is_mono_before_3_12
return false unless is_mono_version_valid?
return false if is_mono_version_keyword?
return true if MONO_VERSION_REGEXP.match(config_mono)[1] == '2'
return true if MONO_VERSION_REGEXP.match(config_mono)[1] == '3' && MONO_VERSION_REGEXP.match(config_mono)[2].to_i < 12
false
end
def is_mono_after_4_4
return false unless is_mono_version_valid?
return true if is_mono_version_keyword?
return false if MONO_VERSION_REGEXP.match(config_mono)[1].to_i < 4
return false if MONO_VERSION_REGEXP.match(config_mono)[1] == '4' && MONO_VERSION_REGEXP.match(config_mono)[2].to_i < 4
true
end
def is_mono_after_5_0
return false unless is_mono_version_valid?
return true if is_mono_version_keyword?
return false if MONO_VERSION_REGEXP.match(config_mono)[1].to_i < 5
true
end
def is_dotnet_after_2_0?
return false unless is_dotnet_version_valid?
return false if DOTNET_VERSION_REGEXP.match(config_dotnet)[:major].to_i < 2
true
end
# Starting in 2.1.300, the package ID changed from dotnet-sdk-(major.minor.patch) to dotnet-sdk-(major.minor)
def is_dotnet_after_2_1_300?
return false unless is_dotnet_version_valid?
return true if config_dotnet == '2.1' # Special case - treat '2.1' as >= 2.1.300
Gem::Version.new(config_dotnet) >= Gem::Version.new('2.1.300')
end
end
end
end
end