Error MSB8066 on first Blender build attempt

Hello!
I was trying to compile blender for the first time and I stumbled across this error.
I was just following the steps on the Building on Blender for Windows page.
I am totally new to this. So I have no idea of how to solve it.
Any help is very appreciated!

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): e
rror MSB8066: Custom build for 'C:\blender-git\build_windows_x64_vc17_Release\CMakeFiles\5ad78f4d7d4cd9b50e0fdc1367ab00
de\dna.c.rule;C:\blender-git\blender\source\blender\makesdna\intern\CMakeLists.txt' exited with code 1. [C:\blender-git
\build_windows_x64_vc17_Release\source\blender\makesdna\intern\bf_dna.vcxproj]
1 Like

Same problem here. I use the latest Visual Studio, the latest Git, and the latest CMake. Everything is the latest and I have followed all of the steps. I got the same error.

I installed Visual Studio 2019 Community using a VM. It works now.
I don’t know why Visual Studio 2022 Enterprise won’t build.

Update:
Good News. I clicked repair to repair my Visual Studio 2022 Enterprise. Now it can build. So the problem was not related to the version.

I take a look at the event viewer. It seems like my MSVCP140.dll was break and repair VC fixed it.