VSCode build error

Building a C++ project with VSCode on 4.18 fails. System is Windows 10.
Output log here:

Cleaning MyProject Binaries...
Performing full C++ include scan (building a new target)
ERROR: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Epic Games\UE_4.18\Engine\Source\Projects\MyProject\MyProject.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)
          at UnrealBuildTool.ProjectDescriptor.FromFile(FileReference FileName)
          at UnrealBuildTool.RulesCompiler.CreateProjectRulesAssembly(FileReference ProjectFileName)
          at UnrealBuildTool.UEBuildTarget.CreateTarget(TargetDescriptor Desc, String[] Arguments, Boolean bCompilingSingleFile)
          at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile)

Terminal will be reused by tasks, press any key to close it.

I got same error and it was caused by a “space” character in the path to my project.

I had it in:

 C:/Users/Me/Documents/Unreal Projects/GameA/

Had to change this to:

 C:/Users/Me/Documents/UnrealProjects/GameA/

What a bizarre fix - thank you sir!

There shouldn’t be any problems with engine/project paths containing spaces. The default install location for both the engine AND a new project will both contain them :slight_smile: What does look suspicious about your example is that you’ve put your project inside the UE4\Engine\Source directory, which is a little unusual.

Just out of curiosity, what happens if you move your project ourside of the UE4 install directory, say to your documents folder, and try again from there! I do see that MirrorNext’s example is exactly that, which is pretty confusing so it’d be interesting to see if your example is the same!

The path being printed as inside the engine source is caused by the bat file and that is caused by the space in the project folder. So, neither or our projects are actually inside the engine folder. The error log just wrongly prints it like it is.

The bat file is doing a pushd which is causing it so print as it being inside the engine source.

Moving my project to a path without spaces fixed the issue.

Just had the same problem, solved it for me also. Thanks alot!

I also faced the same issue, but not in my Visual Studio. When I tried Generating the Visual Studio Code files by right clicking on my .uproject file of my project, I recieved this error,

***at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                  at System.IO.FileSystemEnumerableIterator`1.CommonInit()
                  at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
                  at System.IO.Directory.EnumerateFiles(String path, String searchPattern)
                  at UnrealBuildTool.VCProjectFile.WriteProjectFile(List`1 InPlatforms, List`1 InConfigurations, PlatformProjectGeneratorCollection PlatformProjectGenerators) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProject.cs:line 1212
                  at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2686
                  at UnrealBuildTool.VCProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProjectFileGenerator.cs:line 436
                  at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String[] Arguments) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1045
                  at UnrealBuildTool.GenerateProjectFilesMode.Execute(CommandLineArguments Arguments) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 198
                  at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 550***