---
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 **Xperience Code upgrade tool** provides a way to analyze projects and helps convert code that uses the Xperience API to version Xperience 13. You can download the tool from the [API Changes](https://devnet.kentico.com/documentation/api-changes) page on the DevNet portal.

The tool has the following functionality:

- Detects custom code that is no longer valid in Xperience 13
- Provides recommendations for each occurrence of invalid code
- Automatic conversion of most code to the Xperience 13 API

## Prerequisites

The machine where you plan to run the code upgrade tool must have the following installed:

- [Microsoft .NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/net48) or newer
- Visual Studio 2019 with [Build Tools for Visual Studio 2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019) (including _Web development build tools_)

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

## Analyzing Kentico 12 projects

You can run the code upgrade tool for any ASP.NET project that uses the Kentico API in its code. This includes:

- Kentico administration projects (i.e. the projects that provide the administration interface for a separate [MVC](https://docs.kentico.com/13/developing-websites/mvc-development-overview.md) live site)
- Projects that integrate the Kentico API through NuGet packages (for example MVC live site projects)

> **Note:** **Limitation**: The code upgrade tool does not process Razor view files in MVC projects (files with the _.cshtml_ extension). You need to update the code of your views manually after upgrading the Xperience NuGet packages for the MVC project.

### Basic detection

Run **CodeUpgrade.exe** from the **command line**, with the path to your project’s solution file as the parameter (for example _WebApp.sln_ for Kentico projects).

For example:

```csharp

CodeUpgrade.exe C:\inetpub\wwwroot\Kentico12\WebApp.sln

```

The tool generates a **csv** file containing a list of custom code occurrences in your project that are no longer valid in Xperience 13 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_.

For example:

```csharp

CodeUpgrade.exe -resolve C:\inetpub\wwwroot\Kentico12\WebApp.sln

```

If the tool detects code issues that can be automatically resolved, it creates copies of the given files under the **Converted** folder in the tool directory. All resolvable issues in the files are updated to be compatible with the Xperience 13 API.

### Optional parameters

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

- **-vstoolspath=** – sets the path to the Visual Studio build tools required to analyze the solution. You need to set the path if your build tools are installed in a different directory than the default (_C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v16.0_).
- **-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 Xperience files, the tool reports all detected issues, including the default Kentico 12 code. You can avoid reporting of these false positives by enclosing your custom code into **#region** directives with a specific name. For ASPX markup in the administration project, 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 Xperience 13](https://docs.kentico.com/13/installation/upgrading-to-xperience-13.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:

- **Fully custom files** – directly replace the files using the converted files created by the tool.
- **Customized Xperience files** – use a code comparison tool and merge the Xperience 13 files with the matching files in the _Converted_ output folder.
