VS rebuilding the whole project when I just click Build

If I click ‘Build’ (not ‘Rebuild’) VS will rebuild my whole project, recompile all files (even the ones I haven’t changed). This also happens when I click ‘Compile’ in the editor. Is there any configuration I might have messed up? I was playing around with editor code (making a custom details panel) and I think the problem began there. I have removed the editor module I created, as well as its target.cs file.

I only have my game’s target.cs and it looks like this:



// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class MyGameTarget : TargetRules
{
    public MyGameTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game;
        ExtraModuleNames.Add("MyGame");
    }
}


my game’s build.cs looks like this:



// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class MyGame : ModuleRules
{
    public MyGame(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "AIModule", "GameplayTasks" });
    }
}


Any ideas? Thanks!

Which VS are you using. I used 2015 with 4.15 and always worked for me… I upgraded on a brand new project in 4.21 source code with vs 2017, build it and compile, everything goes correctly, then I add one comment and build and it does the exact same thing as you described… When I researched it I found out it was a VS2017 bug and I switched back to VS 2015 and it works much better but 4.21 still has some compile issues for example… build, build complete no errors, build again, no errors and builds without full build like my old project… I add a line of code, ok… I add a header file, it cant find an engine file not related to header file I added… I delete header file so its back to normal and I get 122 errors LOL… I shouldve stayed in 4.15.

I’m using VS2017 but it worked fine before I tried messing with custom editors and stuff. Compile times went from 5-10s to 60-75s every time. I have reinstalled VS and UE4 and also reverted my project in source control, nothing helps. It always compiles a large number of files even if I changed one little thing. I just made a change to a single line and it compiled 22 files (none contained children classes to the one I modified).

What is the version of your VS toolchain and Windows SDK?

I didnt have much luck with VS2017 so I use VS2015 update 3… A whole bunch of people are complaining about VS2017 having longer compile and full rebuilds not just with ue4 but with everything… If you google “VS2017 longer compile times” some people give a work around because they are saying its not checking to see if a file hasnt been changed so it does full rebuild… They also complain its making additional copies that arent necessary so its taking longer… their work around to make it shorter was too much for my brain to handle.

@ptjackson thank you for pointing me in this direction, I took a look at the comments and their solution fixed it for me, down from 60-75s to 15s.

Since you’re using VS2015 you probably won’t benefit from this, but

EDIT: later I found this actually did nothing. For anyone reading this: you can try this solution, but don’t get your hopes too high.

For anyone else having the same issue:
Just add the file attached to this post to your project’s folder (yes, outside the Source directory) and remove the[FONT=courier new] .txt extension from its name (it should be [FONT=courier new]Directory.Build.props). I got this solution from here.

1 Like

Actually, this didn’t help :frowning:
I thought the problem was solved because I tested a bit and the compile times were shorter, but now I still get long compile times with classes I didn’t even modify.