PNG curse? Solve it with a link.


January 21, 2009 by Alistair Deneys

This is another post which starts out with me reading another post 🙂 . I was reading the Molten Core blog which is written by Thomas Eldblom (fellow MVP) and Jens Mikkelsen. Thomas published a post in which he points out the large number of PNG icon files included in Sitecore. Sitecore contains an extensive icon library consisting of 1,000’s of files. And each of these files is provided in several resolutions to improve the quality on screen. Have you ever tried zipping up an existing Sitecore solution? It takes a while. Not because it’s huge, but because there are so many little files. Same with applying attributes (security) to a folder containing a Sitecore solution.

I have often thought about somehow removing the icons folders and sharing them amongst several Sitecore instances. Like most Sitecore devs, I have several Sitecore instances on each of my machines. If you had to move even just one of these sites from box to box, such as taking a site home on the laptop to work on, it’s a pain.

One thing about reading blogs through RSS; You miss out on the comments. Thomas points out the issue in his post, but there are some great solutions to the problem, and discussion, in the comments.

Alexey Rusakov from Sitecore tells us about the different ways in which Sitecore have tried to minimise the impact of the situation. Mark Cassidy (fellow MVP) from CorePoint told us that Per Bering from Codehouse compiled all the images into a resource DLL and used a custom HTTP Module to serve from the resource DLL. Jakob Christensen from Sitecore pointed out you could use virtual directories in IIS to remap the icon folders to a single shared location. He even posted a NAnt build file which would do this for you. While reading all this I thought “If only we had symbolic links in Windows like we have in *nix. That would solve the problem.”

Seeing all these great comments got me motivated to rewrite Jakob’s build script in MSBuild. I used to be a huge fan of Ant and NAnt, but since Microsoft bought out MSBuild with .net 2.0 I have usually found everything I need in that. Every Visual Studio project file is actually an MSBuild project file. So I got to work on making this happen.

Out of the box, MSBuild can’t talk to IIS. But MSBuild is very extensible, and the MSBuild community tasks provide extensions to allow you to communicate with IIS. Unfortunately I couldn’t get this working with Vista 😦 (perhaps I didn’t try hard enough.) So I looked around for a different way of doing it. MSBuild also let’s you execute any command through the “Exec” task. IIS 7, which is the version which ships with Vista, provides a command line tool called APPCMD (find it at %systemroot%\system32\inetsrv\APPCMD) which allows you to manage IIS from the command line. I found this page very helpful in working out how to create virtual directories.

But seeing as though I was just using Exec, I decided to change my script from MSBuild to a plain old batch file. It was while I was trawling through help files trying to remember how to check if a script argument (%1) was not provided that I stumbled across a new command I hadn’t seen before. MKLINK.

MKLINK allows you to create symbolic links in Vista and Windows 2008…


I can create symbolic links in Vista??!!?


That’s right, as of Vista (sorry XP guys) we now have symbolic links. I was ecstatic. I have been longing for this minor feature for so long in Windows.

So now it’s as easy as:

  1. Move an existing Theme folder to a location where it can be shared amongst all your Sitecore sites such as c:\inetpub\Themes.
  2. Delete all the Theme folders under each Sitecore website (perhaps you should check first and make sure you’re not losing any files).
  3. Create a symbolic link under the Sitecore site to the shared location.
cd c:\inetpub\mysitecoresite\website\sitecore\shell\
mklink /d Themes c:\inetpub\Themes

Symbolic links operate at the file system level, below IIS. To users and applications it’s as if this is a real file. Now this is going to save me a lot of headaches.

Yay symbolic links!


6 thoughts on “PNG curse? Solve it with a link.

  1. First, thanks for the heads up about comment discussion – tracking replies in blogs is definitely an unsolved problem.

    Second, Yay symbolics links! One thing I wanted to warn about is that themes folder also contains css files, and it is possible for those to change from version to version.

  2. Commodore73 says:

    Since Windows 2000 we’ve had junctions (for directories only?) that function much like symbolic links:

  3. Mark Cassidy says:

    LOL I missed that memo too, apparently 😉

  4. Chris Giddings says:

    Great for all sitecore instances running on with the same version but still doesn’t address the issue of different versions as well as new developers comming into the project.

    I’ve never really had an issue with this as it’s normally a simple process and not too length time to copy and what you have to be carefull of is updates, this could cause issues.

    Just my two cents 🙂

  5. […] PNG curse? Solve it with a link.- Life saver! […]

  6. Per Bering says:

    Works for complete sitecore folders too 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


The views expressed on this blog are solely my own and do not necessarily reflect the views of my employer.
%d bloggers like this: