Friday, May 14, 2004

The Code Project - ZipStudio - A versatile Visual Studio add-in to zip up Visual Studio solutions and projects

The Code Project - ZipStudio - A versatile Visual Studio add-in to zip up Visual Studio solutions and projects - C# Programming

"Introduction
This article presents a versatile way to zip up Visual Studio (VS) solutions, projects, and/or any selected items in the Visual Studio Solution Explorer window directly to a zip archive. The approach used is, in general, different from that provided by other solutions to this problem. This add-in uses the Visual Studio automation object (EnvDTE namespace) to enable it to decide what project items are to be included in the resulting Zip file. This approach has the following advantages:

Only the selected items in the Solution Explorer window will be added. So, the solution and/or individual projects can be zipped, or individual folders in those projects, or right down to individual project items. The rule for this works as follows: if the solution is selected, all files will be added to the Zip files, if a project is selected, all files for the project will be added. If a project item is selected, and its parent project and the solution is not selected, only the item itself will be added. If the selected item is a folder all the items in the folder will be added.

It works with ALL projects tested in the VS environment, as it uses VS itself to decide what the individual projects consist of. It has been tested with all C#, VB, C++, Deployment (.vdproj), and also the InfoPath SP1 Preview (.ipproj) projects. Furthermore, it works correctly with the Solution Items folder and all project folders in the projects themselves. It also correctly resolves item dependencies, such as a form item consisting of a .cs and .resx file (in the C# case).

If the 'Show All Files' option is chosen for a project in the Solution Explorer window, any shown item(s) may be selected to be added as well, even though they are not seen by VS to be part of the project.

If a new project type is added to the VS environment the add-in should still continue working, as it makes no assumptions about any type of project, other than the project hierarchies exposed by the DTE automation object itself.

Lastly, but most importantly, the code is relatively simple and concise (once you understand the DTE object model), and does not require the parsing of XML-encoded project files which at a minimum is tedious and the code is mostly fairly convoluted. Instead, this add-in spends a lot of time navigating collections of objects provided by the DTE automation object.

The downside to this approach is:

The Zip file can only be created inside Visual Studio and the implementation is not available (currently) as a standalone executable, or a File Explorer shell extension.

It works ONLY for the Visual Studio .NET 2002 (7.0) and 2003 (7.1) environments. It does not work for any releases of VS which do not have the .NET badge. Sorry for you, VS6 users..."

Cool. Looks like a nice way to zip up projects for redist...

No comments: