0
votes

I have the following problem with latest Visual Studio 2017 (starting from March, 15/20th 2018):

1) Create a Visual studio Project for a C++ DLL (and related solution), for example dll1Prova

2) Add a resource file (file with ".rc" extension) with version information

3) Save all files and compile. Compilation is good, and all seems functional

4) Then with MSBuild I try to build the solution with the following commands (from Command Prompt):

set VisualStudioVersion=15.0 set VCTargetsPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild.exe" dll1Prova.sln /nologo /p:PlatformToolset=v141;Configuration=Debug /v:detailed

I obtain the following error at the end of the log:

"C:\Users\LazzaAnd\source\repos\Dll1Prova\dll1Prova.sln" (default target) (1) -> "C:\Users\LazzaAnd\source\repos\Dll1Prova\Dll1Prova\Dll1Prova.vcxproj" (default target) (2) -> (Link target) -> LINK : fatal error LNK1158: cannot run 'cvtres.exe' [C:\Users\LazzaAnd\source\repos\Dll1Prova\Dll1Prova\Dll1Prova.vcx proj]

The problem seems to be related to security issue, because all is functional when I run MSBUild as a Machine Administrator (start Command Prompt with "Run as Administrator").

I put an issue on a Microsoft social forum:

https://social.msdn.microsoft.com/Forums/it-IT/8829757b-0320-4765-8853-2a78b7b24485/vs-2017-msbuild-of-c-dll-with-version-information-resource-is-not-functional-fatal-error?forum=msbuild

but, when I found the workaround (run as Administrator) there seems to be no further suggestion/investigation. Does anyone have the same problem and/or some solution for this?

1
Don't try to manually setup paths, only cause problems. Run the Developer Command Prompt for VS2017 from the Start menu, then build. You also don't need to specify the full path to msbuild. - stijn
I tried what you suggest, but obtained same error. When I start "Developer Command Prompt for VS2017" as an Administrator ("Run as Administrator") it is functional. - andrea l
Did yo install VS as administrator perhaps? That would be wrong. Anyway I can't actually reproduce this, indicating something might be wrong with your installation, or the steps provided are different from what you are actually doing. - stijn
What is strange is that it was functional before 15th March, 2018. After this date no more.VS was installed by a machine Administrator or with Administrator privilege (as all software in a domain machine), but now I'm a normal user of it. When i start the VS 2017 IDE it shows "(Administrator)" in the title bar. - andrea l

1 Answers

0
votes

VS 2017 - MSBuild of C++ DLL with version information (resource) is not functional (fatal error LNK1158: cannot run 'cvtres.exe')

I also can not reproduce this issue. Since start "Developer Command Prompt for VS2017" as an Administrator works for you, at this moment, you can run Developer Command Prompt for VS2017 As Administrator automatically as workaround.

To accomplish this, Open up Windows Explorer, navigate to the following directory to find Developer Command Prompt for VS2017 shortcut, right-click on the Developer Command Prompt for VS2017 shortcut, click Properties. Switch to Shortcut tab, click on Advanced, check Run as administrator, finally click Ok and then Apply:

enter image description here

enter image description here