'MSBuild: error MSB3073 The command 'setlocal VCEnd' exited with code 1

I am trying to build an opensource project on my machine using Visual Studio 2015 and CMake. I have followed all the steps and the prebuild checks were running properly. But when I am building the INSTALL to install the software in the folder that I have specified in the CMAKE gui, I am getting the MSB3073 error. A full description of the error is as below.

Severity Code Description Project File Line Suppression State Error 
MSB3073 The command "setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=RelWithDebInfo -P    cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 1. 
INSTALL C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets  133 

I have searched for the same error and found that some people who tried to install the build in a directory without write privileges encountered this, but I have made sure that I have write access. I have even tried do this with admin rights and still not able to fix this issue.

Any help in this would be highly appreciated.



Solution 1:[1]

While running Visual Studio 2022, trying to build VST plug-in with code generated by cmake. For me it showed permission access denied when creating a symbolic link.

All I had to do was run Visual Studio "As Administrator" and it worked.

Of course, you have to have Admin privileges to your machine, or you belong to a group that is allowed to "Create symbolic links" in the Local Group Policy Editor (https://developer.steinberg.help/display/VST/Preparation+on+Windows)

Solution 2:[2]

Sorry for being a necro but I just encountered and fixed the exact same issue, and I think it can save someone some time if I share my solution.

By looking a bit in the log before the error message, I found the last element that CMake was trying to install :

-- Installing: path-to-anaconda/anaconda3/Lib/site-packages/cv2.cp37-win_amd64.pyd
CMake Error at modules/python3/cmake_install.cmake:45 (file):
  file INSTALL cannot copy file
  "path-to-repo/opencv/build/lib/python3/Release/cv2.cp37-win_amd64.pyd" to
  "path-to-anaconda/anaconda3/Lib/site-packages/cv2.cp37-win_amd64.pyd":
  Permission denied.
Call Stack (most recent call first):
  modules/cmake_install.cmake:183 (include)
  cmake_install.cmake:124 (include)

Permission denied...

It was simply because I left a console with cv2 imported, so the pyd was still being used and blocked the install. This can probably extend to any other file (DLLs, .hpp) being installed, just look a bit above this obscure error message ! Nothing to do with cmake_install.cmake, at least for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dana Reed
Solution 2 Jux