Generate VS Project Files by Command Line

[EDIT] For those who really want to use a bat script see Bob_Gneu’s answer, for everyone else 's answer will be the fasted solution. [/EDIT]

I now also downloaded the Shooter Example but if I want to open it I get the message: “The game module ‘ShooterGameLoadingScreen’ could not be found…” I use the source code version and had some issues with the launcher as described in this post.

I think the DLLs of the shooter project may link to the precompiled version of UE but not to my custom build version (although I use VS2013 + Windows 64 Bit which seems to be standard at epic too)

I’m relatively sure that a recompile of the project will fix the problem but there are no VS project files and as I cannot open up the UEditor I stand before a chicken and egg problem. Maybe I can call the method per command line (maybe even an external script generates the VS projects for unreal projects?)

Thanks for your help in advance!

#Right Click on .UProject

If you right click on the .uproject file there is a right click option menu to Generate VS files

Enjoy!

If you are absolutely trying to regen your project/solution files from the command line you can do so like this:

"%UE4PATH%\Engine\Build\BatchFiles\GenerateProjectFiles.bat" %~dp0\MyProject.uproject

This is the command I use from SublimeText and it works quite well, although the exact file name of the batch file for your setup may vary.

Hi, I have not the right click option menu to generate VS Project file.
Whould you Please tell me how can I add it to my right click options?
Thank you

Yeah nice I assume that will be the way the context menu entry is working, Although this works for me atm. I think everyone who want to adapt the build scripts will profit form your answer! :thumbsup

Run UnrealEngine\Engine\Build\BatchFiles\RegisterShellCommands.bat as administrator.

BiggestSmile, you are the best. Thank you.

I can not find the “UnrealEngine\Engine\Build\BatchFiles\RegisterShellCommands.bat” file in ue4 4.2 engine

Hi @,

The RegisterShellCommands.bat file was removed in version 4.1. You can find an question with more up-to-date information here.

Alas it appears, using a from-source build of UE4, that all this now does is generate the UE4.sln used for building the editor itself, it doesn’t seem to generate the project for the supplied uproject :frowning:

As of UE4.14, the following works:
“C:\Program Files (x86)\Epic Games\Launcher\Engine\Binaries\Win64\UnrealVersionSelector.exe” /projectfiles “%~dp0\MyProject.uproject”

1 Like

Below worked in 4.16. Note that you must provide full path to project.

"C:\Program Files (x86)\Epic Games\Launcher\Engine\Binaries\Win64\UnrealVersionSelector.exe" /projectfiles "full\path\to\myproject.uproject"

You can find this in following registry key:

HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj

So I wrote a little batch file that you can put in your project folder and invoke it with your uproject:

GenerateProjectFiles.bat

setlocal
del /q gen_temp.txt
powershell -command "& { (Get-ItemProperty 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj' -Name 'Icon' ).'Icon' }" > gen_temp.txt
set /p gen_bin=<gen_temp.txt
%gen_bin% /projectfiles %cd%\%1%
del /q gen_temp.txt

Use this like (from project folder):

GenerateProjectFiles.bat MyProject.uproject
1 Like

Updated solution

"$EngineRoute"\UE_4.X\Engine\Binaries\DotNET\UnrealBuiltTool.exe -projectfiles -project="$AbsoluteProjectRoute" -game -rocket -progress

Just a little typo error “UnrealBuiltTool.exe” > “UnrealBuildTool.exe”

The most up-to-date solution to include in the *.bat script is:

@"<AbsoluteEnginePath>Binaries\DotNET\UnrealBuildTool.exe" -projectfiles -project="<FullPathToUprojectFile>" -game -rocket -progress

Example:

@"C:\ProgramFiles\Epic Games\UE_4.25\Engine\Binaries\DotNET\UnrealBuildTool.exe" -projectfiles -project="C:\Projects\MyProject\MyProject.uproject" -game -rocket -progress

Important: quotation marks matter!

A little change for the UE5 for anyone who read this in the future:

@"C:\ProgramFiles\Epic Games\UE_4.25\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.exe" -projectfiles -project="C:\Projects\MyProject\MyProject.uproject" -game -rocket -progress
2 Likes

if you want to do it through powershell, here is my example:

$ProjectName = 'QuestTemplate'
$ProjectPath = 'D:/Projects/Experimenting/QuestTemplate5.1'
$EnginePath = 'D:/Engines/UE_Oculus_5.1/UnrealEngine'
$ProjectFile = Join-Path $ProjectPath "$ProjectName.uproject"
$BuildTool = Join-Path -Path $EnginePath -ChildPath 'Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.exe'

Start-Process -Wait -NoNewWindow -FilePath $BuildTool -ArgumentList '-projectfiles', "-project=$ProjectFile", '-game', '-rocket', '-progress'

Set-Location $PSScriptRoot
1 Like

Thank you very much! It works in 5.2.
I modified it for me a little (place to project folder and change ProjectName.uproject):
update 25 Dec 2023: now I have an improved version :slight_smile: (no need to set projectname):

GenerateProjectFiles.cmd:

setlocal
powershell -command "$uproject = Get-ChildItem "*.uproject" -Name; $bin = & { (Get-ItemProperty 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj' -Name 'Icon' ).'Icon' }; $bin + ' -projectfiles %cd%\' + $uproject" | cmd.exe
2 Likes