How to precompile a company app by using MDILXAPCompile
January 07, 2014
Applies to: Windows Phone 8 only
Before distributing a company app or a Company Hub app, you must precompile any managed assemblies that are included in the XAP into native code. This topic provides instructions for using the MDILXAPCompile tool to perform this task. MDILXAPCompile is available under %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXAPCompile.
In addition to the MDILXAPCompile tool, the Windows Phone SDK 8.0 also provides the BuildMDILXap.ps1 script. This script uses the MDILXAPCompile command-line tool, but it has the advantage of automating some tasks that must be performed manually when using the tool directly. Consider using the BuildMDILXap.ps1 script rather than using the MDILXAPCompile tool directly unless you need options available only from the MDILXAPCompile tool. For more information, see Preparing company apps for distribution.
Change the file name extension of the XAP file for the app to .ZIP, and extract the contents of the .ZIP file to a folder.
Start the VS2012 x86 Native Tools Command Prompt as an administrator. To access this prompt, open Start and type VS2012 x86 Native Tools Command Prompt.
Optionally, run the following command to ensure that the path environment variable is configured correctly for the MDILXAPCompile tool. If you do not run this command, you must specify the full path for MDILXAPCompile when you run it on the command line in the following step.
set path=%path%;"%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXapcompile";
Run the MDILXAPCompile tool with the following command line. Be sure to replace the placeholder text in this command with appropriate values.
MDILXAPCompile.exe /In:InputPath /Out:OutputPath /Config:ConfigPath [/CompileFilter:AssemblyPath;AssemblyPath] [/Timeout:Timeout] [/Log:LogPath]
The following table describes the command-line arguments for MDILXAPCompile.
Required. The full path to the directory that contains the managed assemblies to precompile to native code.
Required. The full path to the directory to place the precompiled assemblies.
Required. The full path to the MDILXapCompileInput.xml configuration file. This file is available in %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXAPCompile. You should pass in this file without making any changes to it.
Optional. A semicolon-separated list of the assemblies (in the directory specified by the /In argument) to run through the precompiling process. When this argument is specified, only the assemblies listed with the argument are run through the precompiling process.
Optional. The number of milliseconds before the tool automatically stops the compile process. This value overrides the default time-out value in the configuration file. Specify -1 to specify no time limit.
Optional. The full path to the log file to capture output from the MDILXAPCompile tool.
Copy the compiled assemblies back into the folder that the contents of the XAP file were extracted to earlier. Create a ZIP package that contains the compiled assemblies and any other files from the original XAP file, and change the file name extension of the ZIP package to .xap.
The following table describes some of the error codes that MDILXAPCompile may return.
The compilation failed because the IL code was not valid.
One of the methods exceeds 256 KB of IL, the maximum allowed method size. To resolve this error, refactor any methods that exceed this limit into smaller methods and retry the operation.