Skip to content

Upgrading to RLBotDotNet 2.x

Tangil edited this page Aug 19, 2021 · 9 revisions

RLBotDotNet 2.x targets .NET Standard 2.0 so you can use .NET 5+, .NET Core 2.0+, and .NET Framework 4.6.1+. The previous version of RLBotDotNet (1.x) targeted only .NET Framework 4.6.1+. (Note: the + denotes any version equivalent or greater.)

While upgrading from RLBotDotNet 1.x to 2.x should be a largely smooth process, there are a few breaking changes you need to keep in mind. Please follow these sections in order when upgrading your bot.

Upgrading your bot project to .NET 5

It's recommended you upgrade your project from .NET Framework 4.x to .NET 5. The simplest way to upgrade to .NET 5 is with https://github.com/dotnet/try-convert/. Follow the instructions to install try-convert, and then run try-convert -tfm net5 in the command line. Run this command in the directory where your .sln file is located.

You'll likely have the following lines in your Bot.csproj file:

<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>

You don't need these lines so you should remove them.

Note that after the conversion, you'll still have a packages.config file. You'll no longer need this file so feel free to delete it. You also don't need App.config unless you've used it for configuring settings.

You'll probably get compile errors, but don't panic! We're going to fix them in the next sections.

Upgrading RLBotDotNet in your project

To upgrade your RLBotDotNet version to 2.x, you'll need to upgrade it in your NuGet client of choice. This is usually going to be in your IDE. Choose the approach that you prefer the most.

Upgrading in Visual Studio

  1. In Visual Studio, right click on the Bot C# project and choose "Manage NuGet Packages..."
  2. Click on the "Installed" tab. You should see a package called "RLBot.Framework".
  3. Upgrade to the latest 2.x version of RLBotDotNet.

Upgrading in Rider

  1. In Rider, right click on the Bot C# project and choose "Manage NuGet Packages".
  2. In the "Installed Packages" section, click on the package called "RLBot.Framework".
  3. Click the "Version" dropdown and select the latest 2.x version of RLBotDotNet.
  4. Click the Upgrade button next to the dropdown to upgrade.

Upgrading with the dotnet CLI

  1. In the command line, run dotnet remove package RLBot.Framework.
    • This needs to be run in the directory that contains your bot's csproj.
  2. Then run dotnet add package RLBot.Framework.
    • By default, this command adds the latest version of the package. If you want to add a specific version, add the --version flag (e.g. dotnet add package RLBot.Framework --version 2.0.0).

Taking care of breaking changes

After upgrading RLBotDotNet version, you'll need to take care of a few breaking changes.

System.Windows.Media.Color to System.Drawing.Color

The Renderer class now uses System.Drawing.Color.

Changes required

  • Remove the using System.Windows.Media; line and add using System.Drawing;.
  • Instead of System.Windows.Media.Colors.Black (or whatever color you're using), you need to use System.Drawing.Color.Black.
  • Instead of System.Windows.Media.Color.FromRgb(255, 255, 255), you need to use System.Drawing.Color.FromArgb(255, 255, 255).

Casing changed for fields in Bot class

The public fields name, team, and index are now called Name, Team, and Index. This is to keep them in line with common C# naming conventions.

Changes required

  • Rename name, team, and index to Name, Team, and Index respectively.
    • Your IDE will likely have a feature to quickly rename these symbols. If not, you can always use the find and replace feature.
    • The old name, team, and index fields have the Obsolete attribute, which will have a compile-time error if you try to use them. This makes it easier for you to find out where you need to rename the fields.