forked from OData/ODataConnectedService
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
207 lines (182 loc) · 7.46 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
trigger:
- master
name: 'ODataConnectedService'
pool:
vmImage: 'windows-latest'
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
connectedServiceDir: '$(Build.SourcesDirectory)'
sln: '$(connectedServiceDir)\ODataConnectedService.sln'
testSln: '$(connectedServiceDir)\ODataConnectedService.Tests.sln'
signigConfigPath: '$(connectedServiceDir)\configs'
signingConfigFiles: '*.*'
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'
stages:
- stage: Build
jobs:
- job: Build
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)
- 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'
# 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
# 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'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - VSIXStaging'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\VSIXStaging'
ArtifactName: 'VSIXStaging'
publishLocation: 'Container'
- publish: configs
displayName: Publish Signing Scripts
artifact: configs
- stage: CodeSign
condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
jobs:
- deployment: CodeSign
displayName: Code Signing
pool:
vmImage: windows-latest
environment: Code Sign - Approvals
variables:
- group: Code Signing
strategy:
runOnce:
deploy:
steps:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . SignClient
displayName: Install SignTool tool
- pwsh: |
.\SignClient "Sign" `
--baseDirectory "$(Pipeline.Workspace)/VSIXStaging" `
--input "**/*.dll" `
--config "$(Pipeline.Workspace)/configs/SignClient.json" `
--filelist "$(Pipeline.Workspace)/configs/filelist.txt" `
--user "$(SignClientUser)" `
--secret "$(SignClientSecret)" `
--name "OData Connected Service" `
--description "OData Connected Service" `
--descriptionUrl "https://github.com/OData/ODataConnectedService"
displayName: Code signing - DLL
# repackage the vsix that now contains the signed assembly
- task: ArchiveFiles@2
displayName: 'Archive files - Pack VSIX'
inputs:
rootFolderOrFile: '$(Pipeline.Workspace)\VSIXStaging'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)\VSIX\$(vsixFile)'
replaceExistingArchive: true
# publish the vsix as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: VSIX'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/VSIX'
ArtifactName: 'VSIX'
publishLocation: 'Container'
- pwsh: |
.\SignClient "Sign" `
--baseDirectory "$(Build.ArtifactStagingDirectory)/VSIX" `
--input "$(vsixFile)" `
--config "$(Pipeline.Workspace)/configs/SignClient.json" `
--filelist "$(Pipeline.Workspace)/configs/filelist.txt" `
--user "$(SignClientUser)" `
--secret "$(SignClientSecret)" `
--name "OData Connected Service" `
--description "OData Connected Service" `
--descriptionUrl "https://github.com/OData/ODataConnectedService"
displayName: Code signing - VSIX
# publish the vsix as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: SignedVSIX'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/VSIX'
ArtifactName: 'SignedVSIX'
publishLocation: 'Container'