I am scanning C# code files with the sonar-scanner for .NET method. For this I am using the below link and tool Microsoft .NET Framework 4.6 scanner flavour for scanning C# files. During build phase I am facing below issue.
Although you should be able to analyse a project targeting an older version of the .NET Framework you will need to have at least .NET Framework 4.6 SDK installed for the analysis to run.
Thank you for your reply. If you can see the screenshot, it is having the higher version of the .NET Framework 4.8.3761.0. How to analyse a project targeting an older version of the .NET Framework?
We have production build node having above stated version of .NET framework, but can’t change on the node as it may impact other things on the node.
Your screenshot shows that you have MSBuild 4.8 that I believe was shipped with .NET Framework 4.0. You will need at least Framework 4.6 installed for the analysis to run. If you are unable to put a later version on this node I suggest you try running the analysis on a separate node with a later version of the framework installed.
The is the underlying issue that is stopping your build from working, and is unrelated to Sonar analysis.
Logically, when building an application there are two different versions of .NET are relevant:
(1) the version of .NET (and hence MSBuild) that is being used to execute the build, and
(2) the version of .NET that the built assemblies are targeting i.e. are intended to run against.
These versions can be different. However, if they are then the build machine will need to the SDK/Targeting Pack for the target version of .NET. See the MS docs for more information.
As a first step, get the build working correctly without the scanner begin and end steps.
.NET folder version name does not match the installed version number
This is expected. If you check the file properties of a file inside the v4.0.30319 directory (e.g. msbuild.exe) you will see the file and product versions of the file are different e.g. v.4.8.3761.0 in your case.