Chris Gergler
Chris Gergler

Reputation: 179

Visual Studio 2019 Cannot include existing folder (not visible with show all files)

What I'm trying to do

I'm currently attempting to include a set of folders and the files inside in an unreal engine 5 project.

I'm working out of Visual Studio 2019 Community and adding Photon Engine into my game source.

What is shown in the solution, and what is in the folder.


However, every example of adding this folder requests I use "Show all files". When I use "Show all files" on the project, it removes any indication of a folder structure and shows ONLY the files that exist in the project.

Without Show all files

With Show All Files

I found another option to include it in references. Again, this does not work.

"Add References"

Additional things I've tried

At this stage I'm very frustrated with what should be a simple process. I'm sure I'm missing some stupid check-box somewhere and just not thinking of it.

Upvotes: 1

Views: 2952

Answers (1)

Kaiserludi
Kaiserludi

Reputation: 2472

Visual Studio in general:

First, you should deactivate the 'Show all files'-option. Otherwise you will see absolutely every file that is located inside the solution and project folders on disk.

Then the trick is to not add a "folder" (which isn't possible), but a "filter" (which is like a folder, except for not necessarily representing a physical folder on the disk):

In the Solution Explorer within VS right-click on a project or on an existing filter inside the project, then choose 'Add' -> 'New filter'.

Repeat this for each sub-folder in the Photon source and header folder, that you want to add. Then add the files themselves to those filters.

Yes, this is kinda cumbersome.

 

Unreal Engine in particular:

Whenever you let Unreal regenerate the project files, it will override any changes that you have made to them.

So you want to have backup files. Then after regenerating, you can just open the .vcxproj and the .vcxproj.filters files from your backup in a text editor and copy the files and filters from there into the newly generated projects, which is a lot quicker than to manually re-add all filters and files.

The better alternative for adding files to an Unreal project probably is to not add them manually to the Visual Studio project, but to move the files into the folder, where your .Build.cs file is located, or into a sub-folder of this folder, so that Unreal will find these source files and add them to the project when you let it generate the project files.

 

Regarding Photon:

You should absolutely NOT add any Photon source files to your Unreal project. You can add Photon header files to your project to be able to easier navigate through them within VS, but adding Photon source files does not make sense. The Photon Client SDKs already come with pre-build static libs and only some of the Photon projects (currently LoadBalancing-cpp, Chat-cpp and PhotonVoice-cpp) come with source files, the others (Common-cpp and Photon-cpp) are closed source. If you want to modify one of those Photon projects, for which the source is included in the SDK, you should open the included VS solutions for it, make your modifications there and then build it for all platforms and configurations that you are using to get updated library files.

In your Unreal project you should add those library files to your Build.cs file like it is shown in the Photon Unreal demo project.

Upvotes: 3

Related Questions