Download

Several UnrealBuildTool capability questions

Hello,

I’ve been digging around the UnrealBuildTool code and noticed that it has some methods that are used to add projects to the solution it generates. However I do not see a way to access that from my <ProjectName>.[Build, Target].cs files. I would like to be able to add a project to that generated solution that has nothing to do with unreal, except that my code will use some calls/dlls defined there.

If I cannot add the actual project I would be happy if I could just add some Pre-Build event to just do a system call to msbuild.exe and build my external project. That would work fine, however I would then be left with Visual Studio not being able to find any of the included from that external project. I am aware that this will have no impact on the actual compiling since UnrealBuildTool has all the necessary paths specified in the <ProjectName>.Build.cs file. However, being able to add these include paths in some way that won’t get wiped by the re-generation of the solution would allow for some more sane viewing/editing the code within Visual Studio.

So to be clear:

  • Can I add an external .vcxproj to my Unreal project so that it gets added to the .sln when it is generated but is not built by UnrealBuildTool (much like the UnrealBuildTool itself is added)?
  • Can I add some kind of Pre-Build event that occurs before my Unreal project gets built?
  • Can I add addition include paths to the Visual Studio Project that is generated for my Unreal project by Unreal in some manner that won’t get wiped when it is re-generated (this currently works fine for the IntelliSense include paths, but not the actual Include Directories entry)? This can also be expanded as perhaps just having the ability to specify a Property Sheet to the Unreal generated Visual Studio Project (which also gets wiped now).

Thanks!

Hi Fingon,

I’m not sure how easy it is to add the vcxproj to the solution (I’ll ask around to see if that is extensible), but adding a 3rd party project that you want to link against but not build using UBT is certainly doable.

Have a look at one of the ThirdParty build cs files, ranging from something like FBX.Build.cs (simple) to PhysX.Build.cs (fairly complicated).

Cheers,
Michael Noland

Thanks, I’ll look through those. To my understanding, I thought the 3rd party inclusions are intended for pre-built things and they won’t appear in the generated solution. I was hoping that my final solution would include my external project and allow Visual Studio to load and build them when I load the generated game solution.

We currently only add C# ‘external’ projects and it’s all hardcoded in ProjectFileGenerator.cs. This could probably work for VCProjects but I’m not sure how that would work with XCode. You could try that if you don’t care for Mac support though. Portability is the main reason we don’t do that - C# projects are fairly portable (not always though!).

There’s no built-in support for that, but you could add something similar to how UnrealHeaderTool is built and executed in ExternalExecution.cs (tbh we’ve had many requests for that so maybe we’ll add support for that in the future).

We do that by adding include paths to PublicIncludePaths and PrivateIncludePaths in module rule files (*.Builds.cs) for our generated projects.