PVS Studio not working with MSVS not installed in default location - pvs-studio

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?

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.

Related

Visual studio cannot build projects error "The target "ResolveCodeAnalysisRuleSet" does not exist in the project."

I was messing around with style cop and scrapped the idea in my project. I deleted the references to style cop and ended up modifying a system file somewhere.
Every project fails to build with the following error:
The target "ResolveCodeAnalysisRuleSet" does not exist in the project. CDRCallMonitor C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 39
I scrapped my CSharp.Core.targets file and replaced it with the MS one online
https://referencesource.microsoft.com/#MSBuildFiles/C/ProgramFiles(x86)/MSBuild/14.0/bin_/amd64/Microsoft.CSharp.Core.targets
and this doesn't work.
I tried reinstalling msbuild tools and that didn’t help either.
I can't build anything with with msbuild/Visual studio
dotnet build works fine.
If you launch the Visual Studio installer there should be an option to uninstall, modify, or repair.
Give that repair option a go.

Build with sdk 7.1 on VS2015

I have Visual Studio 2015 installed, and I need to compile a specific project with Visual C++ 2010 compiler, which is included in SDK 7.1.
I want to use 2010 compiler within VS2015, without install VS2010.
So, I installed it (the SDK), and "Visual Studio 2010 (v100)", "Windows7.1SDK" options appear under "Platform Toolset" property in the project properties.
But, when I try to build the project, I get those errors:
With "Windows7.1SDK" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
and with "Visual Studio 2010 (v100)" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
Can't figure out what the problem is..
I had the same issue for 2 weeks and just found a workaround that might help :
Without modifying anything to my VS2010 projects (not changing the toolset in the vcxproj), I use the command line build tools MSBuild tools with the toolset specified as a switch as found here Building C++ project on a PC with Windows SDK 7.1 but without VS2010
msbuild /p:PateformToolset=Windows7.1SDK project.vcxproj
(In my case, the corresponding msbuild is in the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319)
If Msbuild throws an error telling its missing mspdb100.dll, you may need to add %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\Common7\IDE\ to your %PATH% env var.
Finally, you may have some files missing like ammintrin.h (especially if like me you try to compile old InDesign plugins) even after installing the visual c++ updates.
The only (and ugly) workaround I found in my case that does not involve installing VS2010 (the common answer of MS) is to copy the missing includes from the %PROGRAMFILES(X86)%\Microsoft Visual Studio 14.0\VC\include folder to the %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\include one.
Voila ! Hope this helps

MSBuild failing to find assembly following upgrade to VS2015

We have a build script which uses MSBuild to build our solution. It has worked fine for VS2013, but it has broken since we installed VS2015 and upgraded. Initially, it failed with this error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for v140
(Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, yo
u may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgra
de Solution...". [C:\Users\user\Documents\GitHub[snipped]Api.vcxproj]
So it was failing to build a C++ project since is seemed to default to using version 12 of MSBuild, even though it was a VS2015 project. So I added:
/tv:14.0
To the invocation of MSBuild to force it to use the right tools version. Now it fails with this:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB4175: The ta
sk factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12
.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll' or one of
its dependencies. The system cannot find the file specified. [C:\Users\user\Documents\GitHub[snip].Api.vcxproj]
Now it's looking for a v12 assembly in the v14 folder. How do I fix this? I can't see any obvious place to make this change.
Note: The C++ project itself might be a red herring, the solution is mostly C# and this might just be the place where it loads in the tasks.

"Invalid License File" while using CMake with Visual Studio Express 2010

After installing AVR Studio, CMake returns an error saying "Invalid License Key" while trying to generate a new project using the MSVC generator. This may also happen if other tools based on Visual Studio 2010 are installed.
This problem is caused by AVR Studio (and possibly) other products installing a "devenv.exe" in the folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE. By default, CMake will attempt to use "devenv.exe" and fall back on "MSBuild" if it is not found. MSVC Express 2010 does not use a "devenv.exe", but instead has its own executable. To fix this problem, rename the "devenv.exe" file to "devenv1.exe" while generating an MSVC 10 file using CMake. It may be necessary to rename it back to get the other tools to work but so far it has not been a problem.

VS 2013 and MSBuild

I've recently upgraded to Visual Studio 2013, which has caused back to back problems when building externally using MSBuild (API or Executable with command line args)
Issue #1
When building with MSBuild it doesn't generate Fake assemblies which are required for our Unit Tests, this leads to build failures. A simple build in visual studio fixes this temporarily, until a new fake assembly needs to be generated.
Issue #2
When running code analysis this complains with the following:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(284,5):
error MSB4127: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll".
Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
I only have Visual Studio 2013 installed on my machine, apparently installing an older version could fix the issue, but it's not something which I can do. (VS 2013 Ships with its own MSBuild 12.0 which is located in a different directory to the previous MSBuild).
I'm unsure why Visual Studio is behaving any differently to MSBuild, i'm simply pointing to the solution file like so...
msbuild.exe "path\solution.sln" /property:Configuration=Debug
So, Visual Studio 2013 comes with a new version of MSBuild i.e. MSBuild 12.0. Once installed, it changes the path so that the new version is used by default.
Looks like your solution compiles with visual studio 2012, you can either specify the full path to msbuild.exe such as
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "path\solution.sln" /property:Configuration=Debug
or set the visual studio 2012 environment variables by running the following before executing msbuild
"%VS110COMNTOOLS%"\vsvars32.bat // VS2012 environment variables
EDIT: Using MSbuild 12.0 assemblies "C:\Program Files (x86)\MSBuild\12.0\Bin\" fixes the issue with the code Analysis bug.

Resources