-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PowerShellV2 ErrorActionPreference #16048
Comments
Hello @awdavies90, I've investigated your issue. You can set ErrorActionPreference as Default in the task settings and this line will not be added to the ps script. |
Most likely, your version of Azure DevOps Server doesn't include the fix for this task. I think in future versions of the ADO server this feature will be added. Related PR with the fix: #15069 |
Hi @awdavies90 please ping if you have any questions. You can probably build task by yourself and upload it via tfx-cli to your local server, although this is not supported. These task changes will be released with one of the next releases of on-prem server. |
Hi @awdavies90, let me close this issue for now. Feel free to reopen it if you have any additional questions about the PowerShell task. For now, you can upload it to your local server via tfx-cli, as was mentioned |
Question, Bug, or Feature?
Type: Bug
Enter Task Name: PowerShellV2
Environment
Issue Description
The PowerShellV2 task has an option for setting the ErrorActionPreference of a script. This is great but I've noticed that the task adds the
$ErrorActionPreference = '{selectedOption}'
at the beginning of your chosen script or inline script, regardless of whether the script already contains a line where the$ErrorActionPreference
is set.If the $ErrorActionPreference is explicitly being set in a script then it should be honoured and the PSV2 task should not prefix the script itself.
I've also noticed that if a script contains a param block and is used inline, the error action preference line is added above the
param
block which causes the script to fail. With this in mind it would be good to either have the option to not specify an ErrorActionPreference within the task or for the preference line to only be added if the script does not contain one already.P.S. I'm aware that if the above change(s) are made, as I'm currently using on-prem AzDO I'll still have the problem. That's fine, I just wanted to bring it to your attention.
The text was updated successfully, but these errors were encountered: