Press "Enter" to skip to content

Lesson 19.1: Converting SOSCSRPG to .NET 5

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:
\bin
\obj
\properties
*.csproj

Step 5: Add NuGet references

In the Engine project, add the latest versions of these NuGet packages:
Newtonsoft.Json
D20Tek.Common.Standard
D20Tek.DiceNotation.Standard

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

8 Comments

  1. Ted Bunny
    Ted Bunny 2022-02-03

    Is there a way to push this to my old GitHub repository, or will I have to make a new one? I don’t want to lose commit history.

    • SOSCSRPG
      SOSCSRPG 2022-02-03

      There probably is a way to do that, but I don’t know the Git commands/parameters that would let you do that.

      You might be able to cheat by copying the .git and .github directories from the old solution, along with the .gitattributes and .gitignore files. But, that might also cause problems. If you try that, be sure to copy your current .NET 5 files to a backup directory first.

  2. Gary Woodward
    Gary Woodward 2024-05-05

    Hi Scott
    Weird how this works ok. Also, in my version .Net 5.0 is out of support. I think i created my original project in .Net 8.0.
    Im getting a lot of errors regarding WPFUI CS010 The name does not exist in the current context
    and CS860/861/862 warnings about Nullable fields
    and
    Warning NETSDK1138 The target framework ‘net5.0-windows’ is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. WPFUI
    Should I just revert to my original .Net 8.0?

    • SOSCSRPG
      SOSCSRPG 2024-05-06

      These lessons were written several years ago. Microsoft have released new versions of .NET since then. After a certain number of years, they don’t support older versions. The older versions still work, but they will not receive any new updates. That’s what the message is telling you.

      The warning about nullable fields is about how Microsoft prefers to do things nowadays. Your program will still work, they just like to do things differently now, which is why they show the warning. If you continue writing programs, you will probably want to follow the suggestions in most warnings. However, companies (and individual programmers) generally develop their own “programming standards” for the programs they write. The important thing is to use the same standards throughout your program.

  3. Jonathan Rodriguez
    Jonathan Rodriguez 2024-05-23

    Hi Scott,

    It’s obligatory to update to runtime 5.0. I have some problems with the update; I got many errors and I don’t know how to fix them. I have my project on runtime 4.0. If I don’t do the update, can I continue the project?

    • SOSCSRPG
      SOSCSRPG 2024-05-23

      Hi Jonathan,

      These lessons are from several years ago. You may also be able to update to .NET 8, if that’s available.

      Can you please upload your solution (including the directories under it, and all the files in those directories) to GitHub, Dropbox, or some other file-sharing location so I can look at it?

      If you haven’t used GitHub before, here is a video on how to upload your solution to GitHub and share it with me. https://youtu.be/0si9ElYQv8I

      • Jonathan Rodriguez
        Jonathan Rodriguez 2024-05-23

        Ok , I give you acces , my account it’s Balsero , and RPG-GAME it’s de backup and Super-Adventure it’s the proyect with the runtime update.

        • SOSCSRPG
          SOSCSRPG 2024-05-24

          I think I found the problem. In the “Factories” folder of the “Engine” project, there is a “Super Adventure” folder with an extra copy of the some of the files. When I deleted that extra “Super Adventure” folder, the program was able to compile.

          Please let me know if that doesn’t fix things for you.

Leave a Reply

Your email address will not be published. Required fields are marked *