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.
This commit is contained in:
Matt Graeber
2013-08-16 06:28:47 -04:00
parent 98be62a03a
commit 9577a4e2c2
+2 -4
View File
@@ -525,12 +525,10 @@ PROCESS {
}
"@
$location = [PsObject].Assembly.Location
$compileParams = New-Object System.CodeDom.Compiler.CompilerParameters
$assemblyRange = @("System.dll", $location)
$compileParams.ReferencedAssemblies.AddRange($assemblyRange)
$compileParams.ReferencedAssemblies.AddRange(@('System.dll', 'mscorlib.dll'))
$compileParams.GenerateInMemory = $True
Add-Type -TypeDefinition $code -passthru -WarningAction SilentlyContinue | Out-Null
Add-Type -TypeDefinition $code -CompilerParameters $compileParams -PassThru -WarningAction SilentlyContinue | Out-Null
}
function Get-DelegateType