Question:
I am using simple PowerShell script in TeamCity Builds.
It requires System.IO.Compression.FileSystem
and the agent has .NET 4.5.2 installed. Below are the .NET frameworks installed
1 2 3 4 5 6 7 8 9 10 11 |
PSChildName Version Release Product ----------- ------- ------- ------- v2.0.50727 2.0.50727.5420 v3.0 3.0.30729.5420 Windows Communic... 3.0.4506.5420 Windows Presenta... 3.0.6920.5011 v3.5 3.5.30729.5420 Client 4.5.51209 379893 4.5.2 Full 4.5.51209 379893 4.5.2 Client 4.0.0.0 |
The PowerShell script has following line
1 2 3 |
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem"); Add-Type -AssemblyName System.IO.Compression.FileSystem |
On the second line, the execution fails with error
1 2 3 4 5 6 |
Add-Type : Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found. At C:\BuildAgent\someFile.ps1:104 char:13 + Add-Type <<<< -AssemblyName System.IO.Compression.FileSystem + CategoryInfo : ObjectNotFound: (System.IO.Compression.FileSystem:String) [Add-Type], Exception + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand |
Strange, but I expected that with .NET 4.5.2
, PowerShell should be able to load assembly from GAC
Any help will be appreciated
Answer:
Try to load particular DLL instead:
1 2 |
Add-Type -Path C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IO.Compression.FileSystem\v4.0_4.0.0.0__b77a5c561934e089\System.IO.Compression.FileSystem.dll |