thoemmi / 7Zip4Powershell

Powershell module for creating and extracting 7-Zip archives
GNU Lesser General Public License v2.1
397 stars 64 forks source link

Not working on Nanoserver #35

Closed msnelling closed 7 years ago

msnelling commented 7 years ago

Hi, when I install this module from PSGallery I get the following error when using it.

Get-7Zip : Could not load type 'System.MarshalByRefObject' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
At line:1 char:1
+ Get-7Zip .\Miniconda3\preconda.tar.bz2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-7Zip], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,SevenZip4PowerShell.Get7Zip
Expand-7Zip : Could not load type 'System.MarshalByRefObject' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
At line:1 char:1
+ Expand-7Zip -ArchiveFileName .\Miniconda3\preconda.tar.bz2 -TargetPat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Expand-7Zip], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,SevenZip4PowerShell.Expand7Zip
woodie commented 7 years ago

Similar issue here. Build this Docker image to experience for yourself.

https://github.com/woodie/nanoserver-7z

thoemmi commented 7 years ago

Thanks @woodie for the repro. I can confirm that the module isn't working.

I've found this article Developing PowerShell Cmdlets for Nano Server:

Nano Server includes PowerShell Core by default in all Nano Server installations. PowerShell Core is a reduced-footprint edition of PowerShell that is built on .NET Core and runs on reduced-footprint editions of Windows, such as Nano Server and Windows IoT Core. PowerShell Core functions in the same way as other editions of PowerShell, such as Windows PowerShell running on Windows Server 2016. However, the reduced footprint of Nano Server means that not all PowerShell features from Windows Server 2016 are available in PowerShell Core on Nano Server.

I'll have a look if I can get 7Zip4PowerShell working on Nano Server.

thoemmi commented 7 years ago

The issue is that Nano Server doesn't support the full .NET Framework, but .NET Core. However, 7Zip4Powershell uses SevenZipSharp, a .NET wrapper for 7-Zip, which does not support .NET Core.

I looked for another library 7-Zip library supporting .NET Core, but the only one I've found (SharpCompress) allows only to read 7Zip, but not writing it.

Therefore I cannot support .NET Core (and Nano Server) at this point in time.