Click here to Skip to main content
Click here to Skip to main content

ProjectZip 1.6 - Zip up the source code for your latest CodeProject article

, 31 Mar 2004
Rate this:
Please Sign up or sign in to vote.
A one-click process to building the source files in the active project into a self contained zip file, using this simple-to-use Visual Studio Add-In

Introduction

The articles I've more recently submitted to CodeProject have been related to Windows' hooking and sub-classing and have reused a number of shared components.

These shared components also typically exist in a separate folder to the article project itself.

As a result, when I come to build the zip file containing the source, I have to build in files from two or more folders and ensure that files in those folders which are not relevant, are not included.

What this means in practice, is zipping the project folder and the shared folder in their entirety and then deleting from the zip, all the shared files which are not relevant.

Clearly, the risk of human error is fairly high and I often find myself doing a number of test zips and builds until I get it right. And then if I want to update the code later, as I generally do, I've got to do it all over again.

Enter ProjectZip, a Visual Studio add-in which provides tools to zip the active project and all its files to a single zip file. And all with a single button click.

The solution

The solution, in itself, is actually quite trivial; all the significant work was in developing the appropriate wrapper classes to Gilles Volant's Multi-File API built on top of the classic ZLib code base by Jean-loup Gailly and Mark Adler.

As a result, this article is not very long or detailed, but I hope that this is more than made up for, by the usefulness of the component.

The essence of the solution is this:

  1. When the user clicks to zip the project, the add-in first saves the current workspace and its contents.
  2. Then the path to the .dsp file is determined by querying the IApplication object for the active project.
  3. The .dsp file is then parsed manually to build a file list (there seems to be no alternative to this and, although others have supplied code to do this, the format is really very simple so I parse it myself).
  4. Since the .dsp typically stores files as relative paths, I then convert the paths to full paths.
  5. Then I parse the file list, iteratively building the longest path that is common to all files (what in the code I call the 'root path').

    The point of establishing the root path is so that the zip file need only contain as much of a file's full path as is necessary to maintain the correct folder relationships when the zip is extracted at a later date.

  6. finally I create the zip file and then add each of the files in turn.

Other features

Because I found the writing of the add-in so straightforward, I began looking around for other related features that might be valuable.

And then it occurred to me that apart from zipping projects to send to CodeProject, I also regularly download and unzip projects before opening them in VC6.

So why not add this facility to the addin.

Again the implementation is fairly trivial since its just a case of unzipping the file to a user-specified location and then loading the appropriate .dsw or .dsp file.

In the case of multiple .dsw files (or multiple .dsp files when no .dsw is present), I show a simple dialog that allows the user to select which project file to open.

Other features include:

  • Including the .dsw file
  • Prompting before overwriting existing zip files or existing projects when unzipping
  • Prompting to save the zip with an alternative name and/or location to the default (project_name.zip in the project folder)
  • Opening the zip after zipping for verification

Using the add-in

To use the add-in, take the following steps:

  1. Close VC6 if its is open.
  2. Copy ProjectZip.dll to ..\Microsoft Visual Studio\Common\MSDev98\AddIns
  3. Restart VC6
  4. Select the 'Add-ins and Macro Files' tab from the 'Tools|Customize' dialog box.
  5. Select the checkbox next to the 'ProjectZip' entry.
  6. Switch to the 'Commands' tab on the same dialog and select 'Add-ins' from the 'Category' droplist.
  7. This will display the three ProjectZip toolbar buttons, which can be dragged and dropped onto any toolbar.
  8. Load a project and try it out!

Credits

Copyright

The code is supplied here for you to use and abuse without restriction, except that you may not modify it and pass it off as your own.

History

  • 1.6 (2 Apr 2004)
    • option added to also zip 'non-essential' project files such as .clw, .ncb, .opt
    • various bugs fixed relating to using the correct user preferences
  • 1.4.1 (9 Mar 2004)
    • code added to handle project file paths of the form ('\file.cpp') which are files in the root of the drive containing the proejct file (thanks to gjr)
    • registry code fixed where direct registry access was failing (thanks to Peter Boulton)
  • 1.4 (3 Mar 2004)
    • option added to set zip filename to lowercase
    • zip paths saved and restored to/from registry (keyed by workspace path)
    • support added for workspaces with multiple projects
  • 1.2
    • File date/times correctly saved with the zip (thanks to IJamil)
  • 1.1
    • bug fix: correct workspace file picked
    • bug fix: files with multiple '..\' handled correctly
  • 1.0
    • Initial Release  

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

.dan.g.
Software Developer Maptek
Australia Australia
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.
 
For all his latest freeware visit AbstractSpoon.

Comments and Discussions

 
GeneralVery good Pinmemberferetyz16-May-09 7:30 
General[Message Removed] Pinmemberstonber5-Oct-08 7:02 
GeneralWorkspace with multiple projects. PinmemberNick Thomas6-Feb-08 23:27 
Hi,
This doesn't work in VC6 where my workspace has multiple projects. It only zips the current active project!
 
Most of my workspaces have multiple projects, so this is unuseable for me.
GeneralVisual Studio 2005 PinmemberJon Smith12-Jul-06 2:20 
GeneralRe: Visual Studio 2005 PinmemberValery A. Boronin30-Apr-07 13:28 
Generalbeginer Pinmemberdnqhung13-Jun-04 2:12 
QuestionCan I use your idea in my open source VC Addin project? PinmemberXSimon2-Apr-04 2:37 
AnswerRe: Can I use your idea in my open source VC Addin project? Pinmember.dan.g.2-Apr-04 16:14 
GeneralRe: Can I use your idea in my open source VC Addin project? PinmemberXSimon3-Apr-04 3:28 
GeneralIt's very good,but one question Pinmemberoliverzy18-Mar-04 18:36 
GeneralRe: It's very good,but one question Pinmember.dan.g.1-Apr-04 21:12 
GeneralRe: It's very good,but one question PinmemberBerry van Olphen1-Apr-04 21:15 
GeneralNice PinmemberMatthew Hazlett2-Mar-04 14:10 
GeneralRe: Nice Pinmember.dan.g.2-Mar-04 14:28 
Questionis VS7 version coming soon? PinmemberValerio12-Aug-03 3:34 
AnswerRe: is VS7 version coming soon? Pinmemberdang!12-Aug-03 14:34 
GeneralRe: is VS7 version coming soon? PinmemberJonathan de Halleux1-Oct-03 23:28 
GeneralRe: is VS7 version coming soon? Pinmemberdang!2-Oct-03 14:05 
GeneralDang! That's nice! Pinmemberrittjc5-Aug-03 17:12 
GeneralRe: Dang! That's nice! Pinmemberdang!5-Aug-03 17:55 
GeneralFile Dates PinmemberIJamil4-Jul-03 3:14 
GeneralRe: File Dates PinmemberDanG6-Jul-03 14:26 
GeneralRe: File Dates PinmemberDanG!10-Jul-03 2:26 
GeneralRe: File Dates PinmemberIJamil21-Mar-04 11:49 
GeneralBug in CCommands::PrepareFilePaths ?! Pinmemberbilbo_baggins17-Jun-03 18:20 
GeneralRe: Bug in CCommands::PrepareFilePaths ?! PinmemberDanG17-Jun-03 18:22 
GeneralRe: Bug in CCommands::PrepareFilePaths ?! PinmemberDanG19-Jun-03 0:17 
GeneralGood Work ! PinmemberAmer Gerzic17-Jun-03 7:35 
GeneralRe: Good Work ! PinmemberDanG17-Jun-03 14:47 
GeneralWrong .dsw zipped Pinmembersoftyan16-Jun-03 22:45 
GeneralRe: Wrong .dsw zipped PinmemberDanG17-Jun-03 14:46 
GeneralRe: Wrong .dsw zipped Pinmembersoftyan17-Jun-03 16:45 
GeneralRe: Wrong .dsw zipped PinmemberDanG17-Jun-03 18:20 
GeneralRe: Wrong .dsw zipped PinmemberDanG19-Jun-03 0:19 
GeneralRe: Wrong .dsw zipped Pinmembersoftyan19-Jun-03 13:53 
GeneralRe: Wrong .dsw zipped PinmemberDanG24-Jun-03 16:49 
GeneralRe: Wrong .dsw zipped PinmemberDanG!10-Jul-03 2:01 
GeneralRe: Wrong .dsw zipped Pinmembersoftyan10-Jul-03 2:17 
GeneralSmall talk... PinmemberOh-keol Kwon16-Jun-03 21:49 
GeneralZipping whole project workspace PinmemberKin Hoon15-Jun-03 6:46 
GeneralRe: Zipping whole project workspace PinmemberDanG15-Jun-03 14:50 
GeneralErr.. it works ! PinmemberTrollslayer14-Jun-03 5:28 
GeneralRe: Err.. it works ! PinmemberDanG17-Jun-03 14:47 
GeneralGreat Work Pinmemberfnaddaf12-Jun-03 8:29 
GeneralRe: Great Work PinmemberRichClaussen12-Jun-03 9:07 
GeneralRe: Great Work PinmemberDanG12-Jun-03 14:22 
GeneralRe: Great Work PinmemberAnna-Jayne Metcalfe15-Jun-03 1:48 
GeneralWonderful PinmemberEugene Pustovoyt12-Jun-03 6:47 
GeneralSweet! Pinmemberravinggoat12-Jun-03 4:56 
GeneralNice! PinadminChris Maunder12-Jun-03 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.141029.1 | Last Updated 1 Apr 2004
Article Copyright 2003 by .dan.g.
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid