forked from zhuxb711/RX-Explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
250 lines (210 loc) · 10.6 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
# Universal Windows Platform
# Build a Universal Windows Platform project using Visual Studio.
# Add steps that test and distribute an app, save build artifacts, and more:
# https://aka.ms/yaml
pr:
autoCancel: true
branches:
include:
- master
variables:
- group: UWP-PipeLineVariable
- name: BuildProject
value: "Package"
- name: Solution
value: "**/*.sln"
- name: BuildPlatform
value: "x64|ARM64"
- name: BuildConfiguration
value: "Release"
- name: SideloadBuildPublishLocation
value: '$(Build.ArtifactStagingDirectory)\Sideload\\'
- name: CIBuildPublishLocation
value: '$(Build.ArtifactStagingDirectory)\CI\\'
- name: TempDirectory
value: "$(Agent.TempDirectory)"
- name: TargetWindowsSDKVersion
value: "10.0.22621.1"
- name: TargetWindowsSDKInstallerUrl # Windows SDK 10.22621.1
value: "https://download.microsoft.com/download/f/6/7/f673df4b-4df9-4e1c-b6ce-2e6b4236c802/windowssdk/winsdksetup.exe"
- name: WindowsSDKBaseLocation
value: '$(Agent.TempDirectory)\WinSDK'
- name: WindowsSDKInstallerLocation
value: '$(Agent.TempDirectory)\WinSDK\winsdksetup.exe'
jobs:
- job: CIBuild
displayName: "Build CI Application"
timeoutInMinutes: 0
pool:
vmImage: "windows-latest"
steps:
# UseDotNet@2 task to install .Net 7 environment because Azure Pipeline would not prepare the SDK we needed.
# Maybe we could remove this task once Azure Pipeline install .Net 7 SDK by default.
- task: UseDotNet@2
displayName: "Install .Net 7 SDK"
inputs:
packageType: sdk
installationPath: $(TempDirectory)
version: 7.x
# Detect if Windows SDK is installed as requirement. If not install the SDK as requirement
- task: PowerShell@2
displayName: "Download And Install Latest Windows SDK As Requirement"
inputs:
targetType: "inline"
script: |
try {
$CurrentSDKVersion = $(Get-Item "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0").GetValue("ProductVersion")
} catch {
$CurrentSDKVersion = ''
Write-Host "Detect the installed Windows SDK failed. Installed Windows SDK Version is aligned with TargetSDKVersion. Skipping this check"
}
if ($CurrentSDKVersion -ne '') {
if($CurrentSDKVersion -lt ($TargetWindowsSDKVersion)) {
New-Item -Path $(WindowsSDKBaseLocation) -ItemType Directory
Write-Host "Start downloading Windows SDK Installer using BitsTransfer..."
Start-BitsTransfer -Source $(TargetWindowsSDKInstallerUrl) -Destination $(WindowsSDKInstallerLocation) -Description "Downloading Windows SDK..."
Write-Host "Windows SDK Installer download completed"
Write-Host "Start installing Windows SDK..."
Start-Process $(WindowsSDKInstallerLocation) -ArgumentList "/q" -Wait
Write-Host "Windows SDK installed completed"
} else {
Write-Host "Windows SDK meet the requeirement, skipping this task and no need to install the SDK"
}
}
- task: DownloadSecureFile@1
name: secureFile
displayName: "Download Publish Certificate"
inputs:
secureFile: "$(signingCert.secureFileName)"
- task: PowerShell@2
displayName: "Import Publish Certificate File"
inputs:
targetType: "inline"
script: |
Write-Host "Start importing the certificate file"
Add-Type -AssemblyName System.Security
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Cert.Import('$(secureFile.secureFilePath)', '$(signingCert.password)', [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet)
$Store = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "MY", CurrentUser
$Store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$Store.Add($Cert)
$Store.Close()
Write-Host "Certificate file was imported successfully"
- task: PowerShell@2
displayName: "Add AppCenter Secret Value"
inputs:
targetType: "inline"
script: |
Write-Host "Start adding AppCenter Secret Value."
$AppCenterSecret = '$(appCenter.secret)'
$TargetPath = '$(Build.SourcesDirectory)\RX_Explorer\View\ExtendedSplash.xaml.cs'
$TargetContent = Get-Content -Path $TargetPath
$TargetContent -Replace '<RX-Explorer-AppCenter-Secret-Value>', $AppCenterSecret | Set-Content -Path $TargetPath -Encoding UTF8
Write-Host "AppCenter Secret Value was added successfully"
- task: NuGetToolInstaller@1
displayName: "Install Nuget ToolSet"
- task: NuGetCommand@2
displayName: "Restore Nuget Packages On Solution"
inputs:
restoreSolution: "$(Solution)"
- task: VSBuild@1
displayName: "Build RX-Explorer Project"
inputs:
solution: "$(Solution)"
msbuildArgs: '/t:$(BuildProject):Rebuild /p:PreferredToolArchitecture="x64" /p:AppxBundlePlatforms="$(BuildPlatform)" /p:AppxPackageDir="$(CIBuildPublishLocation)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=CI /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="$(signingCert.thumbprint)" /p:PackageCertificateKeyFile="$(secureFile.secureFilePath)" /p:PackageCertificatePassword="$(signingCert.password)"'
configuration: "$(BuildConfiguration)"
clean: true
msbuildArchitecture: "x64"
- task: PublishBuildArtifacts@1
displayName: "Publish And Upload Artifact"
inputs:
ArtifactName: "CIBuild"
PathtoPublish: "$(CIBuildPublishLocation)"
- job: SideLoadBuild
displayName: "Build Sideload Application"
timeoutInMinutes: 0
pool:
vmImage: "windows-latest"
steps:
# UseDotNet@2 task to install .Net 7 environment because Azure Pipeline would not prepare the SDK we needed.
# Maybe we could remove this task once Azure Pipeline install .Net 7 SDK by default.
- task: UseDotNet@2
displayName: "Install .Net 7 SDK"
inputs:
packageType: sdk
installationPath: $(TempDirectory)
version: 7.x
# Detect if Windows SDK is installed as requirement. If not install the SDK as requirement
- task: PowerShell@2
displayName: "Download And Install Latest Windows SDK As Requirement"
inputs:
targetType: "inline"
script: |
try {
$CurrentSDKVersion = $(Get-Item "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0").GetValue("ProductVersion")
} catch {
$CurrentSDKVersion = ''
Write-Host "Detect the installed Windows SDK failed. Installed Windows SDK Version is aligned with TargetSDKVersion. Skipping this check"
}
if ($CurrentSDKVersion -ne '') {
if($CurrentSDKVersion -lt ($TargetWindowsSDKVersion)) {
New-Item -Path $(WindowsSDKBaseLocation) -ItemType Directory
Write-Host "Start downloading Windows SDK Installer using BitsTransfer..."
Start-BitsTransfer -Source $(TargetWindowsSDKInstallerUrl) -Destination $(WindowsSDKInstallerLocation) -Description "Downloading Windows SDK..."
Write-Host "Windows SDK Installer download completed"
Write-Host "Start installing Windows SDK..."
Start-Process $(WindowsSDKInstallerLocation) -ArgumentList "/q" -Wait
Write-Host "Windows SDK installed completed"
} else {
Write-Host "Windows SDK meet the requeirement, skipping this task and no need to install the SDK"
}
}
- task: DownloadSecureFile@1
name: secureFile
displayName: "Download Publish Certificate"
inputs:
secureFile: "$(signingCert.secureFileName)"
- task: PowerShell@2
displayName: "Import Publish Certificate File"
inputs:
targetType: "inline"
script: |
Write-Host "Start importing the certificate file"
Add-Type -AssemblyName System.Security
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Cert.Import('$(secureFile.secureFilePath)', '$(signingCert.password)', [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet)
$Store = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "MY", CurrentUser
$Store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$Store.Add($Cert)
$Store.Close()
Write-Host "Certificate file was imported successfully"
- task: PowerShell@2
displayName: "Add AppCenter Secret Value"
inputs:
targetType: "inline"
script: |
Write-Host "Start adding AppCenter Secret Value."
$AppCenterSecret = '$(appCenter.secret)'
$TargetPath = '$(Build.SourcesDirectory)\RX_Explorer\View\ExtendedSplash.xaml.cs'
$TargetContent = Get-Content -Path $TargetPath
$TargetContent -Replace '<RX-Explorer-AppCenter-Secret-Value>', $AppCenterSecret | Set-Content -Path $TargetPath -Encoding UTF8
Write-Host "AppCenter Secret Value was added successfully"
- task: NuGetToolInstaller@1
displayName: "Install Nuget ToolSet"
- task: NuGetCommand@2
displayName: "Restore Nuget Packages On Solution"
inputs:
restoreSolution: "$(Solution)"
- task: VSBuild@1
displayName: "Build RX-Explorer Project"
inputs:
solution: "$(Solution)"
msbuildArgs: '/t:$(BuildProject):Rebuild /p:PreferredToolArchitecture="x64" /p:AppxBundlePlatforms="$(BuildPlatform)" /p:AppxPackageDir="$(SideloadBuildPublishLocation)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="$(signingCert.thumbprint)" /p:PackageCertificateKeyFile="$(secureFile.secureFilePath)" /p:PackageCertificatePassword="$(signingCert.password)"'
configuration: "$(BuildConfiguration)"
clean: true
msbuildArchitecture: "x64"
- task: PublishBuildArtifacts@1
displayName: "Publish And Upload Artifact"
inputs:
ArtifactName: "SideloadBuild"
PathtoPublish: "$(SideloadBuildPublishLocation)"