-
Notifications
You must be signed in to change notification settings - Fork 59
/
azure-pipelines.yml
273 lines (253 loc) · 8.33 KB
/
azure-pipelines.yml
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
trigger:
- master
name: 'ODataConnectedService'
pool:
vmImage: 'windows-latest'
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
connectedServiceDir: '$(Build.SourcesDirectory)\ODataConnectedService'
sln: '$(connectedServiceDir)\ODataConnectedService.sln'
testSln: '$(connectedServiceDir)\ODataConnectedService.Tests.sln'
productBinPath: '$(connectedServiceDir)\src\bin\$(BuildConfiguration)'
productFiles: 'Microsoft.OData.ConnectedService.*?(*.dll|*.config|*.pdb)'
testBinPath: '$(connectedServiceDir)\test\ODataConnectedService.Tests\bin\$(BuildConfiguration)\'
vsixPath: '$(productBinPath)'
vsixFile: 'Microsoft.OData.ConnectedService.vsix'
signingFiles: 'Microsoft.OData.ConnectedService.dll'
mainDll: 'Microsoft.OData.ConnectedService.dll'
testDll: 'ODataConnectedService.Tests.dll'
snExe: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe'
snExe64: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\sn.exe'
steps:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=5.2.0'
- task: NuGetCommand@2
displayName: 'Nuget restore - ODataConnectedService.sln'
inputs:
restoreSolution: '$(sln)'
- task: VSBuild@1
displayName: 'Build solution - ODataConnectedService.sln'
inputs:
solution: '$(sln)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: NuGetCommand@2
displayName: 'Nuget restore tests - ODataConnectedServiceTests.sln'
inputs:
restoreSolution: '$(testSln)'
- task: VSBuild@1
displayName: 'Build tests solution - ODataConnectedServiceTests.sln'
inputs:
solution: '$(testSln)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# because the assemblies are delay-signed, we need to disable
# strong name validation so that the tests may run,
# otherwise our assemblies will fail to load
- task: Powershell@2
displayName: 'Skip strong name validation'
inputs:
targetType: 'inline'
script: |
& "$(snExe)" /Vr $(productBinPath)\$(mainDll)
& "$(snExe64)" /Vr $(productBinPath)\$(mainDll)
& "$(snExe)" /Vr $(testBinPath)\$(testDll)
& "$(snExe64)" /Vr $(testBinPath)\$(testDll)
- task: VSTest@2
displayName: 'Run tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: '$(testBinPath)\$(testDll)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
searchFolder: '$(System.DefaultWorkingDirectory)'
- task: Powershell@2
displayName: 'Re-enable strong name validation'
inputs:
targetType: 'inline'
script: |
& "$(snExe)" /Vu $(productBinPath)\$(mainDll)
& "$(snExe64)" /Vu $(productBinPath)\$(mainDll)
& "$(snExe)" /Vu $(testBinPath)\$(testDll)
& "$(snExe64)" /Vu $(testBinPath)\$(testDll)
# sign the connected service assembly
- task: EsrpCodeSigning@1
displayName: 'ESRP CodeSign - Sign Binaries'
inputs:
ConnectedServiceName: "ESRP CodeSigning - OData"
FolderPath: '$(productBinPath)'
Pattern: '$(mainDll)'
signConfigType: 'inlineSignParams'
inlineOperation: |
[
{
"keyCode": "MSSharedLibSnKey",
"operationSetCode": "StrongNameSign",
"parameters": null,
"toolName": "sn.exe",
"toolVersion": "V4.6.1586.0"
},
{
"keyCode": "MSSharedLibSnKey",
"operationSetCode": "StrongNameVerify",
"parameters": null,
"toolName": "sn.exe",
"toolVersion": "V4.6.1586.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "TestSign"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://test"
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/t \"http://ts4096.gtm.microsoft.com/TSS/AuthenticodeTS\""
}
],
"toolName": "signtool.exe",
"toolVersion": "6.2.9304.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "TestSign"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://test"
},
{
"parameterName": "Append",
"parameterValue": "/AS"
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "FileDigest",
"parameterValue": "/fd sha256"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
],
"toolName": "signtool.exe",
"toolVersion": "6.2.9304.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolVerify",
"parameters": [
{
"parameterName": "VerifyAll",
"parameterValue": "/all"
}
],
"toolName": "signtool.exe",
"toolVersion": "6.2.9304.0"
}
]
SessionTimeout: '60'
MaxConcurrency: '50'
MaxRetryAttempts: '5'
- task: CopyFiles@2
displayName: 'Copy Files - VSIX to Artifacts Staging'
inputs:
SourceFolder: '$(productBinPath)'
Contents: 'Microsoft.OData.ConnectedService.vsix'
TargetFolder: '$(Build.ArtifactStagingDirectory)\VSIX'
- task: CopyFiles@2
displayName: 'Copy Files - Stage Product'
inputs:
SourceFolder: '$(productBinPath)'
Contents: '$(productFiles)'
TargetFolder: '$(Build.ArtifactStagingDirectory)\Product'
# this allows to download the built dll as an artifact (without the vsix)
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - Product'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\Product'
ArtifactName: 'Product'
publishLocation: 'Container'
# extract the vsix so that we can replace the .dll inside the vsix with a signed version
- task: ExtractFiles@1
displayName: 'Extract Files - Unpack VSIX copy'
inputs:
archiveFilePatterns: '$(vsixPath)\$(vsixFile)'
destinationFolder: '$(Build.ArtifactStagingDirectory)\VSIXStaging'
cleanDestinationFolder: true
# replace the .dll inside the vsix with the one that was signed
- task: CopyFiles@2
displayName: 'Copy Files - Signed Binaries to VSIX'
inputs:
SourceFolder: '$(productBinPath)'
Contents: '$(signingFiles)'
TargetFolder: '$(Build.ArtifactStagingDirectory)\VSIXStaging'
OverWrite: true
# repackage the vsix that now contains the signed assembly
- task: ArchiveFiles@2
displayName: 'Archive files - Pack VSIX'
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\VSIXStaging'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\VSIX\$(vsixFile)'
replaceExistingArchive: true
# signed the entire vsix package as well
- task: EsrpCodeSigning@1
displayName: 'ESRP CodeSigning - VSIX Signing'
inputs:
ConnectedServiceName: 'ESRP CodeSigning - OData'
FolderPath: '$(Build.ArtifactStagingDirectory)\VSIX'
Pattern: '$(vsixFile)'
signConfigType: 'inlineSignParams'
inlineOperation: |
[
{
"keyCode": "CP-233016",
"operationSetCode": "OpcSign",
"parameters": [
{
"parameterName": "FileDigest",
"parameterValue": "/fd SHA256"
}
],
"toolName": "Opcsigntool.exe",
"tooVersion": "V6.2.8189.0"
},
{
"keyCode": "CP-233016",
"operationSetCode": "OpcVerify",
"parameters": null,
"toolName": "Opcsigntool.exe",
"tooVersion": "V6.2.8189.0"
}
]
SessionTimeout: '60'
MaxConcurrency: '50'
MaxRetryAttempts: '5'
# publish the vsix as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Public Artifact: VSIX'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/VSIX'
ArtifactName: 'VSIX'
publishLocation: 'Container'