Renaming Xap to Zip is dead. Long live renaming Xap to Zip!

Teach Windows to treat Xap files as first class compressed folders with this simple registry entry. After applying, you’ll be able to open .Xap files and view their contents, and get the same shell experience as Zips have:

If you’ve ever had to do the "rename .Xap to .Zip" routine while doing Silverlight development, then you’ll enjoy this fix. The entry also sets the MIME type of .Xaps to "application/x-silverlight-app", so it relates to my earlier post about the MIME type, too.

I’ve been using this on my Windows Vista and Windows Server 2008 workstation, but have not tried it on XP.

XNA users: Jeff Klawiter pointed out in the comments that part of the XNA Framework uses .xap for its project file extension. So, beware. Sucks that there is overlap.

Disclaimer: Use this registry file at your own risk. I am not responsible in any way for the results. As developers like to say, "it works great on my machine!"

Download and run this registry patch: Xap.reg

Here’s the contents of the registry patch:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.xap]
"PerceivedType"="compressed"
"Content Type"="application/x-silverlight-app"
@="CompressedFolder"

[HKEY_CLASSES_ROOT\.xap\CompressedFolder]

[HKEY_CLASSES_ROOT\.xap\OpenWithProgids]
"CompressedFolder"=""

[HKEY_CLASSES_ROOT\.xap\PersistentHandler]
@="{098f2470-bae0-11cd-b579-08002b30bfeb}"

The experience before the patch:

And after:

Hope this helps!

Share and Enjoy:
  • Live
  • Digg
  • DotNetKicks
  • Technorati
  • del.icio.us
  • Facebook
  • Print
  • Google Bookmarks

Comments

  1. November 1st, 2008 | 6:37 pm

    There’s just one issue, try installing the XNA framework. The Xact Tool for creating sound files for a game uses .xap for it’s project file extension.

    Obviously the two teams do not speak to each other.

  2. November 2nd, 2008 | 1:22 am

    It’s seems silverlight 2.0 ,Do not support common compress format anymore , After i compile my silverlight the xap file is about 500k , But when i unzip it and rezip to zip format it about 300k , But when it uploaded it do not work anymore (I think it worked in beta 2)

  3. November 2nd, 2008 | 3:06 am

    @egoZd, I’ve been able to unzip and rezip from Red Hat fine – can you check the recompressed version to make sure the directory structure is the same, and that it doesn’t have a subdirectory at the root?

  4. November 2nd, 2008 | 3:06 am

    Hi Jeff,

    You can get the same results if you right click the file choose ‘Open With’ then go for the ‘Choose default program …’ option even if your right choice is listed. Then choose the default program you want to use to open the files and make sure you check ‘Always use the selected program to open this kind of file’. And you are done.

    -Mark

  5. November 2nd, 2008 | 7:10 am

    The registry works well on Windows XP, too.

  6. Tom
    November 3rd, 2008 | 7:06 am

    Wow. I thought people only used the shell support for zip files if they didn’t know any better or were using a machine where they couldn’t install a real program for handling them. (Personally I prefer 7-Zip.) Sorry for the negativity but the “shell experience” for zip files is downright embarrassing IMO. I heard it was going to be improved in Vista SP1, but I never checked it because 7-Zip works so well for me.

  7. Dave
    November 3rd, 2008 | 7:21 am

    You can also run the command:
    cmd /c assoc .xap=CompressedFolder

    This way you don’t have to modify the registry.

  8. November 3rd, 2008 | 9:08 am

    @Dave,
    Thanks – do you know if that can be used to set the MIME type to application/x-silverlight-app, too?

  9. November 3rd, 2008 | 6:06 pm

    press shift and right click the xap file, choose winzip/winrar to open it, and you can treat it like zip ever since.

  10. November 3rd, 2008 | 6:11 pm

    @Tom and @unruledboy, makes sense: often I’m in an environment where we just have Windows installed, like a test lab – so although we can run registry files with ease, I typically won’t have the opportunity to install custom software on the machine.

    For a lot of folks, sounds like your solutions would work best though.