-
Notifications
You must be signed in to change notification settings - Fork 21
Upgrading to RLBotDotNet 2.x
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.
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.
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.
- In Visual Studio, right click on the Bot C# project and choose "Manage NuGet Packages..."
- Click on the "Installed" tab. You should see a package called "RLBot.Framework".
- Upgrade to the latest 2.x version of RLBotDotNet.
- In Rider, right click on the Bot C# project and choose "Manage NuGet Packages".
- In the "Installed Packages" section, click on the package called "RLBot.Framework".
- Click the "Version" dropdown and select the latest 2.x version of RLBotDotNet.
- Click the Upgrade button next to the dropdown to upgrade.
- In the command line, run
dotnet remove package RLBot.Framework
.- This needs to be run in the directory that contains your bot's csproj.
- 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
).
- By default, this command adds the latest version of the package. If you want to add a specific version, add the
After upgrading RLBotDotNet version, you'll need to take care of a few breaking changes.
The Renderer
class now uses System.Drawing.Color
.
- Remove the
using System.Windows.Media;
line and addusing System.Drawing;
. - Instead of
System.Windows.Media.Colors.Black
(or whatever color you're using), you need to useSystem.Drawing.Color.Black
. - Instead of
System.Windows.Media.Color.FromRgb(255, 255, 255)
, you need to useSystem.Drawing.Color.FromArgb(255, 255, 255)
.
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.
- Rename
name
,team
, andindex
toName
,Team
, andIndex
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
, andindex
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.