Faced with the same issue on teamcity and on local machine.
18:28:57 INFO:root:Running: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe "C:\ba\tc\work\dev\ue_src\Engine\Saved\CsTools\Engine\Source\Programs\UnrealSwarm\SwarmCoordinator\SwarmCoordinator.csproj" /property:"Platform"="AnyCPU" /property:"Configuration"="Development" /restore /verbosity:minimal /nologo
18:28:58 INFO:root:
18:28:58 INFO:root:C:\ba\tc\work\dev\ue_src\Engine\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\NuGet.targets(439,5): error MSB4062: The "NuGet.Build.Tasks.WarnForInvalidProjectsTask" task could not be loaded from the assembly C:\ba\tc\work\dev\ue_src\Engine\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\NuGet.Build.Tasks.dll. Could not load file or assembly 'NuGet.Build.Tasks, Version=6.10.0.97, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\ba\tc\work\dev\ue_src\Engine\Saved\CsTools\Engine\Source\Programs\UnrealSwarm\SwarmCoordinator\SwarmCoordinator.csproj]
18:28:58 INFO:root:Took 0.64s to run MSBuild.exe, ExitCode=1
18:28:58 INFO:root:Command failed (Result:1): C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe "C:\ba\tc\work\dev\ue_src\Engine\Saved\CsTools\Engine\Source\Programs\UnrealSwarm\SwarmCoordinator\SwarmCoordinator.csproj" /property:"Platform"="AnyCPU" /property:"Configuration"="Development" /restore /verbosity:minimal /nologo. See logfile for details: 'MSBuild-2025.04.16-15.28.57.txt'
18:28:58 INFO:root:AutomationTool executed for 3h 6m 6s
18:28:58 INFO:root:AutomationTool exiting with ExitCode=1 (Error_Unknown)
18:28:58 INFO:root:BUILD FAILED
but if i call raw command:
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe "C:\ba\tc\work\dev\ue_src\Engine\Saved\CsTools\Engine\Source\Programs\UnrealSwarm\SwarmCoordinator\SwarmCoordinator.csproj" /property:"Platform"="AnyCPU" /property:"Configuration"="Development" /restore /verbosity:minimal /nologo
all is ok!
It seems UE download .NET Runtime 8 with ./Setup.bat launch and uses it by default. But Swarm and other csTools (Engine/Binaries/DotNET/) need .NET Runtime 6.
RunUAT.bat BuildGraph used .NET Runtime 8 and raw call of MSBuild.exe used .NET Runtime 6