Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Compress-Archive on Windows PowerShell generates an archive incompatible with OS X Archiver #11

Closed
SteveL-MSFT opened this issue Sep 6, 2016 · 11 comments · Fixed by #62

Comments

@SteveL-MSFT
Copy link
Member

See PowerShell/PowerShell#2140 for details

@lukespragg
Copy link

Is there an alternative to zipping archives in PowerShell other than resorting to using batch or another language? I'm experiencing the same issue on AppVeyor as documented by @vors on the original issue. I'm not aware of any way to switch to CoreCLR on AppVeyor, so pretty much limited to FullCLR and this bug.

@eugeneniemand
Copy link

I have a similar issue, when I package a dotnet core app for AWS Lambda, Lambda says it cannot load my assembly, however if I compress the same files with macOS or zip in terminal it works fine. I even resorted to try and call the terminal zip from powershell but its complaining about "*", if I run the same command in terminal it works fine

@joeyaiello
Copy link

@lukespragg unfortunately, I don't know of any way to use PowerShell Core as the default in an AppVeyor instance (of course, you could always download PS 6 and unzip it, but that's gonna add some serious time to your CI runs)

@eugeneniemand I'm not sure I understand you here: are you using PowerShell Core to generate the ZIP (thereby eschewing the bug in FullCLR that you're hitting)? (And yeah, the globbing/* problem is PowerShell/PowerShell-RFC#33, we haven't solved it yet unfortunately.)

@joeyaiello
Copy link

Oh, one work around that should work from PowerShell (haven't validated, but I'd bet it works):
PS> bash -c 'zip -r filename *'

@lukespragg
Copy link

@joeyaiello, I opted for a batch snippet for now with 7z as it's installed by default on AppVeyor. I could probably use PowerShell to trigger that as well, but it works for now. :)

@joeyaiello
Copy link

@lukespragg sounds good. I was wondering what you were using when you said you could 'just use batch', didn't realize that AppVeyor bundled 7z by default. 👍

@vors
Copy link
Contributor

vors commented Oct 23, 2017

Ping. This is very annoying for macOS users.

@lukespragg
Copy link

For those having issues and looking for a comparable alternative, I ended up going with the following:

Install-Module 7Zip4PowerShell -Force -Verbose
Compress-7Zip "Path\To\Files" -ArchiveFileName "OutputName.zip" -Format Zip

The -Force is needed if you're using this on AppVeyor. I was using 7z directly before since AppVeyor includes that, but the 7Zip4PowerShell module makes it a little cleaner. Tested and had no issues with the archives on macOS, Linux, and Windows.

@vors
Copy link
Contributor

vors commented Oct 24, 2017

Sure it works, when you can change the packaging steps on the projects. The problem is when you are not controlling the project and just downloading the zips.

@rstarkov
Copy link

Could someone please merge this simple pull request? This module is kind of useless because of this bug, but worse, it wastes time when people try to use it and create broken archives. Took us a couple of hours to understand why AWS Lambda was unhappy with our zip files.

@MythreyaK
Copy link

I can reproduce this issue on the latest Windows 2004 with powershell that comes preinstalled.

PS C:\Users\Mythreya> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants