The "SetEnv" task failed unexpectedly

I recently encountered the same error while building my project from Visual Studio:

After some investigation, I noticed that the Unreal Engine Integration Configuration inside Visual Studio now exposes a setting called Max Include Paths Length (chars). This setting corresponds to the MaxSharedIncludePaths field inside BuildConfiguration.xml (located under UnrealBuildTool/BuildConfiguration, as shown in the screenshot blow).

IMG-20251118-3

Solution:
I removed all MaxSharedIncludePaths entries from every BuildConfiguration.xml, deleted the generated .sln, and regenerated the solution. After doing so, the build completed normally and the MSBuild SetEnv error no longer occurred.

12 Likes