-
-
Save ThomasPe/8d27159cbb5d1c5c7ba6bc64e1f4be65 to your computer and use it in GitHub Desktop.
Build, sign and host UWP App on Azure BLOB Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- main | |
pool: | |
vmImage: 'windows-latest' | |
variables: | |
- group: certificate | |
- name: solution | |
value: '**/*.sln' | |
- name: buildPlatform | |
value: 'x64' | |
- name: buildConfiguration | |
value: 'Release' | |
- name: appxPackageDir | |
value: '$(build.artifactStagingDirectory)\AppxPackages\\' | |
steps: | |
- task: NuGetToolInstaller@1 | |
- task: NuGetCommand@2 | |
inputs: | |
restoreSolution: '$(solution)' | |
- task: DownloadSecureFile@1 | |
name: mySecureFile | |
displayName: 'Get the pfx file certificat' | |
inputs: | |
secureFile: '$(signingCert.secureFilePath)' | |
- task: PowerShell@2 | |
inputs: | |
targetType: 'inline' | |
script: | | |
Write-Host "Start adding the PFX file to the certificate store." | |
$pfxpath = '$(mySecureFile.secureFilePath)' | |
$password = '$(signingCert.password)' | |
Add-Type -AssemblyName System.Security | |
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 | |
$cert.Import($pfxpath, $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() | |
- task: VSBuild@1 | |
inputs: | |
platform: 'x64' | |
solution: '$(solution)' | |
configuration: '$(buildConfiguration)' | |
msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" | |
/p:AppxPackageDir="$(appxPackageDir)" | |
/p:AppxBundle=Always | |
/p:UapAppxPackageBuildMode=SideLoadOnly | |
/p:AppxPackageSigningEnabled=true | |
/p:PackageCertificateThumbprint="$(signingCert.thumbprint)" | |
/p:PackageCertificateKeyFile="$(mySecureFile.secureFilePath)" | |
/p:PackageCertificatePassword="$(signingCert.password)"' | |
- task: CopyFiles@2 | |
displayName: 'Copy Files to: $(build.artifactstagingdirectory)' | |
inputs: | |
SourceFolder: '$(system.defaultworkingdirectory)' | |
Contents: '**\bin\$(BuildConfiguration)\**' | |
TargetFolder: '$(build.artifactstagingdirectory)' | |
- task: AzureCLI@2 | |
displayName: 'Clear Static website' | |
inputs: | |
azureSubscription: 'MySubscription' | |
scriptType: 'bash' | |
scriptLocation: 'inlineScript' | |
inlineScript: 'az storage blob delete-batch --account-name storageaccountname --source "\$web"' | |
- task: AzureCLI@2 | |
displayName: 'Upload' | |
inputs: | |
azureSubscription: 'MySubscription' | |
scriptType: 'bash' | |
scriptLocation: 'inlineScript' | |
inlineScript: 'az storage blob upload-batch --account-name storageaccountname --destination "\$web" --source ''$(build.artifactstagingdirectory)/AppxPackages'' --overwrite' | |
- task: PublishBuildArtifacts@1 | |
displayName: 'Publish Artifact: drop' | |
inputs: | |
PathtoPublish: '$(build.artifactstagingdirectory)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment