Download

UE4 C++ Migration to UE5 - Issue with a Plugin Build CS File... (Regex)

So I’ve gotten through 90% of the hump to migrate a UE4 C++ Project to UE5.

However, I have one last issue with a plugin (which is absolutely a must-have for the project) that is not playing happy with the build tool.

This plugin’s .Build.cs file uses System.Text.RegularExpressions to invoke some Regex and it seems to be upsetting the UE5 Build Tool for some reason.

error CS1069: The type name 'Regex' could not be found in the namespace 'System.Text.RegularExpressions'. This type has been forwarded to assembly 'System.Text.RegularExpressions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

If anyone has any idea, that would be great.

1 Like

The error message
error CS1069: The type name ‘Regex’ could not be found in the namespace ‘System.Text.RegularExpressions’.
This type has been forwarded to assembly 'System.Text.RegularExpressions, Version=4.2.2.0,

The error may be due to the fact that Version=4.2.2.0 is looking for does not exist, or 4.3does not exist in Unreal 5.0EA

see C:\Users\Owner\source\repos\UE50EA\Engine\Binaries\ThirdParty\DotNet\Windows\sdk\3.1.403\Microsoft\Microsoft.NET.Build.Extensions\net461\lib
and UE4 probably uses 4.2.2.0 which is very old

You can get the latest one from NuGet Gallery | System.Text.RegularExpressions 4.3.1

It is quite possible you are missing the latest version and the compiler is using an older version found on your system.

I assume you have tried removing the reference to System.Text.RegularExpressions and adding it back

replacing in the code

using System.Text.RegularExpressions

with a later reference using the prompter to select the right version of System.Text.RegularExpressions.dll

Off topic slightly for any one else is in Epic Marketplace
Regex in Blueprints author offers the source code in answer to the a question

see Regex in Blueprints in Code Plugins - UE Marketplace

Without seeing the code I can really give a fix to the problem

1 Like

Hi Jimbohalo10,

Thanks for the assistance!

Unfortunately, I have tried the following and am still getting the same output on the UBT:

  1. Updated System.Text.RegularExpressions with the latest NuGet package’s version (I noticed using IL DASM even then that DLL version is only 4.1.0.0)
  2. Updated .NET (already at 5.0 on my local)
  3. Installed VS Build Tools, as I heard on some other UE issues that that helped.
  4. Updated the C# file itself to move the includes around.

Still no luck sadly, still get the error

 error CS1069: The type name 'Regex' could not be found in the namespace 'System.Text.RegularExpressions'. This type has been forwarded to assembly 'System.Text.RegularExpressions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

Is there a way to check what .NET Version is being targeted by the UBT, or any other configuration which may be missing?

I am unable to find what .NET version UBT targets. In the picture below is all the ways I have to check the .NET loaded on my system.

On the left is my Visual Studio 2019 Showing all the .NET SDK and targeting packs
On the right is Windows Features in Windows 10 and in the bottom right is the .NET Core Frameworks loaded directories stored in C:\Windows\Microsoft.NET\Framework.

I suspect the problem is something missing is the Visual Studio 2019 as that what has happened in past.

Unfortuantely, still no luck.

I checked my Windows Features which looks identical to yours, and I also updated VS 2019 to include the above targeting packs (although most were there).

Unfortunately non helped. Exact same issue.

I suspect I will be waiting for Epic to release an update to 5.0EA. Unfortunately, I haven’t come across anyone else with this issue so it’s really hard to see if it is on their radar or not.

Hi, Reach_Adrian

We are seeing the exact same issue with UE5 EarlyAccess and RegEx.

I’ve added a question on my own as I couldn’t find anything similar at the time of writing (link here).

I just wanted to let you know we are struggling with the same and we still have no resolution.
Waiting for Epic to respond and in the meantime, we will try to replace our regex usages with non-regex equivalent :roll_eyes:

If you are building from source, then you can fix this by modifying to /Engine/Source/Programs/UnrealBuildTool/System/DynamicCompilation.cs.

Inside UnrealBuildTool.DynamicCompilation.CompileAssembly(...) (somewhere around Line 230) is where several reference assemblies are specified.
We can add our dependency like this:

MetadataReferences.Add(MetadataReference.CreateFromFile(Assembly.Load("System.Text.RegularExpressions").Location));
4 Likes

@UndeadIGood

Thanks for the feedback. I have made the change into the file located at ...\UE_5.0EA\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs and yet I am still getting the build error:

ERROR: ...\Plugins\<PLUGIN_NAME>\Source\<PLUGIN_NAME>\<PLUGIN_NAME>.Build.cs(70,31): error CS1069: The type name 'Regex' could not be found in the namespace 'System.Text.RegularExpressions'. This type has been forwarded to assembly 'System.Text.RegularExpressions, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
ERROR: Expecting to find a type to be declared in a target rules named 'GameNameTarget'.  This type must derive from the 'TargetRules' type defined by Unreal Build Tool.

Do I need to do anything else to rebuild UnrealBuildTool?

Huh. That doesn’t look like it’s helped you at all :sweat:

But I’d say that error suggests that UBT is not getting rebuilt with your changes.
You may be able to debug UBT using Visual Studio by…

  • setting UnrealBuildTool as your startup project
  • selecting Debug Win64 as your target configuration & platform
  • specifying these in the UBT C# project Debug settings:
    • Application arguments: -ProjectFiles *
    • Working directory: C:\my_root\Engine\Source
      (this will be different for you; you will find files like UnrealEditor.Target.cs inside)

Hi,
Have you got an file YourApp.exe.config.xml. Where YouApp.exe is your name of the executable
containing

<?xml version="1.0"?>

if that does not work change Version=2.0.0.0 to Version=4.2.2.0 or finally Version=4.6.2.0

Have you right clicked the solution and check properties to see the correct 4.2.2.0 is being referenced. VS 2022 preview found the bug for me!

In the References section to the solution project right click and check that System.Text.RegularExpressions is in the list of references

I have run out of ideas and just saw this on another program, maybe its to load Regex into an executable.

Just a quick heads up and a big thanks: Your solution worked like a charm. I did have to ensure that the project of UBT is rebuilt by cleaning and building it manually. Once that was done I was able to generate the project files just fine! :smiley: