Errors when building engine from source

I’ve been trying to build the engine from source using the guide in the readme, but I’m getting an error when running GenerateProjectFiles.bat

C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.UBA\EpicGames.UBA.csproj : error NU1202: Package Microsoft.Extensions.Logging 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Logging 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.UBA\EpicGames.UBA.csproj : error NU1202: Package Microsoft.Extensions.Options 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Options 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package JetBrains.Annotations 2022.1.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package JetBrains.Annotations 2022.1.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Http.Polly 6.0.26 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Http.Polly 6.0.26 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Logging 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Logging 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.ObjectPool 6.0.8 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.ObjectPool 6.0.8 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package OpenTracing 0.12.1 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package OpenTracing 0.12.1 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Http 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Http 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Polly 7.2.2 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Polly 7.2.2 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Polly.Extensions.Http 3.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Polly.Extensions.Http 3.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Options 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Options 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Logging.Configuration 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Logging.Configuration 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Configuration.Binder 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Configuration.Binder 6.0.0 does not support any target frameworks.
C:\Users\bweno\Documents\NvidiaUnreal\UnrealEngine\Engine\Source\Programs\Shared\EpicGames.Core\EpicGames.Core.csproj : error NU1202: Package Microsoft.Extensions.Options.ConfigurationExtensions 6.0.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Microsoft.Extensions.Options.ConfigurationExtensions 6.0.0 does not support any target frameworks.

There’s a lot more of this kind of error that follows as well.

I’ve tried repairing Visual Studio, completely deleting Visual Studio and reinstalling, deleting all my nuget packages and cache, installing to my boot drive and my D: drive.

Also, when running Setup.bat or GenerateProjectFiles.bat in powershell or command line, it sometimes will just close my window before finishing, so I can’t see any errors or where it stopped at. Any idea what could be causing that?

I had this error a few weeks ago, for me this solved it: Visual Studio and Unreal Engine 5 - #2 by Quetzalcodename - You need different .net version, 3.1 should be sufficient - mine also was throwing errors not being compatible with .net 6.0

Strange, it seems like I’m still getting the same errors, even after uninstalling .net6.0 in the visual studio installer. Here’s what that looks like now for me:

I noticed at the beginning of the log when running GenerateProjectFiles.bat it says this:

Using bundled DotNet SDK version: 6.0.302

Which seems to imply it’s bundled a version of .net 6 somewhere, and is using that regardless of what I have installed. Not sure if that’s correct though.