GenerateProjectFiles.bat doesn't work properly for Plugins folder in seperate project folder

As i’m actually writing a plugin now, i stumbled over something odd.

I copied some files over from another project into my project folder/Plugins/PluginName/Source/Public and Private.
As always VS didnt pick up the files. But i expected that.

What i didn’t expect was, that GenerateProjectFiles.bat couldn’t get VS to see them.

After some googling (without luck) and some diggin in UBT source i noticed a .vs folder in my project folder.

This folder holds some subfolders with a single hidden .suo file in it.
Deleting .vs didn’t do the trick.
I still don’t know how i got the folder though.

Afaik generateprojectfiles should change the project files to show the files&folders in the project files, right?

My call of the generateproject files is a batch as follows:
call “C:\Github\UnrealEngine\GenerateProjectFiles.bat” “D:\UnrealProjects\MyProject\MyProject.uproject”

I already tried the -2015 option, no luck.
Also tried: run generateprojectfiles against the .uplugin file. Still no luck.

How can i get it to show the files properly in the solution explorer? (without adding them with the context menu, because they vanish after rerunning generateprojectfiles)

Just seen, the file dates don’t match either, vcxproj and vcxproj.filters in intermediate folder is like 5 hrs old and i tried gpf a minute ago.

Hey -

Can you explain how you’re creating / setting up the plugin? Are you using the create plugin wizard from the editor or simply adding the new files to the project as a plugin? Does the VS file update if you run Generate Visual Studio project files from the .uproject rather than the batch file? I tried to reproduce this by creating a new plugin through the editor and then copying a .cpp and .h for a class from another project into the plugin’s public and private folders. After running Generate Visual Studio project files from the .uproject both the .cpp and .h showed in VS. Can you let me know if this works the same for you?

Cheers

Hmm, since i hit the wrong button again…

Hi ,

I did create it with the wizard, then copied files from an earlier plugin try into the source folder, changed header files etc, so it would compile again, then tried to regenerate the project files. And nothing. Seems it doesnt write out the file at all.

I think UBT errors out without a message or exit code. Does UBT create a log file where i can look for odd messages?

For your other questions:

I cant rightclick the uproject file (since i never installed the engine itself, i work from git source)

Hmm, found another thing which could be made better.

1st: In a BP Project, you don’t have the New Plugin button at all. It’s only shown in c++ projects. Thats ok, but can’t you show a hint, so people won’t look everywhere why the button isnt there where it should be?

2nd: After adding a c++ class the button is shown only after you restart the editor. I don’t know how much hassle it is to load the plugin wizard module when you add a c++ class, but it might be helpful to either show a message where the button should be or to load the module itself.

Could you explain what you mean by being unable to click the uproject? How do you open the project? Does the right-click menu not appear or is the option for Generate VS project files not available? What color is the icon for the .uproject file? Also, if you are getting an error can you post a screenshot of the error message for more information?

I never installed the ue4 engine. I compiled the source (4.10.1) and run the project’s editor (as development editor) from VS2015.

One thing: i added the boost libraries (sitting in Engine/Source/ThirdParty/boost) in my UE4 source and changed the plugin’s build.cs accordingly so it finds the .hpp and .lib files.
And it compiles like it should and runs like it should. Only UBT doesnt recreate the vcxproj file of the blank project if i add files to the plugin folder.

Here’s the link to the UBT output: 010UBT Running for Rocket: C:\Github\Entimaps4\Entimaps4.uproject010UnrealBuil - Pastebin.com
I notice quite a few System.IO.DirectoryNotFoundException.
They’re not normal, right?

When the project was first created it should have created a project directory (default is MyDocuments/UnrealProjects). The .uproject should be inside this directory along with the rest of the project’s folder structure.

I found the faulty line in UBT, doing some checks. I’ll get back to you in a few minutes (~10 or so)

It goes wrong in AddProjectsForAllTargets in ProjectFileGenerator.cs (Line 1781)
There you have to make the distinction between Engine project and Game project.
You already create a IsEngineTarget boolean, no clue why you dont use it.

Still couldnt come up with a fix yet though, but i’m on it

Just to make sure I’m understanding what is happening correctly, you have source files (.h/.cpp) from PluginA inside ProjectA that you are trying to move to PluginB inside ProjectB, correct? After copying the files to the “ProjectB/Plugins/PluginB/Source/PluginB/Private” and “ProjectB/Plugins/PluginB/Source/PluginB/Public” folders can you go to the root folder for ProjectB where ProjectB.sln and ProjectB.uproject are located. Right click on ProjectB.uproject and select “Generate Visual Studio project files.” Once that finishes can you open ProjectB.sln and let me know if you see the Plugin folder as well as the files that you moved over from PluginA.

UBT is really borked for seperate project folders.
One one side, the Editor creates an Intermediate folder in my project folder, thats fine.
But everything else is stored in the engine’s Intermediate folder.
So Build.bat and other stuff depend on having vcxproj files in the engine…

Anyway, here is what i came up with. It’s based on 5366ce6 (25th Nov) V4.10.1.
With this GenerateProjectFiles works again, but running the editor borks out then, because of the .user file (which did exists before and is not overwritten) has the wrong commandline arguments.
After removing all these roadblocks i finally made it back into the editor and all looks fine now.

But seriously, UBT needs a major overhaul.
It is cluttered, hard to change anything without breaking one or more other things.

And one other thing, you did already have the things in place i needed. But they were not set or not checked.

No, i did create a new empty project, and added a new plugin. Then i copied some files over into the plugin folder (some code i needed). Then i was running generateprojectfiles.bat so it would show up in VS, but nothing.
Cause was that gpf did create the files, but in the wrong folder (engine’s intermediate folder instead of projects intermediate folder)

It doesnt really matter which files i copied over. i did also try creating empty cpp/h just to get them shown. and again, i can’t rightclick uproject files, because i never installed the engine. i work purely from source, for regenerating the project files i call the generateprojectfiles.bat in the UE source folder with the path and filename of the uproject i want to recreate. Thats working again now with the changes i made to UBT’s ProjectFileGenerator.cs

Looking through the posts here, i found a two more which are likely the same issue:
https://answers.unrealengine.com/questions/263875/game-project-outside-unrealengine-folder-generate.html (Exactly the same behaviour)

https://answers.unrealengine.com/questions/215414/how-to-add-code-to-editor.html (Sounds like the same problem too, specially the last post)

Yes, it seems to work with rightclick->generate project files, but not with the batch file. So can you tell me commandline + args a context menu ‘generate project files’ uses please?

(I don’t really want to install the engine, because i do make changes inside the UE4 source, so a installed version is just a waste of precious sdd space for me)

Cheers

Hey -

Unfortunately it is not possible to write a batch file to perform this command. The GenerateProjectFiles.bat file will only generate the files necessary for the engine and is independent of any individual projects. Using the project’s .uproject to run the command is the best solution for this situation.

Cheers

Oh it is possible.
Generateprojectfiles.bat just calls UBT with -projectfiles parameter and all other parameters which i pass along.
Atm i’m reading the versionselector source, where the other needed parameters are defined (-game, -engine, -project, -progress).

My problem was the undocumented -project= parameter

so my final batch file will be (it assumes that the last part of the path = unreal project name):

@echo off
Set lf=%~dp0.
for %%f in ("%lf%") do (
set lastpart=%%~nxf
)

call C:\github\unrealengine4.9\generateprojectfiles.bat -project="%~dp0%lastpart%.uproject" -game -engine
set lastpart=
set lf=

It has to be started in the root of the UE4 project folder.
As you probably guessed, C:\github\unrealengine4.9 has to be exchanged for your own UE4 source root folder.

Use it if you want, it’ll make batch build/team work easier (as a hook for checkout for example)