batch-fileunreal-engine4unreal-development-kit

How to Generate Visual Studio Project Files from Unreal Engine .uproject file with a batch file?


I have a batch file as follows to clean my UE project.

del *.sln
rmdir /s /q .vs
rmdir /s /q Binaries
rmdir /s /q Intermediate
rmdir /s /q Saved
rmdir /s /q DerivedDataCache
"C:\Program Files (x86)\Epic Games\Launcher\Engine\Binaries\Win64\UnrealVersionSelector.exe" /projectfiles Attaching.uproject

Unfortunately, when I run the batch, I get an error as follows:

enter image description here

I found the last command in the batch by reverse-engineering as shown below:

enter image description here

enter image description here

enter image description here

Question

What is the correct way to generate Visual Studio project files from a batch file?


Solution

  • After wasting a lot of time, I found the solution. We have to fully qualify the project path.

    echo off
    
    del *.sln
    rmdir /s /q .vs
    rmdir /s /q Binaries
    rmdir /s /q Intermediate
    rem rmdir /s /q Saved
    rmdir /s /q DerivedDataCache
    
    
    set MyUVS="C:\Program Files (x86)\Epic Games\Launcher\Engine\Binaries\Win64\UnrealVersionSelector.exe"
    set MyUBT="f:\Program Files\Epic Games\UE_4.26\Engine\Binaries\DotNET\UnrealBuildTool.exe"
    
    rem change Transformation to your own project name
    set MyFullPath="%cd%\Transformation"
    
    
    %MyUVS% /projectfiles %MyFullPath%.uproject
    
    %MyUBT% Development Win64 -Project=%MyFullPath%.uproject -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
    
    %MyFullPath%.uproject
    
    %MyFullPath%.sln
    

    I hope this answer is also useful for others in the future!