Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit 9577a4e

Browse files
committed
Compiler parameters were not applied to Add-Type
The compiler parameters were not being applied to Add-Type in Get-PEHeader. Derp. This led to unexpected errors when Visual Studio environment variables were defined.
1 parent 98be62a commit 9577a4e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

PETools/Get-PEHeader.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,10 @@ PROCESS {
525525
}
526526
"@
527527

528-
$location = [PsObject].Assembly.Location
529528
$compileParams = New-Object System.CodeDom.Compiler.CompilerParameters
530-
$assemblyRange = @("System.dll", $location)
531-
$compileParams.ReferencedAssemblies.AddRange($assemblyRange)
529+
$compileParams.ReferencedAssemblies.AddRange(@('System.dll', 'mscorlib.dll'))
532530
$compileParams.GenerateInMemory = $True
533-
Add-Type -TypeDefinition $code -passthru -WarningAction SilentlyContinue | Out-Null
531+
Add-Type -TypeDefinition $code -CompilerParameters $compileParams -PassThru -WarningAction SilentlyContinue | Out-Null
534532
}
535533

536534
function Get-DelegateType

0 commit comments

Comments
 (0)