Fix LIB env var incorrectly set to "System.Collections.DictionaryEntry" (#86436)

This is a fix for a common issue where Ansible is setting the LIB env var to the data type (System.Collections.DictionaryEntry) and not the actual value.

It unfortunately causes downstream issues if you run PowerShell scripts that are affected by the LIB variable not being a search path, but an incorrect string. It causes Add-Type to fail on even the simples call (like `Add-Type "using System;"`
pull/86455/head
Dag Wieers 1 week ago committed by GitHub
parent 6b5301eba7
commit a0b3c7c0d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- "Fix Windows LIB env var corruption (https://github.com/ansible-collections/ansible.windows/issues/297)."

@ -378,7 +378,7 @@ Function Add-CSharpType {
$originalEnv = @{}
try {
'LIB' | ForEach-Object -Process {
$value = Get-Item -LiteralPath "Env:\$_" -ErrorAction SilentlyContinue
$value = (Get-Item -LiteralPath "Env:\$_" -ErrorAction SilentlyContinue).Value
if ($value) {
$originalEnv[$_] = $value
Remove-Item -LiteralPath "Env:\$_"

@ -322,6 +322,7 @@ namespace Namespace12
$env:LIB = "C:\fake\folder\path"
try {
Add-CSharpType -Reference $lib_set
Assert-Equal -actual $env:LIB -expected "C:\fake\folder\path"
}
finally {
Remove-Item -LiteralPath env:\LIB

Loading…
Cancel
Save