Can't package project due to an unknown error

I am using UE4.12.

I can’t package my project, when I try to it I get this error:

MainFrameActions: Packaging (Windows (64-bit)): Project.Build: ********** BUILD COMMAND STARTED **********
MainFrameActions: Packaging (Windows (64-bit)): CommandUtils.Run: Run: C:\Program Files\Epic Games\4.12\Engine\Binaries\DotNET\UnrealBuildTool.exe Subject_A119 Win64 Shipping -Project=E:\Unreal_Game\Subject_A119\Subject_A119.uproject  E:\Unreal_Game\Subject_A119\Subject_A119.uproject  -remoteini="E:\Unreal_Game\Subject_A119" -noxge -generatemanifest -NoHotRe
loadFromIDE
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool: ERROR: System.UnauthorizedAccessException: Access to the path 'C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\LastBuiltTargets.txt' is denied.
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    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)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    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)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
MainFrameActions: Packaging (Windows (64-bit)): UnrealBuildTool:    at UnrealBuildTool.UnrealBuildTool.RunUBT(String[] Arguments, FileReference ProjectFile)
MainFrameActions: Packaging (Windows (64-bit)): CommandUtils.Run: Run: Took 0,9673181s to run UnrealBuildTool.exe, ExitCode=5
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: ERROR: AutomationTool terminated with exception: AutomationTool.AutomationException: Command failed (Result:5): C:\Program Files\Epic Games\4.12\Engine\Binaries\DotNET\UnrealBuildTool.exe Subject_A119 Win64 Shipping -Project=E:\Unreal_Game\Subject_A119\Subject_A119.uproject  E:\Unreal_Game\Subject
_A119\Subject_A119.uproject  -remoteini="E:\Unreal_Game\Subject_A119" -noxge -generatemanifest -NoHotReloadFromIDE. See logfile for details: 'UnrealBuildTool-2016.07.25-01.51.41.txt' 
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.CommandUtils.RunAndLog(String App, String CommandLine, String Logfile, Int32 MaxSuccessCode, String Input, ERunOptions Options, Dictionary`2 EnvVars)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.CommandUtils.RunUBT(CommandEnvironment Env, String UBTExecutable, String Comma
MainFrameActions: Packaging (Windows (64-bit)): ndLine, String LogName, Dictionary`2 EnvVars)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.UE4Build.BuildWithUBT(String TargetName, UnrealTargetPlatform TargetPlatform, String Config, FileReference UprojectPath, Boolean ForceMonolithic, Boolean ForceNonUnity, Boolean ForceDebugInfo, Boolean ForceFlushMac, Boolean DisableXGE, String InAddArgs, Boolean ForceUnity, Dictionary`2 EnvV
ars)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.UE4Build.Build(BuildAgenda Agenda, Nullable`1 InDeleteBuildProducts, Boolean InUpdateVersionFiles, Boolean InForceNoXGE, Boolean InUseParallelExecutor, Boolean InForceNonUnity, Boolean InForceUnity, Boolean InShowProgress, Dictionary`2 PlatformEnvVars, Nullable`1 InChangelistNumberOverride,
 Dictionary`2 InTargetToManifest)
MainFrameActions: Packaging (Windows (64-bit)):    at Project.Build(BuildCommand Command, ProjectParams Params, Int32 WorkingCL, ProjectBuildTargets TargetMask)
MainFrameActions: Packaging (Windows (64-bit)):    at BuildCookRun.DoBuildCookRun(ProjectParams Params)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.BuildCommand.Execute()
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.Automation.Execute(List`1 CommandsToExecute, CaselessDictionary`1 Commands)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.Automation.Process(String[] CommandLine)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.Program.MainProc(Object Param)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.InternalUtils.RunSingleInstance(Func`2 Main, Object Param)
MainFrameActions: Packaging (Windows (64-bit)):    at AutomationTool.Program.Main()
MainFrameActions: Packaging (Windows (64-bit)): Program.Main: AutomationTool exiting with ExitCode=5 (5)
MainFrameActions: Packaging (Windows (64-bit)): Domain_ProcessExit
MainFrameActions: Packaging (Windows (64-bit)): copying UAT log files...
MainFrameActions: Packaging (Windows (64-bit)): BUILD FAILED
PackagingResults:Error: Error Unknown Error

When I try to create a new C++ project I get this error:

Running C:/Program Files/Epic Games/4.12/Engine/Binaries/DotNET/UnrealBuildTool.exe MyProject3 Development Win64 -project="E:/Unreal_Game/Test/MyProject3/MyProject3.uproject" -editorrecompile -progress -noubtmakefiles -NoHotReloadFromIDE
 @progress push 5%
Parsing headers for MyProject3Editor
  Running UnrealHeaderTool "E:\Unreal_Game\Test\MyProject3\MyProject3.uproject" "E:\Unreal_Game\Test\MyProject3\Intermediate\Build\Win64\MyProject3Editor\Development\MyProject3Editor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Reflection code generated for MyProject3Editor in 5,0535425 seconds
 @progress pop
Performing 7 actions (4 in parallel)
[3/7] Resource ModuleVersionResource.rc.inl
[2/7] Resource PCLaunch.rc
PCH.MyProject3.h.cpp
MyProject3GameMode.cpp
MyProject3.cpp
E:\Unreal_Game\Test\MyProject3\Source\MyProject3\MyProject3.cpp: error C4599: '/IE:\Visual Studio\VC\INCLUDE': command line argument number 261 does not match precompiled headerE:\Unreal_Game\Test\MyProject3\Source\MyProject3\MyProject3GameMode.cpp: error C4599: '/IE:\Visual Studio\VC\INCLUDE': command line argument number 261 does not match precompiled header

MyProject3.generated.cpp
E:\Unreal_Game\Test\MyProject3\Intermediate\Build\Win64\UE4Editor\Inc\MyProject3\MyProject3.generated.cpp: error C4599: '/IE:\Visual Studio\VC\INCLUDE': command line argument number 261 does not match precompiled header
ERROR: UBT ERROR: Failed to produce item: E:\Unreal_Game\Test\MyProject3\Binaries\Win64\UE4Editor-MyProject3.dll
Total build time: 62,59 seconds

I opened it with administrator rights.

I am using Visual Studio Community update 3.

Hello MrGoatsy,

What drive is your Visual Studio installed on? Is it the same drive that your Windows is installed on? From looking at the log it looks like it’s installed on a drive called IE:\ which could be part of these problems. If it is on the same drive, can you try disabling any firewall or virus protection programs and compiling once more? There are a few programs that cause some issues with compiling due to false positives. For reference, here’s a list of all of the known software conflicts.

It isn’t on the same drive, it is on an external HDD.

I think it might be due to update 3, it doesn’t seem to be compatible with UE4.12 according to other questions on the answerhub.

That would be correct. If you’re on 4.12.0 you’ll need to upgrade to 4.12.5, as Update 3 released officially during, I believe, 4.12.3’s lifespan. We made updates to support it with 4.12.5.

I’ve also never had Visual Studio installed on a drive separate from my Windows installation but that could be an issue as well since Visual Studio relies on some files from System32.

I will update UE4 tonight and I will let you know if it worked.

I get this error after trying to package the project in UE4.12.5: http:///UJTJ2QeE

That fixed it, could you post it as an answer so I can accept it?

All done. Thank you for giving it a try. Have a good day!