Trouble generating new VS project files from uproject

I’m sure this is a basic error, but I can’t find any information about it. Every time I try to generate visual studio project files from my uproject I get the following error:

Running path/UnrealBuildTool.exe -projectfiles -project="MyActualProject_Path/MyActualProject.uproject" -game -rocket -progress

Discovering modules, targets and source code for game...

UnrealBuildTool Exception: ERROR: Not expecting project Intermediate\ProjectFiles\MyActualProject.vcxproj to already have a target rules of with configuration name Game (SomePluginProjectTarget) while trying to add: MyActualProjectTarget

I only just noticed this when trying to setup a new workspace. I went back and tried to generate new project files from my established workspaces, and they ALSO threw this error.

Any pointers? Thanks in advance.


Update
I’ve created a new project to test with, and generating visual studio project files works, no problems. I’ve also tested on other projects that I’ve been using for the last little while and they also work.
I guess the question is, where do target rules come from, and how can I set this up to work properly?

I would first try deleting the contents of \Intermediate\ProjectFiles\ and starting fresh, if you haven’t tried that. You can delete all of the contents of \Intermediate\ProjectFiles, and they will be rebuilt the next time you run GenerateProjectFiles.bat, and that may solve the issue. That or it might be that you have the the same target configuration defined in two places.

There should only be a Target.cs file in your project folder, not in any plugin folders.

It looks like someone had the same problem here before:

Adding Custom Module to UE4 Project

Hope that helps!

Ah, I see. When the plugin was added for whatever reason the PluginProject had it’s .target.cs files checked into the source folder, along with the rest of it’s source code. Removing the PluginProject.target.cs files from the source folder lets me build my visual studio project files again. To actually add the Plugin as a dependency, I changed the line:
PrivateDependencyModuleNames.AddRange(new string[] { });
to
PrivateDependencyModuleNames.AddRange(new string[] { "OceanProject" });
Is that how I’m supposed to have done that? There’s nothing else that needs to be added to the solution explorer or anything?

That is correct. Just keep in mind that adding the plugin as a dependency means that it will be required to be present in order to build the project.

Great! Thanks both Joe and .

I downloaded a plugin named VaRest from market place.
In my project ,I enabled this plugin.When I try to pakage it,it shows some errors as following.
mono: UnrealBuildTool Exception: ERROR: Not expecting project /Users//Documents/Unreal Projects/UE402/Intermediate/ProjectFilesIOS/UE4.xcodeproj to already have a target rules of with configuration name Game (UE4GameTarget) while trying to add: UE4Target

Hi mayaping,

Does this only happen when packaging? Does it also occur in a new test project?