---
title: Upgrading custom code
---

> 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).

The **Kentico Code upgrade tool** provides a way to analyze Kentico 9 projects and helps convert custom code to version 10. You can download the tool from the [API Changes](http://devnet.kentico.com/documentation/api-changes/kentico-10) page on the DevNet portal.

The tool has the following functionality:

- Detects custom code that is no longer valid in version 10
- Provides recommendations for each occurrence of invalid code
- Automatic conversion of the majority of code to the Kentico 10 API

## Prerequisites

The machine where you plan to run the code upgrade tool must fulfill the following requirements:

- [Microsoft .NET Framework 4.5.1 or newer](http://www.microsoft.com/en-US/download/details.aspx?id=40773)
- Visual Studio 2013 or 2015

The Kentico 9 solution that you wish to analyze must compile without errors.

To allow the tool to check the code of Kentico virtual objects, such as [transformations](https://docs.kentico.com/k10/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md) and [page layouts](https://docs.kentico.com/k10/developing-websites/developing-websites-using-the-portal-engine/editing-page-layouts.md), you need to enable [Deployment mode](https://docs.kentico.com/k10/deploying-websites/deployment-mode-for-virtual-objects.md) for your Kentico 9 instance.

## Analyzing Kentico 9 projects

### Basic detection

Run **CodeUpgrade.exe** from the **command line**, with the path to your project’s solution file as the parameter (_WebSite.sln_ or _WebApp_._sln_).

For example:

```csharp

CodeUpgrade.exe C:\inetpub\wwwroot\Kentico9\WebSite.sln

```

The tool generates a **csv** file containing a list of custom code occurrences in your project that are no longer valid in Kentico 10. The information will help you update your custom code after you perform the upgrade.

Each listed occurrence in the csv file has one of the following statuses:

- **Detected** - an occurrence of invalid code that the tool cannot resolve automatically. See the _Instructions_ value of the occurrence for more information.
- **CanBeResolved** - a detected code occurrence that the tool can resolve automatically if you run it with the _-resolve_ parameter (see the _Automatic conversion_ section).
- **Resolved** - invalid code that the tool automatically resolved in the specified output folder. Only used when running the tool with the _-resolve_ parameter.

### Automatic conversion

You can also use the tool to provide automatic resolutions for most types of code expressions. Add the **-resolve** parameter when running _CodeUpgrade.exe_. Set the target folder for the output using the **-outputfolder** parameter.

For example:

```csharp

CodeUpgrade.exe -resolve -outputfolder=C:\ConvertedCode C:\inetpub\wwwroot\Kentico9\WebSite.sln

```

If the tool detects code issues that can be automatically resolved, it creates copies of the given files in the specified output folder. All resolvable issues in the files are updated to be compatible with the Kentico 10 API.

### Optional parameters

You can also add the following parameters when running the tool:

- **-output=results.csv** - sets the name of the file containing the tool’s results.
- **-verbose=0** - determines how detailed the tool’s output is in the console (enter values from 0 to 3). Does not affect the output file.

> **Info:** For more details about the available parameters, run the tool without any parameters.

### Limiting the scope of the analysis

For customized Kentico files, the tool reports all detected issues, including the default Kentico 9 code. You can avoid reporting of these false positives by enclosing your custom code into **#region** directives with a specific name. For ASPX markup, use the following syntax:

```csharp

<%-- #region Name --%> ... <%-- #endregion --%>

```

To analyze only the code placed inside the regions, run the tool with an additional parameter: **-customregion=**

## Implementing the API changes

Use the output of the tool to update your custom code AFTER you [upgrade the project to Kentico 10](https://docs.kentico.com/k10/installation/upgrading-to-kentico-10.md).

The output file lists all occurrences of invalid custom code, including:

- The path of the affected file and line number
- The exact source code of the expression
- A set of instructions on how to resolve the issue

If you generated automatic conversions for your code, use the following approaches to insert the new code into your upgraded project:

- **Customized Kentico files** - use a code comparison tool and merge the Kentico 10 files with the matching files in the tool’s output folder.
- **Fully custom files** - directly replace the files using the converted files created by the tool.

> **Tip:** **Tip**: To update the code of virtual objects, enable [Deployment mode](https://docs.kentico.com/k10/deploying-websites/deployment-mode-for-virtual-objects.md). You can then fix the code in the corresponding physical files, which match the output of the code upgrade tool. Disable deployment mode to return the updated virtual objects back into the database.
