forked from OmniSharp/omnisharp-roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
670 lines (553 loc) · 22.6 KB
/
build.cake
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
#load "scripts/common.cake"
#load "scripts/runhelpers.cake"
#load "scripts/archiving.cake"
#load "scripts/artifacts.cake"
#load "scripts/platform.cake"
#load "scripts/validation.cake"
using System.ComponentModel;
using System.Net;
// Arguments
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var testConfiguration = Argument("test-configuration", "Debug");
var installFolder = Argument("install-path",
CombinePaths(Environment.GetEnvironmentVariable(Platform.Current.IsWindows ? "USERPROFILE" : "HOME"), ".omnisharp"));
var requireArchive = HasArgument("archive");
var publishAll = HasArgument("publish-all");
var useGlobalDotNetSdk = HasArgument("use-global-dotnet-sdk");
Log.Context = Context;
var env = new BuildEnvironment(useGlobalDotNetSdk);
var buildPlan = BuildPlan.Load(env);
Information("Current platform: {0}", Platform.Current);
/// <summary>
/// Clean artifacts.
/// </summary>
Task("Cleanup")
.Does(() =>
{
if (DirectoryHelper.Exists(env.Folders.Artifacts))
{
DirectoryHelper.Delete(env.Folders.Artifacts, recursive: true);
}
DirectoryHelper.Create(env.Folders.Artifacts);
DirectoryHelper.Create(env.Folders.ArtifactsLogs);
DirectoryHelper.Create(env.Folders.ArtifactsPackage);
DirectoryHelper.Create(env.Folders.ArtifactsScripts);
});
/// <summary>
/// Pre-build setup tasks.
/// </summary>
Task("Setup")
.IsDependentOn("ValidateMono")
.IsDependentOn("InstallDotNetCoreSdk")
.IsDependentOn("InstallMonoAssets")
.IsDependentOn("CreateMSBuildFolder");
void ParseDotNetInfoValues(IEnumerable<string> lines, out string version, out string rid, out string basePath)
{
version = null;
rid = null;
basePath = null;
foreach (var line in lines)
{
var colonIndex = line.IndexOf(':');
if (colonIndex >= 0)
{
var name = line.Substring(0, colonIndex).Trim();
var value = line.Substring(colonIndex + 1).Trim();
if (string.IsNullOrWhiteSpace(version) && name.Equals("Version", StringComparison.OrdinalIgnoreCase))
{
version = value;
}
else if (string.IsNullOrWhiteSpace(rid) && name.Equals("RID", StringComparison.OrdinalIgnoreCase))
{
rid = value;
}
else if (string.IsNullOrWhiteSpace(basePath) && name.Equals("Base Path", StringComparison.OrdinalIgnoreCase))
{
basePath = value;
}
}
}
if (string.IsNullOrWhiteSpace(version))
{
throw new Exception("Could not locate Version in 'dotnet --info' output.");
}
if (string.IsNullOrWhiteSpace(rid))
{
throw new Exception("Could not locate RID in 'dotnet --info' output.");
}
if (string.IsNullOrWhiteSpace(basePath))
{
throw new Exception("Could not locate Base Path in 'dotnet --info' output.");
}
}
void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, string installFolder)
{
if (!DirectoryHelper.Exists(installFolder))
{
DirectoryHelper.Create(installFolder);
}
var scriptFileName = $"dotnet-install.{env.ShellScriptFileExtension}";
var scriptFilePath = CombinePaths(installFolder, scriptFileName);
var url = $"{plan.DotNetInstallScriptURL}/{scriptFileName}";
using (var client = new WebClient())
{
client.DownloadFile(url, scriptFilePath);
}
if (!Platform.Current.IsWindows)
{
Run("chmod", $"+x '{scriptFilePath}'");
}
var argList = new List<string>();
argList.Add("-Channel");
argList.Add(plan.DotNetChannel);
if (!string.IsNullOrEmpty(version))
{
argList.Add("-Version");
argList.Add(version);
}
argList.Add("-InstallDir");
argList.Add(installFolder);
Run(env.ShellCommand, $"{env.ShellArgument} {scriptFilePath} {string.Join(" ", argList)}").ExceptionOnError($"Failed to Install .NET Core SDK {version}");
}
Task("InstallDotNetCoreSdk")
.Does(() =>
{
if (!useGlobalDotNetSdk)
{
InstallDotNetSdk(env, buildPlan,
version: buildPlan.DotNetVersion,
installFolder: env.Folders.DotNetSdk);
}
// Install legacy .NET Core SDK (used to 'dotnet restore' project.json test projects)
InstallDotNetSdk(env, buildPlan,
version: buildPlan.LegacyDotNetVersion,
installFolder: env.Folders.LegacyDotNetSdk);
string DOTNET_CLI_UI_LANGUAGE = "DOTNET_CLI_UI_LANGUAGE";
var originalUILanguageValue = Environment.GetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE);
Environment.SetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE, "en-US");
// Capture 'dotnet --info' output and parse out RID.
var lines = new List<string>();
try
{
Run(env.DotNetCommand, "--info", new RunOptions(output: lines));
}
catch (Win32Exception)
{
throw new Exception("Failed to run 'dotnet --info'");
}
finally
{
Environment.SetEnvironmentVariable(DOTNET_CLI_UI_LANGUAGE, originalUILanguageValue);
}
string version, rid, basePath;
ParseDotNetInfoValues(lines, out version, out rid, out basePath);
if (rid == "osx.10.12-x64")
{
rid = "osx.10.11-x64";
Environment.SetEnvironmentVariable("DOTNET_RUNTIME_ID", rid);
}
Information("Using .NET CLI");
Information(" Version: {0}", version);
Information(" RID: {0}", rid);
Information(" Base Path: {0}", basePath);
});
Task("ValidateMono")
.WithCriteria(() => !Platform.Current.IsWindows)
.Does(() =>
{
ValidateMonoVersion(buildPlan);
});
Task("InstallMonoAssets")
.WithCriteria(() => !Platform.Current.IsWindows)
.Does(() =>
{
Information("Acquiring Mono runtimes and framework...");
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoRuntimeMacOS}", env.Folders.MonoRuntimeMacOS);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoRuntimeLinux32}", env.Folders.MonoRuntimeLinux32);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoRuntimeLinux64}", env.Folders.MonoRuntimeLinux64);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoFramework}", env.Folders.MonoFramework);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoMSBuildRuntime}", env.Folders.MonoMSBuildRuntime);
DownloadFileAndUnzip($"{buildPlan.DownloadURL}/{buildPlan.MonoMSBuildLib}", env.Folders.MonoMSBuildLib);
var monoInstallFolder = env.CurrentMonoRuntime.InstallFolder;
var monoRuntimeFile = env.CurrentMonoRuntime.RuntimeFile;
DirectoryHelper.ForceCreate(env.Folders.Mono);
DirectoryHelper.Copy(monoInstallFolder, env.Folders.Mono);
var frameworkFolder = CombinePaths(env.Folders.Mono, "framework");
DirectoryHelper.ForceCreate(frameworkFolder);
DirectoryHelper.Copy(env.Folders.MonoFramework, frameworkFolder);
Run("chmod", $"+x '{CombinePaths(env.Folders.Mono, monoRuntimeFile)}'");
Run("chmod", $"+x '{CombinePaths(env.Folders.Mono, "run")}'");
});
/// <summary>
/// Create '.msbuild' folder and copy content to it.
/// </summary>
Task("CreateMSBuildFolder")
.IsDependentOn("InstallMonoAssets")
.Does(() =>
{
DirectoryHelper.ForceCreate(env.Folders.MSBuild);
if (!Platform.Current.IsWindows)
{
Information("Copying Mono MSBuild runtime...");
DirectoryHelper.Copy(env.Folders.MonoMSBuildRuntime, env.Folders.MSBuild);
}
else
{
Information("Copying MSBuild runtime...");
var msbuildRuntimeFolder = CombinePaths(env.Folders.Tools, "Microsoft.Build.Runtime", "contentFiles", "any", "net46");
DirectoryHelper.Copy(msbuildRuntimeFolder, env.Folders.MSBuild);
}
// Copy content of Microsoft.Net.Compilers
Information("Copying Microsoft.Net.Compilers...");
var compilersFolder = CombinePaths(env.Folders.Tools, "Microsoft.Net.Compilers", "tools");
var msbuildRoslynFolder = CombinePaths(env.Folders.MSBuild, "Roslyn");
DirectoryHelper.Copy(compilersFolder, msbuildRoslynFolder);
// Delete unnecessary files
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "Microsoft.CodeAnalysis.VisualBasic.dll"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "Microsoft.VisualBasic.Core.targets"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "VBCSCompiler.exe"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "VBCSCompiler.exe.config"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "vbc.exe"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "vbc.exe.config"));
FileHelper.Delete(CombinePaths(msbuildRoslynFolder, "vbc.rsp"));
});
/// <summary>
/// Restore required NuGet packages.
/// </summary>
Task("Restore")
.IsDependentOn("Setup")
.Does(() =>
{
// Restore the projects in OmniSharp.sln
Information("Restoring packages in OmniSharp.sln...");
RunTool(env.DotNetCommand, "restore OmniSharp.sln", env.WorkingDirectory)
.ExceptionOnError("Failed to restore projects in OmniSharp.sln.");
});
/// <summary>
/// Prepare test assets.
/// </summary>
Task("PrepareTestAssets")
.IsDependentOn("Setup")
.Does(() =>
{
// Restore and build test assets
foreach (var project in buildPlan.TestAssets)
{
Information("Restoring and building: {0}...", project);
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
RunTool(env.DotNetCommand, "restore", folder)
.ExceptionOnError($"Failed to restore '{folder}'.");
RunTool(env.DotNetCommand, "build", folder)
.ExceptionOnError($"Failed to restore '{folder}'.");
}
// Restore and build legacy test assets with legacy .NET Core SDK
foreach (var project in buildPlan.LegacyTestAssets)
{
Information("Restoring and building project.json: {0}...", project);
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
RunTool(env.LegacyDotNetCommand, "restore", folder)
.ExceptionOnError($"Failed to restore '{folder}'.");
RunTool(env.LegacyDotNetCommand, $"build", folder)
.ExceptionOnError($"Failed to restore '{folder}'.");
}
});
void BuildProject(BuildEnvironment env, string projectName, string projectFilePath, string configuration, string outputType = null)
{
string command, arguments;
// On Windows, we build exclusively with the .NET CLI.
// On OSX/Linux, we build with the MSBuild installed with Mono.
if (Platform.Current.IsWindows)
{
command = env.DotNetCommand;
arguments = $"build \"{projectFilePath}\" --configuration {configuration} /v:d";
}
else
{
command = env.ShellCommand;
arguments = $"{env.ShellArgument} msbuild \"{projectFilePath}\" /p:Configuration={configuration} /v:d";
}
var logFileName = CombinePaths(env.Folders.ArtifactsLogs, $"{projectName}-build.log");
Information("Building {0}...", projectName);
RunTool(command, arguments, env.WorkingDirectory, logFileName, new Dictionary<string, string>() { { "TestOutputType", outputType } })
.ExceptionOnError($"Building {projectName} failed.");
}
Task("BuildHosts")
.IsDependentOn("Setup")
.IsDependentOn("Restore")
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
var projectName = project + ".csproj";
var projectFilePath = CombinePaths(env.Folders.Source, project, projectName);
BuildProject(env, projectName, projectFilePath, configuration);
}
});
/// <summary>
/// Build Test projects.
/// </summary>
Task("BuildTest")
.IsDependentOn("Setup")
.IsDependentOn("Restore")
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
var projectName = project + ".csproj";
var projectFilePath = CombinePaths(env.Folders.Source, project, projectName);
BuildProject(env, projectName, projectFilePath, configuration, "test");
}
foreach (var testProject in buildPlan.TestProjects)
{
var testProjectName = testProject + ".csproj";
var testProjectFilePath = CombinePaths(env.Folders.Tests, testProject, testProjectName);
BuildProject(env, testProjectName, testProjectFilePath, testConfiguration);
}
});
/// <summary>
/// Run all tests.
/// </summary>
Task("Test")
.IsDependentOn("Setup")
.IsDependentOn("BuildTest")
.IsDependentOn("PrepareTestAssets")
.Does(() =>
{
foreach (var testProject in buildPlan.TestProjects)
{
PrintBlankLine();
var instanceFolder = CombinePaths(env.Folders.Bin, testConfiguration, testProject, "net46");
// Copy xunit executable to test folder to solve path errors
var xunitToolsFolder = CombinePaths(env.Folders.Tools, "xunit.runner.console", "tools", "net452");
var xunitInstancePath = CombinePaths(instanceFolder, "xunit.console.exe");
FileHelper.Copy(CombinePaths(xunitToolsFolder, "xunit.console.exe"), xunitInstancePath, overwrite: true);
FileHelper.Copy(CombinePaths(xunitToolsFolder, "xunit.runner.utility.net452.dll"), CombinePaths(instanceFolder, "xunit.runner.utility.net452.dll"), overwrite: true);
var targetPath = CombinePaths(instanceFolder, $"{testProject}.dll");
var logFile = CombinePaths(env.Folders.ArtifactsLogs, $"{testProject}-desktop-result.xml");
var arguments = $"\"{targetPath}\" -parallel none -noshadow -xml \"{logFile}\" -notrait category=failing";
if (Platform.Current.IsWindows)
{
Run(xunitInstancePath, arguments, instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
}
else
{
// Copy the Mono-built Microsoft.Build.* binaries to the test folder.
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", instanceFolder);
var runScript = CombinePaths(env.Folders.Mono, "run");
var oldMonoPath = Environment.GetEnvironmentVariable("MONO_PATH");
try
{
Environment.SetEnvironmentVariable("MONO_PATH", $"{instanceFolder}");
// By default, the run script launches OmniSharp. To launch our Mono runtime
// with xUnit rather than OmniSharp, we pass '--no-omnisharp'
Run(runScript, $"--no-omnisharp \"{xunitInstancePath}\" {arguments}", instanceFolder)
.ExceptionOnError($"Test {testProject} failed for net46");
}
finally
{
Environment.SetEnvironmentVariable("MONO_PATH", oldMonoPath);
}
}
}
});
void CopyMonoBuild(BuildEnvironment env, string sourceFolder, string outputFolder)
{
DirectoryHelper.Copy(sourceFolder, outputFolder, copySubDirectories: false);
// Copy MSBuild runtime and libraries
DirectoryHelper.Copy($"{env.Folders.MSBuild}", CombinePaths(outputFolder, "msbuild"));
DirectoryHelper.Copy($"{env.Folders.MonoMSBuildLib}", outputFolder);
// Included in Mono
FileHelper.Delete(CombinePaths(outputFolder, "System.AppContext.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Numerics.Vectors.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Runtime.InteropServices.RuntimeInformation.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.ComponentModel.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.ComponentModel.TypeConverter.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Console.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.IO.FileSystem.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.IO.FileSystem.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.Encoding.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.Primitives.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Security.Cryptography.X509Certificates.dll"));
FileHelper.Delete(CombinePaths(outputFolder, "System.Threading.Thread.dll"));
}
string PublishMonoBuild(string project, BuildEnvironment env, BuildPlan plan, string configuration, bool archive)
{
Information($"Publishing Mono build for {project}...");
var outputFolder = CombinePaths(env.Folders.ArtifactsPublish, project, "mono");
var buildFolder = CombinePaths(env.Folders.Bin, configuration, project, "net46");
CopyMonoBuild(env, buildFolder, outputFolder);
if (archive)
{
Package(GetPackagePrefix(project), "mono", outputFolder, env.Folders.ArtifactsPackage);
}
return outputFolder;
}
string PublishMonoBuildForPlatform(string project, MonoRuntime monoRuntime, BuildEnvironment env, BuildPlan plan, bool archive)
{
Information("Publishing platform-specific Mono build: {0}", monoRuntime.PlatformName);
var outputFolder = CombinePaths(env.Folders.ArtifactsPublish, project, monoRuntime.PlatformName);
DirectoryHelper.Copy(monoRuntime.InstallFolder, outputFolder);
Run("chmod", $"+x '{CombinePaths(outputFolder, monoRuntime.RuntimeFile)}'");
Run("chmod", $"+x '{CombinePaths(outputFolder, "run")}'");
DirectoryHelper.Copy(env.Folders.MonoFramework, CombinePaths(outputFolder, "framework"));
var sourceFolder = CombinePaths(env.Folders.ArtifactsPublish, project, "mono");
var omnisharpFolder = CombinePaths(outputFolder, "omnisharp");
CopyMonoBuild(env, sourceFolder, omnisharpFolder);
if (archive)
{
Package(GetPackagePrefix(project), monoRuntime.PlatformName, outputFolder, env.Folders.ArtifactsPackage);
}
return outputFolder;
}
Task("PublishMonoBuilds")
.IsDependentOn("Setup")
.WithCriteria(() => !Platform.Current.IsWindows)
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
var outputFolder = PublishMonoBuild(project, env, buildPlan, configuration, requireArchive);
CreateRunScript(project, outputFolder, env.Folders.ArtifactsScripts);
if (publishAll)
{
foreach (var monoRuntime in env.MonoRuntimes)
{
PublishMonoBuildForPlatform(project, monoRuntime, env, buildPlan, requireArchive);
}
}
}
});
string PublishWindowsBuild(string project, BuildEnvironment env, BuildPlan plan, string configuration, string rid, bool archive)
{
var projectName = project + ".csproj";
var projectFileName = CombinePaths(env.Folders.Source, project, projectName);
Information("Restoring packages in {0} for {1}...", projectName, rid);
RunTool(env.DotNetCommand, $"restore \"{projectFileName}\" --runtime {rid}", env.WorkingDirectory)
.ExceptionOnError($"Failed to restore {projectName} for {rid}.");
var outputFolder = CombinePaths(env.Folders.ArtifactsPublish, project, rid);
var args = $"publish \"{projectFileName}\" --runtime {rid} --configuration {configuration} --output \"{outputFolder}\"";
Information("Publishing {0} for {1}...", projectName, rid);
RunTool(env.DotNetCommand, args, env.WorkingDirectory)
.ExceptionOnError($"Failed to publish {project} for {rid}");
// Copy MSBuild to output
DirectoryHelper.Copy($"{env.Folders.MSBuild}", CombinePaths(outputFolder, "msbuild"));
if (archive)
{
Package(GetPackagePrefix(project), rid, outputFolder, env.Folders.ArtifactsPackage);
}
return outputFolder;
}
Task("PublishWindowsBuilds")
.IsDependentOn("Setup")
.WithCriteria(() => Platform.Current.IsWindows)
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
string outputFolder;
if (publishAll)
{
var outputFolder32 = PublishWindowsBuild(project, env, buildPlan, configuration, "win7-x86", requireArchive);
var outputFolder64 = PublishWindowsBuild(project, env, buildPlan, configuration, "win7-x64", requireArchive);
outputFolder = Platform.Current.Is32Bit
? outputFolder32
: outputFolder64;
}
else if (Platform.Current.Is32Bit)
{
outputFolder = PublishWindowsBuild(project, env, buildPlan, configuration, "win7-x86", requireArchive);
}
else
{
outputFolder = PublishWindowsBuild(project, env, buildPlan, configuration, "win7-x64", requireArchive);
}
CreateRunScript(project, outputFolder, env.Folders.ArtifactsScripts);
}
});
Task("Publish")
.IsDependentOn("BuildHosts")
.IsDependentOn("PublishMonoBuilds")
.IsDependentOn("PublishWindowsBuilds");
/// <summary>
/// Execute the run script.
/// </summary>
Task("ExecuteRunScript")
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
var projectFolder = CombinePaths(env.Folders.Source, project);
var script = project;
var scriptPath = CombinePaths(env.Folders.ArtifactsScripts, script);
var didNotExitWithError = Run(env.ShellCommand, $"{env.ShellArgument} \"{scriptPath}\" -s \"{projectFolder}\" --stdio",
new RunOptions(timeOut: 30000))
.DidTimeOut;
if (!didNotExitWithError)
{
throw new Exception($"Failed to run {script}");
}
}
});
/// <summary>
/// Clean install path.
/// </summary>
Task("CleanupInstall")
.Does(() =>
{
DirectoryHelper.ForceCreate(installFolder);
});
/// <summary>
/// Quick build.
/// </summary>
Task("Quick")
.IsDependentOn("Cleanup")
.IsDependentOn("Publish");
/// <summary>
/// Quick build + install.
/// </summary>
Task("Install")
.IsDependentOn("Cleanup")
.IsDependentOn("Publish")
.IsDependentOn("CleanupInstall")
.Does(() =>
{
foreach (var project in buildPlan.HostProjects)
{
string platform;
if (Platform.Current.IsWindows)
{
platform = Platform.Current.Is32Bit
? "win7-x86"
: "win7-x64";
}
else
{
platform = "mono";
}
var outputFolder = PathHelper.GetFullPath(CombinePaths(env.Folders.ArtifactsPublish, project, platform));
var targetFolder = PathHelper.GetFullPath(CombinePaths(installFolder));
DirectoryHelper.Copy(outputFolder, targetFolder);
CreateRunScript(project, installFolder, env.Folders.ArtifactsScripts);
Information($"OmniSharp is installed locally at {installFolder}");
}
});
/// <summary>
/// Full build and execute script at the end.
/// </summary>
Task("All")
.IsDependentOn("Cleanup")
.IsDependentOn("Restore")
.IsDependentOn("Test")
.IsDependentOn("Publish")
.IsDependentOn("ExecuteRunScript");
/// <summary>
/// Default Task aliases to All.
/// </summary>
Task("Default")
.IsDependentOn("All");
/// <summary>
/// Default to All.
/// </summary>
RunTarget(target);