@kelvintaywl, @mrothstein74
I do remember reading the environment variables page linked, I believe that because it is based on Bash I decided to just try PowerShell commands (our pipeline uses PS scripts not Bash) and see what works - which my method does for windows 2019. Hence, we have a number of jobs which get/set environment variables for use in subsequent steps as it is simple to access them with $env:VAR.
Thanks for the suggestions, I already had implemented some workarounds and I would rather not use Bash. I thought that this was unintended behaviour, given that it does work in the windows 2019 images and PS should update these if each step is a new shell.
I found that for the 2019 image there is a PS profile which refreshes the environment variables in a new shell:
This isn’t the case for the 2022 image (I also checked elsewhere but couldn’t find it):
So perhaps you could add this to the setup in the 2022 image?
This is also related to the other issue in this thread about trx2junit. In our build, we have cached trx2junit so we must add the installation directory to the path variable after we retrieve from cache. Note: we cache to the default 2019 image circleci user directory, even though this is not the same in the 2022 image.
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Users\circleci\.dotnet\tools", [System.EnvironmentVariableTarget]::User)
We also have other steps which add to path like this. This leads to a similar failure as other people were having, as the PS path variable is not updated even if the registry entry is.
I had resorted to simply using the full path here to fix this problem.
It is not a huge issue to workaround, but it would be good if it was supported.
Thanks