Using Azure Pipelines with PowerShell to build your UWP Application, using PowerShell to download and install Microsoft Store Services & Microsoft Advertising [UWP][PowerShell]

Delaire Damien
3 min readAug 5, 2019

Back story

One of my application has was using the SDK Microsoft Store Services & Microsoft Advertising but these where not loaded as nuget packages which means that when I was building my application on Azure Pipelines I was getting an error saying that Azure Pipelines could not build my application.

I was getting the following error in Azure:

The issue was that I had installed these two SDKs Microsoft Store Services & Microsoft Advertising on my development machine this means that every time I would build my application (localy) it would pull these two SDKs from my machine.

The First solution I found was to download the SDK using PowerShell.

Here are the steps:

  • this first go in Pipelines
  • click on Builds
  • then click on Edit
  • next under the Tab Task
  • click on the Plus search for PowerShell
  • lastly add the task just before your the build task of your application.

Here are the steps in picture:

Now we need to select our PowerShell file that needs to be executed:

You can also do it in YAML :

steps:
- task: PowerShell@2
displayName: 'PowerShell Script'
inputs:
targetType: filePath
filePath: ./AzurePipelinesPowershell.ps1

More information on using PowerShell in Azure Pipelines:

My PowerShell File

Now we will look at the PowerShell file that will be used to download and install the SDK:

Write-Host "Installing Microsoft Store Services SDK..."
$msiPath = "$($env:USERPROFILE)\AdMediator.msi"
(New-Object Net.WebClient).DownloadFile('https://admediator.gallerycdn.vsassets.io/extensions/admediator/microsoftstoreservicessdk/10.0.5/1550117536112/MicrosoftStoreServicesSDK.msi', $msiPath)
cmd /c start /wait msiexec /i $msiPath /quiet
Write-Host "Installed" -ForegroundColor green
Write-Host "Installing Microsoft Advertising SDK..."
$msiPath = "$($env:USERPROFILE)\AdMediator.msi"
(New-Object Net.WebClient).DownloadFile('https://admediator.gallerycdn.vsassets.io/extensions/admediator/microsoftadvertisingsdk/10.1.00/1548989510766/MicrosoftAdvertisingSDK.msi', $msiPath)
cmd /c start /wait msiexec /i $msiPath /quiet
Write-Host "Installed" -ForegroundColor green

This can be used to download and install any other type of SDK all you need to have the the download URL of the SDK you wish to install.

Now when you queue the build you will have the SDK downloaded and installed during your build as follows:

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Delaire Damien
Delaire Damien

Written by Delaire Damien

Technical Lead on (Windows & Smart TV apps) @Dailymotion, Windows Mobile/ Xbox/ Desktop Lover. Entrepreneur in spirit, I love working on side projects

No responses yet

Write a response