I am using Azure DevOps Deployment Group Agent to deploy Azure DevOps Releases Tasks.
Is there a way to utilize Azure DevOps built-in variables, such as $(System.DefaultWorkingDirectory), within PowerShell files when executing them through the Azure DevOps Releases task, akin to their accessibility when using inline PowerShell within the same task?
Background of the issue:
The issue is that when I run Inline Powershell scripts, it works fine. But when I move the same script to a file and try to consume the file from the repo that is located in $(System.DefaultWorkingDirectory) which is the agent host server, it can not find it.
When you run Azure DevOps built-in variables like
$(System.DefaultWorkingDirectory)via a file on an on-prem agent, you need to add$envbefore the variable. Here's an example of how you can access$(System.DefaultWorkingDirectory)in a PowerShell file:$envis valid and also applies to other Azure DevOps build-in variables in PowerShell when running in the same context.