Refer to these steps to do it:
- Add variables and set corresponding values per to configurations (AppDebug, AppHoc, AppRelease)
- Add PowerShell task (Trpe: Inline Script)
Script:
switch ($env:BuildConfiguration)
{
"debug" {Write-Host "##vso[task.setvariable variable=actualSecret;]$env:AppDebug"}
"release" {Write-Host "##vso[task.setvariable variable=actualSecret;]$env:AppRelease"}
"Hoc" {Write-Host "##vso[task.setvariable variable=actualSecret;]$env:AppHoc"}
default {Write-Host "##vso[task.setvariable variable=actualSecret;]$env:AppDebug"}
}
After that set app secret for your app by using actualSecret variable.
Logging Commands
Note: if you are using secret variables, you need to pass them through arguments, for example:
param(
[string]$appRelease
)
Write-Host "##vso[task.setvariable variable=actualSecret;]$appRelease"
Arguments: -appRelease $(appRelease)
BTW, if the build agent doesn't support PowerShell, you can use other task, such as Batch Script.
echo "##vso[task.setvariable variable=sauce]crushed tomatoes"