-
-
Notifications
You must be signed in to change notification settings - Fork 221
/
azure-pipelines.yml
164 lines (140 loc) · 5.35 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
name: $(Build.DefinitionName) $(date:yyyyMMdd)$(rev:.r)
stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: windows-2022
variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'release'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.0.201'
- script: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" -version'
displayName: 'log msbuild version'
- script: 'dotnet --info'
displayName: 'log dotnet version'
- task: PowerShell@1
displayName: 'Set build version'
inputs:
scriptType: inlineScript
inlineScript: |
(new-object Net.WebClient).DownloadString("https://raw.github.com/tom-englert/BuildScripts/master/BuildScripts.ps1") | iex
$version = Project-SetVersion "src\Directory.Build.props"
$version | Build-AppendVersionToBuildNumber
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: NuGetToolInstaller@1
inputs:
versionSpec: '6.7.0'
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
- task: MSBuild@1
displayName: 'Build solution'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
logProjectEvents: true
createLogFile: true
- task: MSBuild@1
displayName: 'Publish Click Once'
inputs:
solution: 'src\ResxManager\ResxManager.csproj'
platform: AnyCPU
configuration: release
msbuildArguments: '/target:publish'
logProjectEvents: true
createLogFile: true
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)\src\Deploy'
Contents: '*.*'
TargetFolder: '$(build.artifactstagingdirectory)'
CleanTargetFolder: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: BuildPackages'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: BuildPackages
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: signing scripts'
inputs:
PathtoPublish: 'signing'
ArtifactName: signing
- stage: CodeSign
dependsOn: Build
condition: and(succeeded('Build'), ne(variables['build.reason'], 'PullRequest'))
jobs:
- job: CodeSign
displayName: Code Signing
pool:
vmImage: windows-latest # Code signing must run on a Windows agent for Authenticode signing (dll/exe)
steps:
# Retreive unsigned artifacts and file list
- download: current
artifact: signing
displayName: Download signing file list
- download: current
artifact: BuildPackages
displayName: Download build artifacts
- task: CmdLine@2
displayName: "AntiMalware Scan"
inputs:
script: |
Dir "$(Pipeline.Workspace)\BuildPackages"
"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "$(Pipeline.Workspace)\BuildPackages"
failOnStderr: true
# Install the code signing tool
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . sign --version 0.9.1-beta.23530.1
displayName: Install SignTool tool
- pwsh: Rename-Item -Path "$(Pipeline.Workspace)\BuildPackages\Publish.zip" -NewName Publish.clickonce
displayName: 'Rename click-once archive to .clickonce'
- pwsh: |
.\sign code azure-key-vault `
"**/*.*" `
--base-directory "$(Pipeline.Workspace)\BuildPackages" `
--file-list "$(Pipeline.Workspace)\signing\filelist.txt" `
--publisher-name "tom-englert" `
--description "ResX Resource Manager" `
--description-url "https://github.com/dotnet/ResXResourceManager" `
--azure-key-vault-tenant-id "$(SignTenantId)" `
--azure-key-vault-client-id "$(SignClientId)" `
--azure-key-vault-client-secret "$(SignClientSecret2)" `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)"
displayName: Sign packages
- pwsh: Rename-Item -Path "$(Pipeline.Workspace)\BuildPackages\Publish.clickonce" -NewName Publish.zip
displayName: 'Rename click-once archive back to .zip'
# Publish the signed packages
- publish: $(Pipeline.Workspace)/BuildPackages
displayName: Publish Signed Packages
artifact: SignedPackages
- stage: Upload
dependsOn: CodeSign
jobs:
- job: Upload
displayName: Upload to VSIX gallery
pool:
vmImage: windows-latest
steps:
- download: current
artifact: SignedPackages
displayName: Download build artifacts
- task: PowerShell@1
displayName: 'Publish to vsix-gallery'
inputs:
scriptType: inlineScript
inlineScript: |
(new-object Net.WebClient).DownloadString("https://raw.github.com/tom-englert/BuildScripts/master/BuildScripts.ps1") | iex
Vsix-PublishToGallery "$(Pipeline.Workspace)\SignedPackages\ResXManager.Vsix.vsix"
continueOnError: true