Any change made to build.cs results in compile error (tried UE5.1 and UE5.2)

‘’’
Registered restarted process N:_EPIC_Installs\UE_5.1\Engine\Binaries\Win64\UnrealEditor.exe (PID: 2184, previous PID: 12124)
Loading module N:_Unreal_Projects\SportsGame\Binaries\Win64\UnrealEditor-SportsGame.dll (0.085 MB)
Loaded 1 module(s) (0.000s, 5 translation units)
Live coding ready - Save changes and press CTRL+ALT+F11 to re-compile code
Manual recompile triggered
---------- Creating patch ----------
Running N:_EPIC_Installs\UE_5.1\Engine\Build\BatchFiles\Build.bat -Target=“SportsGameEditor Win64 Development -Project=”“N:/_Unreal_Projects/SportsGame/SportsGame.uproject”“” -LiveCoding -LiveCodingModules=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCodingModules.txt” -LiveCodingManifest=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCoding.json” -WaitMutex -LiveCodingLimit=100
Quick restart disabled when re-instancing is enabled.
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -Target=“SportsGameEditor Win64 Development -Project=”“N:/_Unreal_Projects/SportsGame/SportsGame.uproject”“” -LiveCoding -LiveCodingModules=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCodingModules.txt” -LiveCodingManifest=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCoding.json” -WaitMutex -LiveCodingLimit=100
Log file: C:\Users\MegaCorp\AppData\Local\UnrealBuildTool\Log.txt
Building SportsGameEditor…
Using Visual Studio 2022 14.33.31631 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Determining max actions to execute in parallel (4 physical cores, 8 logical cores)
Executing up to 4 processes, one per physical core
Building 5 actions with 4 processes…
[1/5] Compile SharedPCH.Engine.ShadowErrors.cpp
[2/5] Compile SportsGame.init.gen.cpp
[3/5] Compile SportsGame.cpp
[4/5] Compile SportsGameGameModeBase.gen.cpp
[5/5] Compile SportsGameGameModeBase.cpp
Total time in Parallel executor: 61.72 seconds
Total execution time: 63.27 seconds
File N:_Unreal_Projects\SportsGame\Intermediate\Build\Win64\SportsGameEditor\Development\Engine\SharedPCH.Engine.ShadowErrors.h.obj was modified or is new
File N:_Unreal_Projects\SportsGame\Intermediate\Build\Win64\UnrealEditor\Development\SportsGame\SportsGame.init.gen.cpp.obj was modified or is new
File N:_Unreal_Projects\SportsGame\Intermediate\Build\Win64\UnrealEditor\Development\SportsGame\SportsGameGameModeBase.gen.cpp.obj was modified or is new
File N:_Unreal_Projects\SportsGame\Intermediate\Build\Win64\UnrealEditor\Development\SportsGame\SportsGame.cpp.obj was modified or is new
File N:_Unreal_Projects\SportsGame\Intermediate\Build\Win64\UnrealEditor\Development\SportsGame\SportsGameGameModeBase.cpp.obj was modified or is new
Building patch from 5 file(s) for Live coding module N:_Unreal_Projects\SportsGame\Binaries\Win64\UnrealEditor-SportsGame.dll
Creating library N:_Unreal_Projects\SportsGame\Binaries\Win64\UnrealEditor-SportsGame.patch_0.lib and object N:_Unreal_Projects\SportsGame\Binaries\Win64\UnrealEditor-SportsGame.patch_0.exp
Successfully linked patch (0.000s)
Patch creation for module N:_Unreal_Projects\SportsGame\Binaries\Win64\UnrealEditor-SportsGame.dll successful (0.000s)
---------- Finished (0.000s) ----------
Manual recompile triggered
---------- Creating patch ----------
Running N:_EPIC_Installs\UE_5.1\Engine\Build\BatchFiles\Build.bat -Target=“SportsGameEditor Win64 Development -Project=”“N:/_Unreal_Projects/SportsGame/SportsGame.uproject”“” -LiveCoding -LiveCodingModules=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCodingModules.txt” -LiveCodingManifest=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCoding.json” -WaitMutex -LiveCodingLimit=100
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -Target=“SportsGameEditor Win64 Development -Project=”“N:/_Unreal_Projects/SportsGame/SportsGame.uproject”“” -LiveCoding -LiveCodingModules=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCodingModules.txt” -LiveCodingManifest=“N:/_EPIC_Installs/UE_5.1/Engine/Intermediate/LiveCoding.json” -WaitMutex -LiveCodingLimit=100
Log file: C:\Users\MegaCorp\AppData\Local\UnrealBuildTool\Log.txt
Invalidating makefile for SportsGameEditor (SportsGame.Build.cs modified)
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(3,27): error CS0246: The type or namespace name ‘ModuleRules’ could not be found (are you missing a using directive or an assembly reference?)
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(5,23): error CS0246: The type or namespace name ‘ReadOnlyTargetRules’ could not be found (are you missing a using directive or an assembly reference?)
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(5,53): error CS1729: ‘ModuleRules’ does not contain a constructor that takes 1 arguments
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(7,9): error CS0103: The name ‘PCHUsage’ does not exist in the current context
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(7,20): error CS0103: The name ‘PCHUsageMode’ does not exist in the current context
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(9,9): error CS0103: The name ‘PublicDependencyModuleNames’ does not exist in the current context
N:_Unreal_Projects\SportsGame\Source\SportsGame\SportsGame.Build.cs(11,9): error CS0103: The name ‘PrivateDependencyModuleNames’ does not exist in the current context
Expecting to find a type to be declared in a target rules named ‘SportsGameEditorTarget’. This type must derive from the ‘TargetRules’ type defined by Unreal Build Tool.
Build failed.
‘’’

This is the entire output log on my new project. I installed all the relevant addons etc. I am using VS2022 and I have set this to be the code editor inside UE5.

The error is created by saving the build.cs, even if I make no changes to it. On this occasion, all I added was a line with a comment “//” and saved it.

I have no idea how I can fix this error. But I need to alter the Build.cs so that I can learn the new “EnhancedInput” module.

For reference here is the actual build.cs file:

// Copyright Epic Games, Inc. All Rights Reserved.

public class SportsGame : ModuleRules
{
public SportsGame(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

    PrivateDependencyModuleNames.AddRange(new string[] { });

    //

    // Uncomment if you are using Slate UI
    // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

    // Uncomment if you are using online features
    // PrivateDependencyModuleNames.Add("OnlineSubsystem");

    // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}

}

1 Like

Turn off live coding and its popup window. Compile straight from the IDE.

Also if you are on visual studio try detaching debug, if it’s attached to the unreal process.

1 Like

Thanks for your help. But I went to Editor Settings and turned off “enable live coding”. But in the IDE I still get the same error when I build. Please see this image. Note at top the warning about Visual Studio Integration Tool. But I verified I DEFINITELY have that tool installed in Epic and it says “installed already to all compatible engines”.

Sadly I have to leave for work now so have to try again later. But I am sure I will need help again when I am home. Thanks again for your advice. (Also I am not sure how to detach the debug)

this is how to detach

here is a segment of code for the enhanced input module

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class yourGameName: ModuleRules
{
	public yourGameName(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" });

	}
}

I’ve also seen that some people put “EnhancedInput” in the private dependencies

Seems in your code you are missing

using UnrealBuildTool;

You would need to put in the namespace before the public & private dependency Module names for them to register correctly hence the error.

1 Like

I’ve turned off Live Coding. Detach was not an option available to me there, so I figure it is already not attached.

However I am having a very odd problem. When I add the line “using UnrealBuildTool”. CTRL-S to save it, the line I add is instantly deleted.

I am still worried about the warning at the top of VS2022 about not having the plugin installed, even though it is installed.

Try closing your project and changing it in the pure IDE. It would be trying to revert it while the project is running.

You can also try deleting the temp directories

  • Intermediate
  • DerivedDataCache
  • Binaries
  • .vs
  • Saved

.sln file

and from the uproject choosing “Generate Visual project files”

It will refresh the project and maybe stale files won’t be messing it up

1 Like

This is crazy. Even with Unreal closed. I opened the .sln file in VS2022. I type “using UnrealBuildTool;” at start of the build.cs file, save it, and it deletes it instantly.

If I type anything in the body, it saves fine. Could it be my configuration of VS2022? When I installed I chose “C++” instead of “General” (not the components part, but after in the “default language (or something like this)”.

You can use the modify visual studio install file to change packages in the visual studio installation. I’d post mine but they are in Polish so I’m not sure you’d be able to recognize the elements by icons alone.

In the game programming segment I do have the unreal expansion installed

1 Like

I believe all the components are correct but I post images here if you are kind enough to take a look:

But after setting the components when installing it, it gave me an option of something like “preferred language”. Normally I leave it as ‘General’ but for some reason I chose ‘C++’ this time around (I doubt that is really what caused this issue though.

In Games and graphics I have “Unreal Engine Installer” installed

I just created another fresh new project. I can confirm that the line “using UnrealBuildTool;” is present by default. If I make any change to this file however (even just adding a comment in the code block), i save it and the line about UnrealBuildTool is deleted.

Do you have any form of source control running in visual studio? Git or Perforce?

Nothing like that right now. Its a fresh install of VS2022. And UE5.1 (I tried with UE5.2 first but wen tback to 5.1 hoping it might help). I installed it all yesterday and AFAIK no other programs I have will be interferring with this.

Is it normal that “UnrealBuildTool” isn’t recognised in Intellisense/auto-type?
I confirm Live Coding is turned off, however maybe it has to do with Detaching as I just don’t have that detach option.

You could have code cleanup turned on in VS. It seems to strip the using command

Tools → Options → Text Editor → Code Cleanup
turn off “Run Code cleanup profile on save”

edit: You can only detach if you attach to a process or ran the project in debug mode.

2 Likes

Thank you this seems to be the issue!!! The solution to my original question is kind of a mixture between your answer here about Code Cleanup, aswell as the missing using and the other answers above.

Thanks for sticking with me, and answering so fast to get this working for me.

No problem. I’m happy you were able to get it up and running as intended. These types of roadblocks can be a bit discouraging, but you have to power through them :slight_smile:

Yeah man, hopefully I can get back into adding the EnhancedInput which is my next learning step. A year or two ago in UE4 I made a pretty complex multiplayer game which I successfully integrated with Steam and played with my friends around the country and abroad. But that was a while ago, and I forgot a lot of stuff since then.

Thanks again for your help. All the best!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.