Add-Type: Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found

后端 未结 4 805
情深已故
情深已故 2021-01-12 13:28

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

4条回答
  •  悲哀的现实
    2021-01-12 14:19

    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;
    

提交回复
热议问题