Building UE4 from source [error MSB3073 The command "..\..\Build\BatchFiles\Build.bat DatasmithSDK ...." exited with code 6

The long answer

Since it’s a good exercise I’ll explain how I found the fix for learning purposes, may this story help you solve other issues.

At first the error does not tell you much, if you analyze it, it says some script Build\BatchFiles\Build.bat failed and exited with error code 6. It may not even be clear what are the arguments if you are unfamiliar with UE.

So you might take a look at “C:\UE\Engine\Build\BatchFiles\Build.bat” and see it executes UnrealBuildTool.exe which means it’s actually UnrealBuildTool.exe which is failing and returning error code 6. The documentation says nothing about the meaning of code 6 so you may remember UE has its own build tool then look around and find C:\UE\Engine\Programs\UnrealBuildTool\Log.txt which contains the details of the last execution of UnrealBuildTool.exe by the look of the file’s timestamp:

//C:\UE\Engine\Programs\UnrealBuildTool\Log.txt
ParallelExecutor.ExecuteActions:   [46/46] Executing post build script (PostBuild-1.bat)
ParallelExecutor.ExecuteActions:   Copying C:\UE\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSDK\Documentation\*.* to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Documentation\
ParallelExecutor.ExecuteActions:   invalid number of parameters
ParallelExecutor.ExecuteActions:   Copying C:\UE\Engine\Source\Runtime\Datasmith\DatasmithCore\Public\*.h to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Public\
ParallelExecutor.ExecuteActions:   invalid number of parameters
ParallelExecutor.ExecuteActions:   Copying C:\UE\Engine\Source\Developer\Datasmith\DatasmithExporter\Public\*.h to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Public\
ParallelExecutor.ExecuteActions:   invalid number of parameters
UnrealBuildTool.Main: CompilationResultException: Error: OtherCompilationError
UnrealBuildTool.Main:    in UnrealBuildTool.ActionGraph.ExecuteActions(BuildConfiguration BuildConfiguration, List`1 ActionsToExecute) in C:\UE\Engine\Source\Programs\UnrealBuildTool\System\ActionGraph.cs:line 242
UnrealBuildTool.Main:    in UnrealBuildTool.BuildMode.Build(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options, FileReference WriteOutdatedActionsFile) in C:\UE\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 372
UnrealBuildTool.Main:    in UnrealBuildTool.BuildMode.Execute(CommandLineArguments Arguments) in C:\UE\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 219
UnrealBuildTool.Main:    in UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in C:\UE\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 550

Too focused about UnrealBuildTool.exe instead of researching the first error “invalid number of parameters” (which I should have) I only look at “UnrealBuildTool.Main: CompilationResultException: Error: OtherCompilationError” so now I know the return code 6 for UnrealBuildTool.exe means OtherCompilationError. I waste some more time and I go look at the code of UnrealBuildTool.exe in C:\UE\Engine\Source\Programs\UnrealBuildTool it’s C# and the entry point of the program is in UnrealBuildTool.cs I look for the word OtherCompilationError inside but it does not give me much info. I give up this lead.

Now, if I go back to visual studio and instead of looking at the Error List tab (which only gives me a very short and obscure message

error MSB3073 The command "..\..\Build\BatchFiles\Build.bat DatasmithSDK blabla" exited with code 6. 

I should have went straight to the detailed errors in the Output tab where it shows:

3>  [45/46] DatasmithSDK.target
3>  [46/46] Executing post build script (PostBuild-1.bat)
3>  Copying C:\UE\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSDK\Documentation\*.* to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Documentation\
3>  invalid number of parameters
3>  Copying C:\UE\Engine\Source\Runtime\Datasmith\DatasmithCore\Public\*.h to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Public\
3>  invalid number of parameters
3>  Copying C:\UE\Engine\Source\Developer\Datasmith\DatasmithExporter\Public\*.h to C:\UE\Engine\Binaries\Win64\DatasmithSDK\Public\
3>  invalid number of parameters

Which is the same message I previously missed in the Unreal Build Tool Log.txt arf… It clearly says it’s attempting to copy some files from some location to another. It involves a project called “Datasmith” and if I look in the solution explorer of visual studio there is a project in programs/Datasmith/DatasmithSDK. I try to rebuild this specific project instead of the whole solution (the later is excruciating slow). Bingo, the error shows up again, well at least now I can quickly recompile this part and try various things. First I make sure files and folders are no read only. Recompiles … Nope. Then after some random search I figure out where this copy is specified: it’s in the build configuration file DatasmithSDK.Target.cs it’s calling the command xcopy and by the looks of it does not wrap the file paths with extra quotes and so it does not correctly parse file paths containing spaces! This is a mistakes I’ve made myself countless times aha! Hooray :slight_smile:

To summarize with this we’ve learned: how to find the build scripts of UE, where are the logs of Unreal Build Tool, overall get familiar with part of the folder structure of UE’s (modules and separate programs build tools) and pinpoint and only compile where the error comes from. But above all we’ve learned that we should better read the details of error messages… I could have went straight to where xcopy was just by looking up the string “Runtime\Datasmith\DatasmithCore\Public” if I had better read the error log and a bit of luck.

8 Likes