Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'MSBuild.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.

when i try to build this samp-gps-plugin/CMakeLists.txt at master · kristoisberg/samp-gps-plugin · GitHub which is built normally with everyone without any problem

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error at CMakeLists.txt:2 (project):
  Failed to run MSBuild command:

    Z:/Installations/Visual Studio Build Tools/MSBuild/Current/Bin/amd64/MSBuild.exe

  to get the value of VCTargetsPath:


    Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'MSBuild.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.


  Exit code: -532462766



-- Configuring incomplete, errors occurred!

What is the command line you’re using to run CMake? If relevant, have you loaded the toolchain environment with vcvars.bat or equivalent? What version(s) of Visual Studio do you have installed?

What is the: command line you’re using to run CMake?

git clone ...
cd ...
mkdir ./build
cmake -B ./build -DCMAKE_BUILD_TYPE=Release -A Win32

have you loaded the toolchain environment with vcvars.bat or equivalent?
No.

What version(s) of Visual Studio do you have installed?
Visual Studio Community 2022 (v17.10.4)

If you are using the Visual Studio toolchain, you need to load the appropriate toolchain environment with vcvars.bat or equivalent.