Visual Studio NET errors

This is an issue I’ve been having for a while now, and thus far, I haven’t found a clear-cut solution for it yet. Nobody I’ve spoken to about it seems to know how to fix it, and nothing I’ve tried up to now has worked.

Essentially, whenever I’ve tried to use Visual Studios with C++, attempting to build a solution has always led to the same errors popping up. They all look like this:

Warning As Error: Package ‘Microsoft.Build 17.14.8’ was restored using ‘.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1’ instead of the project target framework ‘net8.0’. This package may not be fully compatible with your project.

So, to my understanding, these packages are being restored using old .NETFramework versions instead of net8.0, which is what my Unreal project uses. The thing is, I already have net8 installed on my computer, the VS installer says the net8.0 WebAssembly Build Tools and Runtime are installed, and at least one of these .NETFramework development tools are automatically included in the Workloads I need to use VS with Unreal.

Basically, I’m not sure how to solve this issue. Upgrading the project or changing its properties hasn’t helped, and hardly anyone seems to be having the same issue as me. If anyone knows a solution to all this, I’d greatly appreciate it.

Hello there @TheRealQuilithin!

Checking with my peers about your error, I believe this is due UE not targetting .NET 8. Your build is looking for .NET 6, and when VS checks with NuGet, it tries to use SDK 8.0, and fails.

A solution to test would be to install .NET 6.0 SDK (even if you already have .NET 8), then add the following to your global.json file:

{
  "sdk": {
    "version": "6.0.4",
    "rollForward": "latestFeature"
  }
}

Finally, close VS, reopen, and rebuild your project. Afterwards, I would also review all elements tied to your Unreal version, and that all components are installed, following the guide below: