Search code examples
pvs-studio

PVS Studio not working with MSVS not installed in default location


Due to disk size constraints, I installed MSVS 2017 to D:\Program Files\Visual Studio.

I then installed PVS-Studio v6.14. When I tried to run it, I get the following error messages:

Error was encountered while opening project 'MIDI2LR.vcxproj'.  0
Exception message:   0
Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC'.  0

It also appears that PVS-Studio did install its extensions into the D:\Program Files\Visual Studio\Common7\IDE\Extensions\3ci0fu2p.p0x directory, so it appears that the installer found the executable.

How do I point PVS-Studio to the correct directories?


Solution

  • If I have understood correctly, we are talking about /Builds/VisualStudio2017/MIDI2LR.vcxproj from your repository (develop branch). If you're talking about another project, please specify it. The information is based on the analysis of the project I mentioned before.

    Does this project compile on your machine? If a project does not compile, PVS-Studio does not guarantee the analysis. Otherwise, the analysis should be performed correctly. I also note that for the compilation you have to have the components Visual C++ Build Tools 2015 installed (in this context we use the contents of the directory C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC).

    In this case, such behavior occurs because of your project's file structure – the PlatformToolset property is set with a value v140 before the import of Microsoft.Cpp.Default.props, thus this import is performed based on this toolset. This causes MSBuild to use the compiler from Visual C++ 2015, and not from Visual C++ 2017.

    To compile using the compiler from VS2017 (V141 toolset), you need to modify the project file (see example of a console application project file that is created in Visual Studio 2017). Then the compilation should be done with a correct compiler and the analysis with PVS-Studio performed correctly.