Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a task to zip / unzip files #1781

Closed
natemcmaster opened this issue Mar 2, 2017 · 8 comments
Closed

Create a task to zip / unzip files #1781

natemcmaster opened this issue Mar 2, 2017 · 8 comments
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. triaged

Comments

@natemcmaster
Copy link
Contributor

natemcmaster commented Mar 2, 2017

Producing zip archives is a very common build step. Would be nice to have a built-in msbuild task that does this.

@moozzyk
Copy link

moozzyk commented Mar 2, 2017

There is a reaoson why the task is in the file called "common.tasks": https://github.com/moozzyk/MSBuild-Tasks/blob/master/common.tasks

@AndyGerlicher AndyGerlicher added the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Mar 2, 2017
@AndyGerlicher AndyGerlicher added this to the After 15 milestone Mar 2, 2017
@AndyGerlicher
Copy link
Contributor

Setting this up-for-grabs. This is something we would accept but not prioritizing right now.

@coderpatros
Copy link
Contributor

I'll have a look at this over the next few days.

@coderpatros
Copy link
Contributor

Has this already been done and merged?

@natemcmaster
Copy link
Contributor Author

FYI - we needed zip/unzip tasks to build ASP.NET Core so we wrote our own tasks. They're good enough for us. They need more thorough testing, but you might be able to use these as a springboard for an official MSbuild version.

https://github.com/aspnet/BuildTools/blob/dev/src/Internal.AspNetCore.BuildTools.Tasks/UnzipArchive.cs
https://github.com/aspnet/BuildTools/blob/dev/src/Internal.AspNetCore.BuildTools.Tasks/ZipArchive.cs

@coderpatros
Copy link
Contributor

Thanks @natemcmaster

I'm going to hold off looking at this until I get more familiar with the code base and just keep chipping away at little things.

@jeffkl jeffkl self-assigned this May 9, 2018
jeffkl added a commit that referenced this issue May 22, 2018
`ZipDirectory` task zips up a whole directory.  It will fail if the destination file already exists.  Zipping individual files is a lot harder because you have to calculated a base path for all files and make zip entries relative to that.  The code in the CLR that does this is very efficient by reusing string buffers and I didn't want to have to replicate the code.  So for now there's only `ZipDirectory` instead of a more generic `Zip`.

`Unzip` unzips files from an archive to a directory.
* Defaults to skip unzipping files that are already up-to-date
* Logs every file that was unzipped
* Supports cancellation
* Supports overwriting read-only files
* Supports unzipping multiple files to the same directory

Fixes #1781
@natemcmaster
Copy link
Contributor Author

Awesome, thanks @jeffkl !

@GF-Huang
Copy link

GF-Huang commented Apr 26, 2024

MSBuild from VS2022 only remains ZipDirectory, where is the Zip/ZipFiles task? I need exclude some files but ZipDirectory not supports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. triaged
Projects
None yet
Development

No branches or pull requests

7 participants