C# Scan results are not being sent to SonarCloud....

704 views
Skip to first unread message

Matt Moore

unread,
Apr 9, 2018, 5:54:50 PM4/9/18
to SonarQube
Hello all, thanks for your help in advance.

Things were working fine until roughly March 12th when we noticed that C# scan results (only) were not being uploaded to the SonarCloud server.  The files were indexed but the results of the scan for those files were not being recorded.

Please find attached a verbose log.

Item of interest:

INFO: -------------  Scan CranSoft.Utilities
INFO: Base dir: C:\build\DSP\70\CranSoft.Utilities\libraries\CranSoft.Utilities\CranSoft.Utilities
INFO: Working dir: C:\build\DSP\70\CranSoft.Utilities\libraries\CranSoft.Utilities\.sonarqube\out\.sonar\mod1
INFO: Source paths: ApplicationEnvironment.cs, AssemblyInfo/AssemblyRevisionInfo.cs, Collections/DictionaryHelpers.cs, Collections/Extensions.cs, Collections/IOrderedDictionary!2.cs, Collections/KeyValueCollection!2.cs, Collections/KeyValueCollection.cs, Collections/OrderedDictionary!2.cs, Collections/ReadOnlyDictionary!2.cs, Collections/Sorting/DirectedGraph.cs, Collections/XmlSerializableDictionary!2.cs, Data/ColumnMappingAttribute.cs, ComponentModel/BinarySearch!1.cs, ComponentModel/DefaultValueOutOfRangeException!1.cs, ComponentModel/EnumConverter!1.cs, ComponentModel/MemberInfoAttributeCache.cs, ComponentModel/ObjectConverter.cs, ComponentModel/PropertyBinder.cs, ComponentModel/PropertyBinding.cs, ComponentModel/TypeHelpers.cs, ComponentModel/TypePropertyCache.cs, Contracts/Arg.cs, Contracts/Collections/CollectionExtensions.cs, Contracts/Extensions.cs, Contracts/IArg.cs, Contracts/IArg`1.cs, Contracts/IO/PathArg.cs, Contracts/IO/PathArgExtensions.cs, Contracts/IO/StreamExtensions.cs, Contracts/Require.cs, Contracts/Types/EnumArg.cs, Contracts/Types/EnumArgExtensions.cs, Diagnostics/EmptyLogEventSink.cs, Diagnostics/Enumerations.cs, Diagnostics/ILogEventSink.cs, Diagnostics/Log.cs, Diagnostics/LogEvent.cs, Diagnostics/StackHelpers.cs, Diagnostics/Tracing/Enums.cs, Diagnostics/Tracing/NullTracer.cs, Diagnostics/Tracing/TraceContext.cs, Diagnostics/Tracing/Tracer.cs, Data/Enumerations.cs, Exceptions/ExceptionExtensions.cs, Exceptions/Throwable.cs, Helpers/BooleanHelpers.cs, Helpers/ExceptionHelpers.cs, Helpers/GuidHelpers.cs, Helpers/StringHelpers.cs, IO/Compression/ZipHelpers.cs, IO/DirectoryHelpers.cs, IO/FileHelpers.cs, IO/IStreamFormattable.cs, IO/PathCompressor.cs, IO/PathHelpers.cs, IO/Resolver.cs, IO/ResourceHelpers.cs, IO/StreamHelpers.cs, Properties/AssemblyInfo.cs, Reflection/AttributeHelper.cs, Reflection/EnumHelper.cs, Reflection/TypeExtensions.cs, Reflection/TypeUtils.cs, Security/Cryptography/CryptoHelpers.cs, Security/Cryptography/Enumerations.cs, Security/Cryptography/HashAlgorithms/HmacSHA256.cs, Security/Cryptography/HashAlgorithms/IHmacProvider.cs, Security/Hardware/Identification.cs, Text/DynamicSubstitution/DynamicString.cs, Text/DynamicSubstitution/DynamicValueAttribute.cs, Text/DynamicSubstitution/Embed.cs, Text/DynamicSubstitution/ExpressionToken.cs, Text/DynamicSubstitution/FluentDynamicString.cs, Text/DynamicSubstitution/IDynamicValueProvider.cs, Text/DynamicSubstitution/Interpolator.cs, Text/DynamicSubstitution/Parser.cs, Text/DynamicSubstitution/ParserState.cs, Text/DynamicSubstitution/PrimitiveSerializer.cs, Text/DynamicSubstitution/Resolve.cs, Text/DynamicSubstitution/StringLiteralToken.cs, Text/DynamicSubstitution/Token.cs, Text/DynamicSubstitution/TokenFoundEventArgs.cs, Text/DynamicSubstitution/TokenList.cs, Text/DynamicSubstitution/Utilities.cs, Text/Enumerations.cs, Text/StringExtensions.cs, Text/StringScript.cs, Text/Wildcard.cs, Web/Json/JsonBuilder.cs, Xml/XmlSerializationHelpers.cs, Xml/XmlPrimitiveSerializer.cs
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Excluded sources: 
INFO:   **/*.llblgenproj
INFO: 91 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
WARNING: WARN: Analyzer working directory does not exist: 'C:\build\DSP\70\CranSoft.Utilities\libraries\CranSoft.Utilities\.sonarqube\out\CranSoft.Utilities_6467\output-cs'. Analyzer results won't be loaded from this directory.
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: SCM provider for this project is: git
INFO: 1 files to be analyzed
INFO: 0/1 files analyzed
WARNING: WARN: Missing blame information for the following files:
WARNING: WARN:   * CranSoft.Utilities/AssemblyInfo/AssemblyRevisionInfo.cs
WARNING: WARN: This may lead to missing/broken features in SonarQube
INFO: -------------  Scan DSP-70-CranSoft.Utilities-CranSoft.Utilities
INFO: Base dir: C:\build\DSP\70\CranSoft.Utilities\libraries\CranSoft.Utilities
INFO: Working dir: C:\build\DSP\70\CranSoft.Utilities\libraries\CranSoft.Utilities\.sonarqube\out\.sonar
INFO: Source encoding: windows-1252, default locale: en_US
INFO: Index files
INFO: Excluded sources: 
INFO:   **/*.llblgenproj
INFO: 0 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=69ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=22ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 404ms, dir size=785 KB
INFO: Analysis reports compressed in 142ms, zip size=226 KB
INFO: Analysis report uploaded in 833ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarcloud.io/dashboard/index/DSP-70-CranSoft.Utilities-CranSoft.Utilities
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AWIqrbUlV4Tcj4EG2awx
INFO: Task total time: 11.296 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 26.663s
INFO: Final Memory: 61M/148M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
13:20:38.158  Creating a summary markdown file...
13:20:38.162  Analysis results: https://sonarcloud.io/dashboard/index/DSP-70-CranSoft.Utilities-CranSoft.Utilities
13:20:38.162  Post-processing succeeded.



The working directory WARN was not there the build before.  In previous builds the message there was 'Found 6 protobuf....' and my results were visible in SonarCloud.


The other interesting snippet is the 91 files indexed at the top of the snippet but then 0 files indexed later on for the same project.


Not sure what is going on as we did not make any config changes to the SonarCloud server nor the machine building and running the analysis.


Any ideas would be greatly appreciated,


Matt


SonarQube_output.rtf
Files_but_no_scan_data.png

Matt Moore

unread,
Apr 9, 2018, 6:41:45 PM4/9/18
to SonarQube
Another piece of information I've discovered is that the drop in number of files (the C# ones disappearing) happened between evening of 3/11 and morning of 3/12 which is a Sunday evening to Monday morning timeframe (see attached image).  This leads me to believe a change in config on our side is not the cause of this issue because we don't work Sunday nights :)

Matt
Change_from_311_to_312.png

duncan.po...@sonarsource.com

unread,
Apr 10, 2018, 2:37:00 PM4/10/18
to SonarQube
Hi Matt,

Thanks for the providing so much detail up front.

Which version of the Visual Studio are you using on your build agent?

From the logs, it looks like it might be Visual Studio 2015 RTM i.e. 2015 with no service packs (I'm guessing that because that version of VS2015 produces invalid .json for the Roslyn analyzers, and it looks from the log that the Scanner for MSBuild is fixing up the invalid json).

If you are currently running VS2015 RTM, is it possible for you to install VS2015 Update 3, which is the most recent supported update from Microsoft?


My best guess at the moment is that the change in behaviour is connected to the release of SonarC# v7. That was released on March 5th and will have been deployed to SonarCloud shortly afterwards, although I don't know exactly when. SonarC# v7 dropped support for VS2015 prior to VS2015 Update 3 for technical reasons (specifically so that we can handle some of the new C# syntax that has been added in the last few years, and take advantage of some of the newer features that have been added to the Roslyn framework).

However, if that were the case then I'm not sure why Roslyn .json report files are being produced at all. Are there are any warnings or errors in MSBuild section of the log?

Regards,
Duncan

Matt Moore

unread,
Apr 10, 2018, 4:01:38 PM4/10/18
to SonarQube
Thanks for the reply.  We do not have VS installed on the build box but rather we use MSBuild v14 to build our .NET 4.6 application.

Only thing in the build log that stands out is many occurrences of:
C:\Users\Administrator\AppData\Local\Temp\2\.sonarqube\resources\6\SonarAnalyzer.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..


Which just started appearing in build logs around the time of the SonarC# v7 update on March 12th or so.  Must be related.  Does this mean I can get away with just updating my version of MSBuild or am I forcced to install full version of VS2015 on our build box?  

Matt

duncan.po...@sonarsource.com

unread,
Apr 11, 2018, 5:19:00 AM4/11/18
to SonarQube
That error looks like what I'd expect if MSBuild is using an older version of Roslyn, and it would stop SonarC# issues from being reported.

Installing Visual Studio isn't a requirement - updating the version of MSBuild to one that contains Roslyn v1.3 or later should work.

Out of interest, where are you downloading the installer for MSBuild from? I can find downloads for the major versions of MSBuild (Microsoft Build Tools 2015 in the Microsoft Download Centre and 
Build Tools For Visual Studio 2017 on www.visualstudio.com), but I can't find installers for the updates to MSBuild 14 that shipped with the Visual Studio 2015 updates.

Thanks,
Duncan

Matt Moore

unread,
May 1, 2018, 2:32:37 PM5/1/18
to SonarQube
We upgraded to MSBuild 15 and all is well.  Thanks for the help!

Matt
Reply all
Reply to author
Forward
0 new messages