Precompiling websites
When deploying websites, you have the option of precompiling the web project before you place it on a server. This compiles the project’s code into assemblies, providing several advantages:
- Faster initial response times – the system does not need to compile resources dynamically when they are requested for the first time.
- Source code protection – you can create a compiled version of the website without any accessible source code.
Precompilation can be enabled when publishing projects from Visual Studio, or done as part of a more complex deployment process (for example using third-party tools).
Precompiling the administration application
Testing before compilation
You can check that your administration project’s virtual objects (layouts, etc.) compile correctly before starting the precompilation.
- In the Xperience administration interface, open the System application.
- Select the Virtual objects tab.
- Click Test virtual objects.
The system compiles all virtual objects and adds them to the temporary files in the application’s ASP.NET cache. This operation may take a long time, depending on the number of virtual objects in the system.
If the process finishes without errors, your administration application should run correctly after the precompilation.
Preparing virtual objects for compilation
Before you start the deployment, you need to perform the following steps to include your website’s virtual objects into the precompiled project:
- In the Xperience administration interface, open the System application.
- Select the Virtual objects tab.
- Click Store all virtual objects in file system.
The system creates physical files containing the code of your virtual objects inside the project’s CMSVirtualFiles folder. See Deployment mode for administration virtual objects for details.
You need to manually include the CMSVirtualFiles folder into the CMSApp project in Visual Studio.
Enabling precompilation in the Visual Studio publish profile
When creating a publish profile for your Visual Studio deployment, configure the following precompilation options in the Publish dialog:
On the Settings tab, expand File Publish Options and enable Precompile during publishing.
Click Configure next to the Precompile during publishing check box.
Configure the options in the Advanced Precompile Settings dialog:
Allow precompiled site to be updatable:
- enabled – compiles the code behind of all web forms and controls, but keeps the markup files (.aspx, .ascx) in their original form.
- disabled – the compilation also includes markup files. The precompiled website contains only empty “stub” .aspx/.ascx files without any code. We generally recommend using non-updatable sites for optimal performance.
Merge options – select one of the following options:
Do not merge
Do not merge. Create a separate assembly for each page and control
Do NOT select any of the other options. Merging of outputs into assemblies is not supported by Xperience projects.
After you finish setting up the profile’s remaining settings, you can Publish the precompiled site.
Moving the database
Precompiled Xperience sites cannot be used to install a new SQL database on the target server. If you need to move the database as part of the deployment process, you have several options:
- Copy the database to the target server using the standard backup/restore procedure and update the connection string in the project’s web.config file.
- Install Xperience locally without a database and run the database setup against the target SQL server. In this case, you need to enable deployment mode for the new database. See Deployment mode for administration virtual objects for details.