PowerShell/Pwsh environment variables can't process special characters in their names.
What does this MR do?
When environment variables are used with dashes in their names (e.g., UE-LocalDataCachePath) in the runner configuration, PowerShell script generation fails with syntax errors:
Executing "step_script" stage of the job script 00:04
At line:96 char:4
+ $UE-LocalDataCachePath="W:\unreal-cache"
+ ~~~~~~~~~~~~~~~~~~~
Unexpected token '-LocalDataCachePath' in expression or statement.
At line:97 char:8
+ $env:UE-LocalDataCachePath=$UE-LocalDataCachePath
+ ~~~~~~~~~~~~~~~~~~~
Unexpected token '-LocalDataCachePath' in expression or statement.
At line:97 char:31
+ $env:UE-LocalDataCachePath=$UE-LocalDataCachePath
+ ~~~~~~~~~~~~~~~~~~~
Unexpected token '-LocalDataCachePath' in expression or statement.
At line:1 char:3
+ & {
+ ~
Missing closing '}' in statement block or type definition.
At line:96 char:1
+ $UE-LocalDataCachePath="W:\unreal-cache"
The ExportRaw() and Variable() functions in shells/powershell.go generate environment variable assignments using the syntax $env:VARIABLE-NAME, $VARIABLE_NAME which doesn't work for variable names containing special characters like dashes.
In order to fix this, we can use PowerShell's brace syntax ${env:VARIABLE_NAME} , ${VARIABLE_NAME} to properly escape variable names containing dashes and other special characters.
What's the best way to test this MR?
In your config.toml or .gitlab-ci.yml file, create a variable with dash in its name (e.g, New-Variable) and run a job.
What are the relevant issue numbers?
Edited by Pishel