-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
105 lines (93 loc) · 4.18 KB
/
azure-pipelines.yml
File metadata and controls
105 lines (93 loc) · 4.18 KB
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
pool:
vmImage: 'windows-2022'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
major: 1
minor: 1
revision: $[counter('rev', 0)]
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- powershell: |
$sourceBranch = "$(Build.SourceBranch)"
$branchLabel = "none"
if ($sourceBranch.endswith("master"))
{
$branchLabel = "Main"
}
elseif ($sourceBranch.endswith("merge"))
{
$branchLabel = "$(System.PullRequest.SourceBranch)"
}
else
{
$branchLabel = "$(Build.SourceBranch)"
$branchLabel = $branchLabel.substring($branchLabel.lastIndexOf('/') + 1)
}
Write-Host "##vso[task.setvariable variable=branchLabel;]$branchLabel"
if($branchLabel -eq 'Main')
{
$packageName = "Planomatic_$(major).$(minor).$(revision).0.msix"
}
else
{
$packageName = "Planomatic_" + $branchLabel
$packageName += "_$(major).$(minor).$(revision).0.msix"
}
Write-Host "##vso[task.setvariable variable=packageName;]$packageName"
displayName: 'Setup Branch Label and Package Name'
- powershell: |
[Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")
$path = "PlanomaticPackage/Package.appxmanifest"
$doc = [System.Xml.Linq.XDocument]::Load($path)
$xIdentity = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity"
$xProperties = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Properties"
$xDisplayName = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}DisplayName"
$xApplications = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Applications"
$xApplication = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Application"
$xVisualElements = [System.Xml.Linq.XName]"{http://schemas.microsoft.com/appx/manifest/uap/windows10}VisualElements"
$doc.Root.Element($xIdentity).Attribute("Version").Value = "$(major).$(minor).$(revision).0"
if ("$(branchLabel)" -ne 'Main')
{
$doc.Root.Element($xIdentity).Attribute("Name").Value = "Planomatic$(branchLabel)"
$doc.Root.Element($xProperties).Element($xDisplayName).Value = "Planomatic_$(branchLabel)"
$doc.Root.Element($xApplications).Element($xApplication).Element($xVisualElements).Attribute("DisplayName").Value = "Planomatic_$(branchLabel)"
}
$doc.Save($path)
displayName: 'Setting Version and Branch Name in Package Manifest'
- powershell: |
((Get-Content -path PlanoWeb\plano.appinstaller -Raw) -replace '<msix_version>','$(major).$(minor).$(revision).0' `
-replace '<msix_name>','$(packageName)' `
-replace '<appinstaller_file>','plano_$(branchLabel).appinstaller' `
-replace '<name>','Planomatic$(branchLabel)') `
| Set-Content -Path $(Build.ArtifactStagingDirectory)\plano_$(branchLabel).appinstaller
displayName: 'Updating Appinstaller file'
- task: MSBuild@1
inputs:
solution: $(solution)
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: '/p:AppxPackageOutput=$(Build.ArtifactStagingDirectory)\$(packageName) /p:AppxPackageSigningEnabled=false'
displayName: 'Build and Package'
- task: DownloadSecureFile@1
inputs:
secureFile: 'certificate.pfx'
displayName: 'Download Secure PFX File'
- script: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool"
sign /fd SHA256 /f $(Agent.TempDirectory)/certificate.pfx /p 1234 $(Build.ArtifactStagingDirectory)/$(packageName)'
displayName: 'Sign MSIX Package'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
# Comment out the copy out to web step for now
#- task: AzureFileCopy@4
# inputs:
# SourcePath: '$(Build.ArtifactStagingDirectory)\*'
# azureSubscription: 'planostorage'
# Destination: 'AzureBlob'
# storage: 'planomaticstorage'
# ContainerName: '$web'
# targetPath: 'branch'