|
1 | 1 | var TARGET = Argument("t", Argument("target", "Default")); |
2 | 2 | var CONFIGURATION = Argument("c", Argument("configuration", "Release")); |
3 | | -var PREVIEW_LABEL = Argument ("previewLabel", EnvironmentVariable ("PREVIEW_LABEL") ?? "preview"); |
4 | | -var BUILD_NUMBER = Argument ("buildNumber", EnvironmentVariable ("BUILD_NUMBER") ?? "0"); |
5 | | -var GIT_SHA = Argument ("gitSha", EnvironmentVariable ("GIT_SHA") ?? ""); |
6 | | -var GIT_BRANCH_NAME = Argument ("gitBranch", EnvironmentVariable ("GIT_BRANCH_NAME") ?? ""); |
| 3 | +var PREVIEW_LABEL = Argument("previewLabel", EnvironmentVariable("PREVIEW_LABEL") ?? "preview"); |
| 4 | +var BUILD_NUMBER = Argument("buildNumber", EnvironmentVariable("BUILD_NUMBER") ?? "0"); |
| 5 | +var GIT_SHA = Argument("gitSha", EnvironmentVariable("GIT_SHA") ?? ""); |
| 6 | +var GIT_BRANCH_NAME = Argument("gitBranch", EnvironmentVariable("GIT_BRANCH_NAME") ?? ""); |
| 7 | + |
| 8 | +var OUTPUT_ROOT = MakeAbsolute((DirectoryPath)"./output/"); |
| 9 | + |
| 10 | +ProcessArgumentBuilder AppendForwardingLogger(ProcessArgumentBuilder args) |
| 11 | +{ |
| 12 | + if (BuildSystem.IsLocalBuild) |
| 13 | + return args; |
| 14 | + |
| 15 | + // URL copied from https://github.com/microsoft/azure-pipelines-tasks/blob/7faf3e8146d43753b9f360edfae3d2e75ad78c76/Tasks/DotNetCoreCLIV2/make.json |
| 16 | + var loggerUrl = "https://vstsagenttools.blob.core.windows.net/tools/msbuildlogger/3/msbuildlogger.zip"; |
| 17 | + |
| 18 | + var AGENT_TEMPDIRECTORY = (DirectoryPath)EnvironmentVariable("AGENT_TEMPDIRECTORY"); |
| 19 | + var loggerDir = AGENT_TEMPDIRECTORY.Combine("msbuildlogger"); |
| 20 | + EnsureDirectoryExists(loggerDir); |
| 21 | + |
| 22 | + var loggerZip = loggerDir.CombineWithFilePath("msbuildlogger.zip"); |
| 23 | + if (!FileExists(loggerZip)) |
| 24 | + DownloadFile(loggerUrl, loggerZip); |
| 25 | + |
| 26 | + var loggerDll = loggerDir.CombineWithFilePath("Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"); |
| 27 | + if (!FileExists(loggerDll)) |
| 28 | + Unzip(loggerZip, loggerDir); |
| 29 | + |
| 30 | + return args.Append($"-dl:CentralLogger,\"{loggerDll}\"*ForwardingLogger,\"{loggerDll}\""); |
| 31 | +} |
7 | 32 |
|
8 | 33 | Task("build") |
9 | 34 | .Does(() => |
10 | 35 | { |
11 | | - var settings = new MSBuildSettings() |
12 | | - { AllowPreviewVersion = true } |
13 | | - .EnableBinaryLogger("./output/binlogs/build.binlog") |
14 | | - .SetConfiguration(CONFIGURATION) |
15 | | - .SetMaxCpuCount(0) |
16 | | - .WithRestore(); |
17 | | - |
18 | | - MSBuild("./SkiaSharp.Extended.sln", settings); |
| 36 | + DotNetBuild("./SkiaSharp.Extended.sln", new DotNetBuildSettings |
| 37 | + { |
| 38 | + Configuration = CONFIGURATION, |
| 39 | + MSBuildSettings = new DotNetMSBuildSettings() |
| 40 | + .EnableBinaryLogger(OUTPUT_ROOT.Combine("binlogs").CombineWithFilePath("build.binlog").FullPath), |
| 41 | + ArgumentCustomization = AppendForwardingLogger |
| 42 | + }); |
19 | 43 | }); |
20 | 44 |
|
21 | 45 | Task("pack") |
22 | 46 | .Does(() => |
23 | 47 | { |
24 | | - MSBuild("./SkiaSharp.Extended-Pack.slnf", new MSBuildSettings() |
25 | | - { AllowPreviewVersion = true } |
26 | | - .EnableBinaryLogger("./output/binlogs/pack.binlog") |
27 | | - .SetConfiguration(CONFIGURATION) |
28 | | - .SetMaxCpuCount(0) |
29 | | - .WithRestore() |
30 | | - .WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/nugets")).FullPath) |
31 | | - .WithTarget("Pack")); |
| 48 | + DotNetPack("./scripts/SkiaSharp.Extended-Pack.slnf", new DotNetPackSettings |
| 49 | + { |
| 50 | + Configuration = CONFIGURATION, |
| 51 | + MSBuildSettings = new DotNetMSBuildSettings() |
| 52 | + .EnableBinaryLogger(OUTPUT_ROOT.Combine("binlogs").CombineWithFilePath("pack.binlog").FullPath), |
| 53 | + OutputDirectory = OUTPUT_ROOT.Combine("nugets"), |
| 54 | + ArgumentCustomization = AppendForwardingLogger |
| 55 | + }); |
32 | 56 |
|
33 | 57 | var preview = PREVIEW_LABEL; |
34 | | - if (!string.IsNullOrEmpty (BUILD_NUMBER)) { |
| 58 | + if (!string.IsNullOrEmpty(BUILD_NUMBER)) |
| 59 | + { |
35 | 60 | preview += $".{BUILD_NUMBER}"; |
36 | 61 | } |
37 | 62 |
|
38 | | - MSBuild("./SkiaSharp.Extended-Pack.slnf", new MSBuildSettings() |
39 | | - { AllowPreviewVersion = true } |
40 | | - .EnableBinaryLogger("./output/binlogs/pack-preview.binlog") |
41 | | - .SetConfiguration(CONFIGURATION) |
42 | | - .SetMaxCpuCount(0) |
43 | | - .WithRestore() |
44 | | - .WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/nugets")).FullPath) |
45 | | - .WithProperty("VersionSuffix", preview) |
46 | | - .WithTarget("Pack")); |
| 63 | + DotNetPack("./scripts/SkiaSharp.Extended-Pack.slnf", new DotNetPackSettings |
| 64 | + { |
| 65 | + Configuration = CONFIGURATION, |
| 66 | + MSBuildSettings = new DotNetMSBuildSettings() |
| 67 | + .EnableBinaryLogger(OUTPUT_ROOT.Combine("binlogs").CombineWithFilePath("pack-preview.binlog").FullPath), |
| 68 | + OutputDirectory = OUTPUT_ROOT.Combine("nugets"), |
| 69 | + VersionSuffix = preview, |
| 70 | + ArgumentCustomization = AppendForwardingLogger |
| 71 | + }); |
47 | 72 |
|
48 | 73 | CopyFileToDirectory("./source/SignList.xml", "./output/nugets"); |
49 | 74 | }); |
50 | 75 |
|
51 | 76 | Task("test") |
52 | 77 | .Does(() => |
53 | 78 | { |
54 | | - var failed = 0; |
55 | | - |
56 | | - foreach (var csproj in GetFiles("./tests/*/*.csproj")) { |
57 | | - // skip WPF on non-Windows |
58 | | - if (!IsRunningOnWindows() && csproj.GetFilename().FullPath.Contains(".WPF.")) |
59 | | - continue; |
60 | | - |
61 | | - try { |
62 | | - DotNetTest(csproj.FullPath, new DotNetTestSettings { |
63 | | - Configuration = CONFIGURATION, |
64 | | - Loggers = new [] { $"trx;LogFileName={csproj.GetFilenameWithoutExtension()}.trx" }, |
65 | | - }); |
66 | | - } catch (Exception) { |
67 | | - failed++; |
68 | | - } |
69 | | - } |
70 | | - |
71 | | - var output = $"./output/test-results/"; |
72 | | - EnsureDirectoryExists(output); |
73 | | - CopyFiles($"./tests/**/TestResults/*.trx", output); |
74 | | - |
75 | | - if (failed > 0) |
76 | | - throw new Exception($"{failed} tests have failed."); |
| 79 | + DotNetTest("./scripts/SkiaSharp.Extended-Test.slnf", new DotNetTestSettings |
| 80 | + { |
| 81 | + Configuration = CONFIGURATION, |
| 82 | + Loggers = ["trx"], |
| 83 | + ResultsDirectory = OUTPUT_ROOT.Combine("test-results"), |
| 84 | + MSBuildSettings = new DotNetMSBuildSettings() |
| 85 | + .EnableBinaryLogger(OUTPUT_ROOT.Combine("binlogs").CombineWithFilePath("test.binlog").FullPath), |
| 86 | + ArgumentCustomization = AppendForwardingLogger |
| 87 | + }); |
77 | 88 | }); |
78 | 89 |
|
79 | 90 | Task("Default") |
|
0 commit comments