-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid benign GAC warnings logged by install/uninstall #1984
Comments
Do you have any preference on how to implement it?
We could consider also writing a PowerShell unit test to check if after using the module there are no new errors or warnings in the Windows Event Log. |
It's worth exploring option 1, at a different it could help in different places too. |
I spend a few hours trying the option 1, but there are too many obstacles to make it worth in my opinion. Example problems:
Notable article: https://endjin.com/blog/2020/12/how-to-consume-a-nuget-package-in-powershell Maybe someone else would have more luck... Ported C# snippet to PowerShell (not tested): function Test-Assembly([string] $Path) {
try {
$fs = [System.IO.FileStream]::new($Path, [System.IO.FileMode.Open], [System.IO.FileAccess.Read], [System.IO.FileShare.ReadWrite])
# Try to read CLI metadata from the PE file.
$peReader = [System.Reflection.PortableExecutable.PEReader]::new($fs)
if (-not $peReader.HasMetadata) {
return $false # File does not have CLI metadata.
}
# Check that file has an assembly manifest.
$reader = $peReader.GetMetadataReader()
return $reader.IsAssembly
}
finally {
if ($null -ne $fs) {
$fs.Dispose()
}
if ($null -ne $peReader) {
$fs.Dispose()
}
}
} |
Running the PowerShell install/uninstall ends up logging warning events to the Windows Event Logger that are benign and not actionable by the user:
This issue is a follow-up to #1906
The text was updated successfully, but these errors were encountered: