Compile In Editor "FileNotFoundException" Compiler Can't Find UProject File

I’m getting this callstack:

          at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in D:\PROJECT_NAME\UnrealEngine-4.21.1-release\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1136
ERROR: System.IO.FileNotFoundException: Could not find file 'D:\PROJECT_NAME\PROJECT_NAME.uproject'.
       File name: 'D:\PROJECT_NAME\PROJECT_NAME.uproject'
          at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
          at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
          at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
          at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
          at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
          at Tools.DotNETCommon.JsonObject.Read(FileReference File) in D:\PROJECT_NAME\UnrealEngine-4.21.1-release\Engine\Source\Programs\DotNETCommon\DotNETUtilities\JsonObject.cs:line 50
          at UnrealBuildTool.ProjectDescriptor.FromFile(FileReference FileName) in D:\PROJECT_NAME\UnrealEngine-4.21.1-release\Engine\Source\Programs\UnrealBuildTool\System\ProjectDescriptor.cs:line 184
          at UnrealBuildTool.RulesCompiler.CreateProjectRulesAssembly(FileReference ProjectFileName, Boolean bUsePrecompiled, Boolean bSkipCompile) in D:\PROJECT_NAME\UnrealEngine-4.21.1-release\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 348
          at UnrealBuildTool.TargetDescriptor.ParseCommandLine(String[] Arguments, Boolean bUsePrecompiled, Boolean bSkipRulesCompile, FileReference& ProjectFile) in D:\PROJECT_NAME\UnrealEngine-4.21.1-release\Engine\Source\Programs\UnrealBuildTool\Configuration\TargetDescriptor.cs:line 180

The issue is that somewhere in the build process, it is deciding to go up one extra folder.

At the very top, it says the project is not at the path “D:\PROJECT_NAME\PROJECT_NAME.uproject”

This is true. It’s at “D:\PROJECT_NAME\PROJECT_NAME\PROJECT_NAME.uproject”

I have deleted the contents of the saved folder, the vs folder, the intermediate folder, regenerated project files multiple times, done several checks over all the VCXProj files, all the directories pointing to this file are CORRECT.

I even tried moving everything to that folder and regenerating project files, and when I did it started telling me it couldn’t find “D:\PROJECT_NAME.uproject”.

So it’s consistently looking one folder up, and I have NO Idea why.

It’s also worth noting that compiling from visual studio works perfectly fine. Even when using the unrealbuildtool.

Did you tried to package it trough project launcher to see if the compiler will have that error?

If you try, post the screenshot here, I will be checking it tomorrow

The build process in packaging works fine, too, from the editor. No errors.

I’m having the same issue. I’ve been stepping through UnrealBuildTool.cs and I’m seeing weird behavior with FileReference and FullName.

Line 316 of UnrealBuildTool.cs assigns ProjectFile by creating a new FileReference.

FileReference.cs line 30, with the parameter

InPath = “…/…/…/project_name/project_name”

public FileReference(string InPath)
: base(Path.GetFullPath(InPath))
{
if(FullName[FullName.Length - 1] == ‘\’ || FullName[FullName.Length - 1] == ‘/’)
{
throw new ArgumentException(“File names may not be terminated by a path separator character”);
}
}

As soon as the base constructor is called, FullName is set to an incorrect value.

Path.GetFullPath(InPath) returns “E:\Projects\project_name\project_name\project_name.uproject”

That is the correct location. However, FullName is set to an incorrect location, one directory higher.

FullName “E:\Projects\project_name\project_name.uproject”