In this lesson, we’ll upgrade the project to use .NET 5.
Some of you created your projects with .NET 5. If so, you can skip this lesson.
I tried to use the upgrade assistant from Microsoft, but it didn’t work. So, here are the manual steps I used.
Step 1:Install .NET 5
If you don’t already have .NET 5 installed, follow these steps:
1. Run Visual Studio Installer
2. Click the “Modify” button
3. Check “.NET 5 Runtime”
4. Click the “Modify” button in the lower-right corner
5. Wait for the installation to finish, then close Visual Studio Installer
Step 2: Rename your SOSCSRPG solution directory
Since these changes might fail, rename your existing SOSCSRPG folder to something like SOSCSRPG_BACKUP.
Step 3: Create a new SOSCSRPG solution, with empty .NET 5 projects
Start Visual Studio and select “Create a new project”
Set your template search criteria to “C#” and “WPF” and select the project that says “WPF Application – A project for creating a .NET Core Application”.
Set the project name to “WPFUI” and the solution name to “SOSCSRPG”. If you named your solution and project something else, use the same names from your original solution. This will help when we copy the old files to the new solution – they expect the same project/namespace name.
When the solution is created, add a class library project “Engine” (or whatever name you used for your Engine project).
Be sure to select the “Class library” project option that says, “A project for creating a class library that targets .NET Standard or .NET Core”.
To finish setting up the solution:
1. Delete the Class1.cs class from the Engine project.
2. Add a project reference from the WPFUI project to the Engine project.
3. Shut down Visual Studio
Step 4: Copy files from old projects to new projects
Copy the \Docs folder from the original solution’s directory to the new solution’s directory.
Copy the files and folders from the old projects to the new projects EXCEPT for these:
Step 5: Add NuGet references
In the Engine project, add the latest versions of these NuGet packages:
Step 6: Set GameData and Images to copy during the build
In the Engine folder, set the “Copy to Output Directory” property on the files in the \GameData, \Images\Locations, and \Images\Monsters directories to “Copy if newer”.
Step 7: Test that the game builds and runs
If your game does not run, please leave a message with the error message that’s happening.
NEXT LESSON: Lesson 19.2: Identifying refactoring targets
PREVIOUS LESSON: Lesson 18.5: Update game loading and saving