How can I resolve the error "Couldn't find target rules file for target 'MyProjectName'" when building a project?

I received the same error (or at least very similar), after rebuilding everything nothing worked anymore ;D Let me know if you found what happened please :slight_smile:

So i’ve successfully built an engine. Created new sidescroller project like in this video Introduction to Programming | Live Training | Unreal Engine - YouTube but when i select a build project and hit build button i get next errors:

error MSB3073: The command "D:\UnrealEngine\Engine\Build\BatchFiles\Build.bat MyProject3Editor Win64 DebugGame" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp v4.0\V120\Microsoft.MakeFile.Targets	38
error : Couldn't find target rules file for target 'MyProject3Editor' in rules assembly 'MyProject3EditorModuleRules, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.	D:\UnrealEngine\Projects\MyProject3\Intermediate\ProjectFiles\EXEC

Can both of you please post these files from your Source directory?

YourGame.Build.cs

YourGame.Target.cs

This should help Epic to resolve this faster :slight_smile:

#Code Project

Do both of you have visual studio installed, and you meant to start a code-based project?

Did you start a code based project?

#Do You have VS Installed


Please reply to my answer so all the info is in one place (its called a Comment)


“Did you start a code based project? Yes, I did. BP project works fine.”

Do you have VS 2012 or 2013 installed?

Rama

Build.cs

public class MyProject3 : ModuleRules
{
	public MyProject3(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
	}
}

Target.cs

using UnrealBuildTool;
using System.Collections.Generic;

public class MyProject3Target : TargetRules
{
	public MyProject3Target(TargetInfo Target)
	{
		Type = TargetType.Game;
	}

	//
	// TargetRules interface.
	//

	public override void SetupBinaries(
		TargetInfo Target,
		ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
		ref List<string> OutExtraModuleNames
		)
	{
		OutExtraModuleNames.Add("MyProject3");
	}
}

Did you start a code based project?

Yes, I did. BP project works fine.

Hi, It is the directories.
You should save your project in its default directory.

I had same problem and solved when I put the project files in right place. (Link to problem)
The default directory:

(C:\Users\Usher\Documents\Unreal Projects)
Change (\UnrealEngine\Projects\MyProject3) to (C:\Users\Usher\Documents\Unreal Projects\MyProject3)

I hope that it would work for you.

I had the exact same issue and I found a really easy way to fix it.

I created a Projects folder within the root directory of UE4. Inside that folder I created a C++ project from the side scroller template (like in the video). When I build I get the same error. Here’s the really easy fix.

Create a new file inside UE4 root folder and name it Games.uprojectdirs. Edit the file and write Projects (the name of your folder where the projects are). And that’s it UnrealBuildTool will pick all your projects inside that folder.

My SSD can rest in peace now…

Here’s what my UE4 folder looks like :

5527-ueroot.png

This worked perfectly for me. Thanks Madmaurice for a nice solution :slight_smile:

PS. if you’re interested in why this fix works, check UnrealEngine\Engine\Source\Runtime\Core\Private\Misc\UProjectInfo.cpp around line 25

I am having this same issue but confuse how to implement this solution. I have the engine root in my D:/ drive and the project in G:/ drive. It knows the project path, but what would I type in the Games.uprojectdirs file?

Would it be:
G:/Projects/MyProject ?

I am going to guess you have got this answered after 6 months but I’m replying so if others encounter the same issue they can at least reference this comment.

So, “yes” is effectively my answer. However the image in madmaurice’s post shows far more files that I have in that directory. In fact in the root of my install dir there are NO FILES, just folders although they do match the ones shown above (Engine/Projects/Samples/Templates).

My boot drive is "D:" and my UE is installed “D:\Program Files\Epic Games\UE_4.14” - my projects directory (for everything not just UE) is “D:\Projects”.

If I create a file called Games.uprojectdirs (all I did was right click, create text file, edited the filename) and add in one line…

D:\Projects\Unreal

…then save it, my project will not only open and compile it will bring up the Editor and VS - something it did not before the addition of this file. No longer do I get the “ERROR: Couldn’t find target rules file for target” prompt.

So for you, if you still have that issue, you would just change the D:\Projects\Unreal to G:\Projects\MyProject (remember back slashes in the OS, forward slashes for web addresses).

Hope this comment helps someone because I spent a week tearing my hair out trying to get this working and there is very little documentation to tell you about the Games.uprojectdirs file.

D:\Project\Unreal , D is your directory , Project is your Folder where your project is , Unreal is your project name ?

If i have my Project name as : “Experiment1” , then my path will be

“D:\Project\Experiment1” ???

or am i doing something wrong ?

I had this issue when creating projects on one of my computers. For some reason projects created on one of the computers create the following setting in the .uproject file (just open it with a text editor):

“Enterprise”: true,
I removed the setting from the .uproject file and now it compiles.

that worked for me too, I guess when I install launcher, it can be enterprise or not. On some machines it is and others its not, so jumping between them was an issue, until I removed this line. That being said, I am not using datasmith etc in my project.

This also worked for me. I wonder how that “Enterprise” setting got in there, and what does it mean?

It means this project is using Unreal Studio(Datasmith). UnrealEngine now is a complicated beast, a little hidden problem drives me crazy.

…solved my issue …thanks … : ) ,