When trying to build a Gen 8.6 .NET C# application with Visual Studio 2022 this error will be seen:
error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Gen Build Tool using Visual Studio 2022.
Visual Studio 2022 no longer delivers .NET Framework 4.0.
Building Gen generated C# code will result in the above error regardless of the value used for Build Tool OPTIONS token OPT.VSVERSION.
There is currently no resolution.
Workaround:
If intending to build C# applications with a Visual Studio 2022 installation, install Visual Studio 2019 with the following individual component selected:
.NET Framework 4 targeting pack
i.e. from Visual Studio 2019 installer (Individual Components) select as follows:
That will then be picked up when using Visual Studio 2022 for the build.