Yes, you can use PowerShell in your custom build task.
You need to edit this section in task.json
:
"execution": {
"PowerShell3": {
"target": "ps-script.ps1",
"workingDirectory": "$(currentDirectory)"
}
}
And you need to install the VstsTaskSdk
Powershell Module:
- open up Powershell
- navigate to the
root/buildtask
of directory of your extension
- execute
mkdir ps_modules
and then navigate into the new directory
- your
pwd
should read root/buildtask/ps_modules
- execute
Save-Module -Name VstsTaskSdk -Path .
which will save the module to disk.
- Flatten the directory structure by removing the version number. For example you will have a path of
root/buildtask/ps_modules/VstsTaskSdk/0.10.0/*
which should now read root/buildtask/ps_modules/VstsTaskSdk/*
A full tutorial exist here.
You can also see an example for custom task with PS on this GitHub repo.
Note: it works only in windows machines.