---
title: Publishing projects from Visual Studio
related:
  - https://docs.kentico.com/k11/installation/deploying-kentico-to-a-live-server.md
  - https://docs.kentico.com/k11/running-kentico-on-microsoft-azure/running-kentico-in-azure-web-apps/setting-up-kentico-in-azure-web-apps.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

You can deploy Kentico web projects to your hosting server using the [Visual Studio Publish function](http://msdn.microsoft.com/en-us/library/dd394698%28v=vs.110%29.aspx) (MSDeploy).

1. Decide whether to precompile the website prior to deployment. See the [Precompiling websites](#precompiling-websites) section for more information.
2. Open your web project in Visual Studio (using the **WebSite.sln** or **WebApp.sln** file).
3. Right-click the Kentico project in the Solution Explorer and select **Publish Web Site** (web site projects) or **Publish** (web applications).
4. Prepare a publish profile according to your requirements. See [How to: Deploy a Web Project](http://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx) for details.
5. **Publish** the site.

Visual Studio publishes the project according to your profile's settings – either copies the project's files to the target server or creates a deployment package.

## Precompiling websites

When deploying websites from Visual Studio, you have the option of [precompiling](http://msdn.microsoft.com/en-us/library/bb398860%28v=vs.90%29.aspx) 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.

> **Note:** **Limitations of precompiled websites**
>
> Only use precompilation to deploy completed websites. Precompiled instances of Kentico have limited website development features.
>
> You cannot edit, create or import virtual objects that contain ASP.NET markup and require compilation:
>
> - [Page layouts](https://docs.kentico.com/k11/developing-websites/developing-websites-using-the-portal-engine/editing-page-layouts.md) (ASCX type)
> - [Transformations](https://docs.kentico.com/k11/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md) (ASCX type)
> - [Web part layouts](https://docs.kentico.com/k11/custom-development/developing-web-parts/using-custom-web-part-layouts.md)
> - [Form layouts](https://docs.kentico.com/k11/managing-website-content/forms/defining-custom-form-layout.md) (ASCX type)
>
> If you wish to [import](https://docs.kentico.com/k11/deploying-websites/exporting-and-importing-sites/importing-a-site-or-objects.md) physical files that require compilation (such as _cs_, _vb_, _aspx_, _ascx_), you need to run the import process on the original project, and then create the precompiled site again.
>
> [Partial caching](https://docs.kentico.com/k11/configuring-kentico/optimizing-website-performance/configuring-caching/caching-page-output.md) (i.e. caching portions of page output generated by specific web parts or controls) is not supported on precompiled websites.

### Testing the website before compilation

You can check that your site's virtual objects (Transformations, Page layouts, etc.) compile correctly before starting the precompilation. 

1. In the Kentico administration interface, open the **System** application.
2. Select the **Virtual objects** tab.
3. 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 website 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:

1. In the Kentico administration interface, open the **System** application.
2. Select the **Virtual objects** tab.
3. 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.

**Note**: On _web application_ projects, you need to manually include the _CMSVirtualFiles_ folder into the _CMSApp_ project. See [Deployment mode for virtual objects](https://docs.kentico.com/k11/deploying-websites/deployment-mode-for-virtual-objects.md) for details.

### Enabling precompilation in your publish profile

When creating a [publish profile](http://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx) for your Visual Studio deployment, configure the following precompilation options in the **Publish Web** dialog:

1. On the **Settings** tab, expand **File Publish Options** and enable **Precompile during publishing**.
2. Click **Configure** next to the _Precompile during publishing_ check box.
3. Configure the options in the _Advanced Precompile Settings_ dialog:

   - **Allow precompiled site to be updatable**:

     - checked - compiles the code behind of all web forms and controls, but keeps the markup files (.aspx, .ascx) in their original form.
     - not checked - 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**_

       > **Note:** Do NOT select any of the other options. Merging of outputs into assemblies is not supported by Kentico projects.

After you finish setting up the profile's remaining settings, you can **Publish** the precompiled site.

> **Tip:** **Tip**: You can also use the [ASP.NET Compilation Tool](http://msdn.microsoft.com/en-us/library/bb398860%28v=vs.110%29.aspx#PerformingPrecompilation) to perform the precompilation from the command line.

### Moving the database

Precompiled Kentico 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 Kentico locally without a database and run the [database setup](https://docs.kentico.com/k11/installation/additional-database-installation.md) against the target SQL server. In this case, you need to enable deployment mode for the new database. See [Deployment mode for virtual objects](https://docs.kentico.com/k11/deploying-websites/deployment-mode-for-virtual-objects.md) for details.
