Once you've created a XapOptimizer project, you can add it to your build process in Visual Studio. This is easy to do using a post-build event. Note that previously you could use the /cmd command line argument to run XapOptimizer in command mode for batch runs. Now, you can use the separate XapOptimizerCmd.exe application included in the XapOptimizer installation.
Complete the following steps:
1. Open the Silverlight project in Visual Studio.
2. Select the Release configuration (you probably will not want to optimize the project after each debug build).
3. Right-click the main project node in the Solution Explorer and select Properties.
4. Click the Build Events tab on the left side of the Properties window.
5. Enter the following command in the Post-build event command line:
%ProgramFiles%\ComponentOne\XapOptimizer\bin\XapOptimizerCmd.exe" /p:$(ProjectDir)$(ProjectName).xoproj
Note that the command line statement in step 5 assumes that the command line version of ComponentOne XapOptimizer is located in the Program Files\ComponentOne\XapOptimizer\bin folder. You may change this line if the application is installed in a different directory. See Command Line Arguments for more information about the arguments used in the above statement.
Once this step is finished, the XAP file will be optimized automatically every time you perform a release build. You can easily test the optimization by running the release configuration from Visual Studio.
If your application does not use reflection, it will probably work right away without any customizations to the project file. If you do use reflection, you may need to customize the XapOptimizer project. See Working with XapOptimizer for more information.