How to generate Unreal visual studio solution files into specific folders

I am on Windows 10 and Unreal 4.15

When I right click Unreal project to generate visual studio solution files, there is no option to change output directory and it always goes to the same folder as the project file, which means the source files and the build files are mixed together. For traditional C++ projects where the build files are generated by CMake, we can do something like

*mkdir build
cd build
cmake -A x64 …
msbuild test.sln *

The build files and source files are separated. Is it possible to do this kind of good practice for Unreal Projects? Below is the command line I am currently using to generate the build files for Unreal

UnrealBuildTool.exe -projectfiles -project=“%WORKSPACE%/projectname/projectname.uproject” -game -rocket -progress

If everything else fails make a symbolic link pointing where you want.

Thank you for the reply. For symbolic link, is that before the build or after the build? Could you please provide more details about how to make it work?

The Visual Studio .sln is really just for humans. Internally, the Unreal Build Tool(UBT) handles all building for you.

I recommend you leave the Source structure intact exactly as it is.

The .sln is just there to help you use Visual Studio to browse code.

Thank you for your reply. If keep the source structure, when using UBT to build visual studio solution file, do you know how to use relative path? like:

UnrealBuildTool.exe -projectfiles -project=“projectname/projectname.uproject” -game -rocket -progress

Because I am using jenkins to do the automation for Unreal project and I don’t want to use full path for building.

On jenkins u can use relative path together with build variables

-project="%WORKSPACE%/projectname/projectname.uproject"

For jenkins, i have multiple engine branches checked out / pre-build, which each have a system variables.
I used to include UE4 builds into my jenkins project or artifact them and use artifact from other project for it, but it just using up to much resources for something that does not change.
So its better to just manually build the engine and link to it.

Here is sample script for one of the jenkins jobs



@echo off

set PROJECT=SwatReloaded

call "%UE4_13_ROOT%\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun -project="%WORKSPACE%/%PROJECT%.uproject" -rocket -noP4 -platform=Win64 -clientconfig=DebugGame -serverconfig=DebugGame -clean -build -cook -allmaps -pak -archive -archivedirectory="%WORKSPACE%/Release"


Where u can artifact the entire Release folder

On git i have about the same script for local build or cooking



@echo off

set WORKSPACE=%~dp0.
set UE4_13_ROOT=D:\Epic Games\4.13\
set PROJECT=SwatReloaded

call "%UE4_13_ROOT%\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun -project="%WORKSPACE%/%PROJECT%.uproject" -rocket -noP4 -platform=Win64 -clientconfig=DebugGame -serverconfig=DebugGame -nocompile -cook -allmaps
REM call "%UE4_13_ROOT%\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun -project="%WORKSPACE%/%PROJECT%.uproject" -rocket -noP4 -platform=Win64 -clientconfig=DebugGame -serverconfig=DebugGame -build -cook -allmaps
REM call "%UE4_13_ROOT%\Engine\Build\BatchFiles\RunUAT.bat" BuildCookRun -project="%WORKSPACE%/%PROJECT%.uproject" -rocket -noP4 -platform=Win64 -clientconfig=DebugGame -serverconfig=DebugGame -clean -build -cook -allmaps