Skip to content

Commit e943f4a

Browse files
authored
Update to the new 1ES MicroBuild templates (#314)
1 parent cd0933a commit e943f4a

File tree

16 files changed

+161
-145
lines changed

16 files changed

+161
-145
lines changed

.config/dotnet-tools.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "4.0.0",
6+
"version": "5.0.0",
77
"commands": [
88
"dotnet-cake"
9-
]
9+
],
10+
"rollForward": false
1011
}
1112
}
1213
}

.config/tsaoptions.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2+
"codebaseName": "skiasharp.extended_main",
3+
"notificationAliases": [
4+
5+
],
26
"instanceUrl": "https://devdiv.visualstudio.com/",
3-
"template": "TFSDEVDIV",
4-
"projectName": "DEVDIV",
5-
"areaPath": "DevDiv\\VS Client - Runtime SDKs\\SkiaSharp",
7+
"projectName": "DevDiv",
8+
"areaPath": "DevDiv\\.NET MAUI\\SkiaSharp",
69
"iterationPath": "DevDiv",
7-
"notificationAliases": [ "[email protected]" ],
8-
"repositoryName": "SkiaSharp.Extended",
9-
"codebaseName": "SkiaSharp.Extended"
10-
}
10+
"allTools": true
11+
}

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
# Repository-specific files
77
output/
8-
tools/*
9-
!tools/packages.config
108

119
# User-specific files
1210
*.suo

.vscode/launch.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

azure-pipelines-public.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ jobs:
3636
- template: /scripts/azure-pipelines-steps-prepare.yml@self
3737
- pwsh: dotnet cake --target=build
3838
displayName: Build everything
39-
env:
40-
JavaSdkDirectory: $(JAVA_HOME)
4139
- publish: output
4240
artifact: build
4341
condition: always()
@@ -49,8 +47,6 @@ jobs:
4947
- template: /scripts/azure-pipelines-steps-prepare.yml@self
5048
- pwsh: dotnet cake --target=pack
5149
displayName: Pack NuGet packages
52-
env:
53-
JavaSdkDirectory: $(JAVA_HOME)
5450
- publish: output
5551
artifact: pack
5652
condition: always()
@@ -62,8 +58,6 @@ jobs:
6258
- template: /scripts/azure-pipelines-steps-prepare.yml@self
6359
- pwsh: dotnet cake --target=test
6460
displayName: Run tests
65-
env:
66-
JavaSdkDirectory: $(JAVA_HOME)
6761
- task: PublishTestResults@2
6862
condition: always()
6963
inputs:

azure-pipelines.yml

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,59 @@ trigger: none
33
pr: none
44

55
parameters:
6-
- name: runCompliance
7-
displayName: 'Run post-build compliance tasks (such as API Scan)'
8-
type: boolean
9-
default: false
106
- name: buildAgent
117
displayName: 'The build agent to use'
128
type: object
139
default:
1410
name: Maui-1ESPT
1511
image: 1ESPT-Windows2022
1612
os: windows
13+
- name: runApiScan
14+
displayName: 'Run API Scan'
15+
type: boolean
16+
default: false
17+
- name: forceRealSigning
18+
displayName: 'Ignore all logic and force Real signing on binaries'
19+
type: boolean
20+
default: false
1721

1822
variables:
1923
- template: /scripts/azure-pipelines-variables.yml@self
2024

2125
resources:
2226
repositories:
23-
- repository: internal-templates
24-
type: github
25-
name: xamarin/yaml-templates
26-
endpoint: xamarin
27+
- repository: yaml-templates
28+
type: git
29+
name: DevDiv/Xamarin.yaml-templates
2730
ref: refs/heads/main
28-
- repository: 1ESPipelineTemplates
31+
- repository: 1ESTemplates
2932
type: git
30-
name: 1ESPipelineTemplates/1ESPipelineTemplates
31-
ref: refs/tags/release
33+
name: 1ESPipelineTemplates/MicroBuildTemplate
3234

3335
extends:
34-
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
36+
template: azure-pipelines/MicroBuild.1ES.Official.yml@1ESTemplates
3537
parameters:
3638
pool: ${{ parameters.buildAgent }}
3739
customBuildTags:
3840
- ES365AIMigrationTooling
41+
sdl:
42+
sourceRepositoriesToScan:
43+
exclude:
44+
- repository: yaml-templates
45+
binskim:
46+
enabled: true
47+
break: false
48+
codeInspector:
49+
enabled: true
50+
credscan:
51+
enabled: true
52+
policheck:
53+
enabled: true
54+
spotBugs:
55+
enabled: false
56+
tsa:
57+
enabled: true
58+
configFile: $(Build.SourcesDirectory)/.config/tsaoptions.json
3959
stages:
4060

4161
- stage: build
@@ -44,20 +64,6 @@ extends:
4464
- job: build
4565
displayName: Build
4666
templateContext:
47-
sdl:
48-
apiscan:
49-
enabled: true
50-
binskim:
51-
enabled: true
52-
break: false
53-
codeInspector:
54-
enabled: true
55-
credscan:
56-
enabled: true
57-
policheck:
58-
enabled: true
59-
spotBugs:
60-
enabled: false
6167
outputParentDirectory: 'output'
6268
outputs:
6369
- output: pipelineArtifact
@@ -68,28 +74,28 @@ extends:
6874
- template: /scripts/azure-pipelines-steps-prepare.yml@self
6975
- pwsh: dotnet cake --target=pack
7076
displayName: Pack NuGets
71-
env:
72-
JavaSdkDirectory: $(JAVA_HOME)
7377

7478
- stage: signing
7579
displayName: Sign NuGets
7680
dependsOn: build
7781
jobs:
78-
- template: sign-artifacts/jobs/v2.yml@internal-templates
82+
- template: sign-artifacts/jobs/v4.yml@yaml-templates
7983
parameters:
8084
usePipelineArtifactTasks: true
81-
use1ESTemplate: true
82-
${{ if or( eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') ) }}:
85+
checkoutType: 'self'
86+
${{ if or(eq(parameters.forceRealSigning, 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')) }}:
8387
signType: 'Real'
8488
${{ else }}:
8589
signType: 'Test'
8690

87-
- ${{ if or( eq(variables['Build.Reason'], 'Schedule'), parameters.runCompliance ) }}:
88-
- template: security/apiscan/v0.yml@internal-templates
91+
- ${{ if or(eq(parameters.runApiScan, 'true'), and(eq(variables['Build.Reason'], 'Schedule'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))) }}:
92+
- template: security/apiscan/v0.yml@yaml-templates
8993
parameters:
9094
windowsPoolName: ${{ parameters.buildAgent.name }}
9195
windowsImageOverride: ${{ parameters.buildAgent.image }}
9296
timeoutInMinutes: 480
97+
tsaConfigFile: $(Build.SourcesDirectory)/.config/tsaoptions.json
98+
tsaUploadEnabled: true
9399
stageDependsOn:
94100
- build
95101
scanArtifacts:

build.cake

Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,90 @@
11
var TARGET = Argument("t", Argument("target", "Default"));
22
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+
}
732

833
Task("build")
934
.Does(() =>
1035
{
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+
});
1943
});
2044

2145
Task("pack")
2246
.Does(() =>
2347
{
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+
});
3256

3357
var preview = PREVIEW_LABEL;
34-
if (!string.IsNullOrEmpty (BUILD_NUMBER)) {
58+
if (!string.IsNullOrEmpty(BUILD_NUMBER))
59+
{
3560
preview += $".{BUILD_NUMBER}";
3661
}
3762

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+
});
4772

4873
CopyFileToDirectory("./source/SignList.xml", "./output/nugets");
4974
});
5075

5176
Task("test")
5277
.Does(() =>
5378
{
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+
});
7788
});
7889

7990
Task("Default")

samples/SkiaSharpDemo/SkiaSharpDemo.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
<ApplicationVersion>1</ApplicationVersion>
2424

2525
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
26-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
2727
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
2828
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
2929
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
3030
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
32+
<!-- Skip Xcode version checks -->
33+
<ValidateXcodeVersion>false</ValidateXcodeVersion>
3134
</PropertyGroup>
3235

3336
<ItemGroup>

SkiaSharp.Extended-Pack.slnf renamed to scripts/SkiaSharp.Extended-Pack.slnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"solution": {
3-
"path": "SkiaSharp.Extended.sln",
3+
"path": "..\\SkiaSharp.Extended.sln",
44
"projects": [
55
"source\\SkiaSharp.Extended.UI.Maui\\SkiaSharp.Extended.UI.Maui.csproj",
66
"source\\SkiaSharp.Extended\\SkiaSharp.Extended.csproj",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"solution": {
3+
"path": "..\\SkiaSharp.Extended.sln",
4+
"projects": [
5+
"source\\SkiaSharp.Extended.UI.Maui\\SkiaSharp.Extended.UI.Maui.csproj",
6+
"source\\SkiaSharp.Extended\\SkiaSharp.Extended.csproj",
7+
"tests\\SkiaSharp.Extended.Tests\\SkiaSharp.Extended.Tests.csproj",
8+
"tests\\SkiaSharp.Extended.UI.Maui.Tests\\SkiaSharp.Extended.UI.Maui.Tests.csproj",
9+
]
10+
}
11+
}

0 commit comments

Comments
 (0)