Is it possible to get the analyzer error to break the build, I've the rule severity to error which does flag as a red squiggle in the IDE with an accompanying intellisense error. However if possible can you raise it as a build error?
Thanks
You need to pass the analyzer to the compiler, instead of having it installed into VS as a VSIX in order for it to break the build.
Related
I installed the SonarLint extension for Visual Studio and connected successfully to our SonarQube server and successfully ran Code Analysis to display sonar issues in VS. So it was working OK but for some reason I am now no longer getting any sonar Sxxx warnings and instead now see the following 2 warnings:
> Warning CA0507 Post-build Code Analysis (FxCopCmd.exe) has been
> deprecated in favor of FxCop analyzers, which run during build. Refer
> to https://aka.ms/fxcopanalyzers to migrate to FxCop analyzers.
>
> Warning CA0064 : No analysis was performed because the
> specified rule set could not be loaded or did not contain any managed
> code analysis rules.
But I am not using FxCop and I am not aware of having done anything to turn it on.
If I check one rule inside "Managed Binary Analysis" the CA0064 warning will go away, but CA0507 remains and still no sonar Sxxx warnings.
The "Run Code Analysis" menu items only apply to the legacy FxCop rules. You don't need to use those menu items for Roslyn-based analyzers (like the C# and VB.NET rules in SonarLint) - Visual Studio will automatically trigger the analysis in the background. See the Microsoft docs for more info.
If you are not seeing Sxxx issues being reported there are a couple of things to look at:
Check whether you have the Enable full solution analysis option checked. If not, VS will only report issues in open files.
You've connected the solution to your SonarQube server so SonarLint will have generated a ruleset based on the Quality Profile. The ruleset will be in the solution-level .sonarlint folder. Check whether the rules you are expecting to report issues are enabled in the ruleset file. If not, update the Quality Profile on the server then close and re-open the solution. SonarLint will detect that the Quality Profile has changed and prompt you to update it.
Try to Compile again the project. With first compilation this errors will appear but with second compilation probably not.
No idea why, but it worked for me.
I analyze C# projects using MSBuild.SonarQube.Runner-2.1:
MSBuild.SonarQube.Runner.exe begin /k:"%SKEY%" /n:"%SNAME%" /v:"%SVERSION%"
"c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /t:Rebuild
MSBuild.SonarQube.Runner.exe end
The analysis works fine and the analyzed project is created on SQ.
The problem is that when I click at 'Issues' on the project's site on SQ and then double-click at an issue then the source code with the corresponding rule violation is NOT shown! Why?
SQ version: 5.3.
VS version: 2015.
I think I found the reason: it were all fxcop rules which were violated. And fxcop analyzes the compiled managed code which makes it impossible to associate the rule violation with a concrete line of code.
Among all the fxcop rule violations I also found one stylecop rule violation in the project. For this violation the source code was displayed because stylecop analyzes the source files.
I have a visual studio project (VS2012) that just contains some configuration files. When I build I get the following warning:
CSC : warning CS2008: No source files specified [C:\Project\Config\Config.csproj]
Is there any way to disable this warning?
I experienced the same problem with VS2017 (<nowarn> attribute didn't work). Adding an empty VersionInfo.cs prevented the build warning.
Go to the project's property page in your Solution Explorer. On the build tab, you can disable the warning using its warning number.
This describes the options available there: http://msdn.microsoft.com/en-us/library/vstudio/kb4wyys2(v=vs.100).aspx
If you ever have actual code that triggers warnings, it can be disabled like so: http://msdn.microsoft.com/en-us/library/vstudio/441722ys(v=vs.120).aspx
In Xamarin Studio, is it possible to have the compiler treat certain warnings as errors? I would like to elevate the severity of some warning so I am forced to see and deal with them. I am using the Mac version.
If your project is a normal C# project then you can select which warnings you want to be treated as errors in the Build/Compiler page in the project's properties. In the "Additional arguments" field enter:
-warnaserror:CS0123,CS3210
To make the warnings CS0123 and CS3210 be treated as errors.
I converted one of the .net 2.0 (VS2005) solution to work with VS2010 (didn't change the framework). Now when I try to build I keep getting this error message:
'Warning as Error 2008 is not a valid warning number'.
Does anyone know how I can fix this?
Are there any #pragma warnings in the project? Do you get a line number with your error?
EDIT:
Try unchecking treat warnings as errors in your project config. That should allow you to compile.