Friday, August 26, 2011

Reducing size of RTF file with image

We use RTF format to generate documents in our products as it is widely supported by software vendors. The bad thing about RTF files is a file size, which drastically increases when document contains images (compared to the same document saved in "doc" format). This becomes a big  issue when you have hundreds of thousands documents stored in a databases, and send them to other parties.

As it turned out, the file size issue is not caused by RTF format itself, but by the way MS Word saves RTF files with images. When MS Word saves document in RTF format, it saves two copies of each image - original one and also a copy converted to WMF format. Fortunately, there is way to disable such a strange behavior. You can read how at Microsoft knowledge base article Document file size increases with EMF, PNG, GIF, or JPEG graphics in Word.

Wednesday, August 17, 2011

Using NuGet to download all packages for the solution

Here I'm talking about technique which allows you to use NuGet without committing packages to source control (which is handy in case you use Mercurial). First time I've heard about this approach from José F. Romaniello post. In essence: each project within solution has a pre-build step ensuring that all packages are downloaded via NuGet.exe command line utility. While this approach works well for a small project, it has some drawbacks with large solutions:
  • It forces me to insert that build step into each project within solution, which is a little bit annoying.
  • It increases solution build time. This becomes visible for a solution containing a lot of projects. I guess that was one of the main reasons why Simon Cropp wrote this post.
So, do I really need to check for NuGet packages on each build? It think that checking for dependencies at CI server, and perhaps after pulling changes from source control might be enough.

To achieve this I use a Powershell script which looks for packages.config files within a solution and executes NuGet.exe for each of them.


This script uses repositories.config file to locate packages.config files instead of searching them in file system. Obviously to make it work, repositories.config should be placed in source control and path variables should be adjusted according to the solution folders structure.

Hope you find this post helpful. At least I've learned some new things about powershell :). Please share your thoughts.