Silverlight 2: structure of the new .XAP file (Silverlight packaged application)
With Silverlight 2 comes a new file extension for your Silverlight applications: .XAP (pronounced zap). This is a compressed file that uses standard .zip compression algorithm to minimize client download size.
As stated the .XAP file is a .zip compressed file that contains the client DLL for the Silverlight application as extra DLLs of assemblies that you are using in your application. This can be your own assemblies of user controls or assemblies that are not part of the Silverlight runtime by default that gets installed on the client.
External resources like images or other types of files can also be added to the .XAP file if you do embed them into your client DLL. I will be doing another post on the different ways of embedding files into the package application and DLL.
By renaming the .xap file to .zip you can view its contents:
Application Manifest file
The AppManifest.xml file defines the assemblies that get deployed in the client application. This file is automatically updated when compiling your application. Based on the settings of a referenced assembly it is added to the Application manifest. For example, if you have an assembly that you are referencing in your application but do not wish to have it included into the. XAP file you can choose to set “Copy Local” to false.
In this example I’m referencing the System.Xml.Linq assembly and chose not to have a local copied deployed with the .xap. I’ll then need to an on demand download of the assembly when accessing it in my code. This can be useful to have only your base assembly deployed and have an on demand download of subsequent assemblies on the fly so that your initial download time is minimal. When only a part of your application uses a specific assembly you may want to use this mechanism.
.XAP generation tool
When you use the Silverlight project template in Visual Studio 2008 the .XAP file gets generated automatically for you. This is done in a post-build action that uses a tool called Chiron; a tool that gets installed with the Silverlight 2 Beta1 SDK.
The Chiron tool can also be accessed via the command line to package your own .XAP files if needed. You can also use this tool to generate the .XAP for a DLR application.