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
Try to load particular DLL instead:
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
I had the exactly same error when running PowerShell script. I guess it was some collision of installed .Net version vs. PowerShell version. In my case helped me just to update PowerShell version to the newest one. Can be found here:
https://www.microsoft.com/en-us/download/details.aspx?id=40855
Try adding this instead (and remove the last portion) Add-Type -AssemblyName System.IO.Compression
LoadWithPartialName()
is not always available; however since LoadWithPartialName()
is already working in your context, you could also use the Location property from the object that is returned to load the DLL.
Add-Type -Path ([Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")).Location;