Is there a possibility to scan the contents of a .csproj file for certain tags with a custom rule

using: Sonarqube 7.7, Developer edition.

I am trying to trigger a CodeSmell if there is a <HintPath> in the .csproj file.
This could mean the developer linked a DLL directly in stead of using a Nuget reference.
When the Nuget is updated the path to the dll will change and the reference will break.

I tried to make an XPath XML rule but it seems like it is not triggered:

expression
//*[local-name()='HintPath']

filePattern	
/**/*.csproj

message	
Projects should not refer directly to dll's but use Nuget references.

Are *.csproj files excluded automatically?

I hope someone can help me out here, thanx in advance.

Can you post an example of .csproj file where the issue should be detected? Can you also post the debug logs of the analysis when you analyze .csproj file?

Hi,
I have a similar problem. I am analyzing a .NET Core 3 console application, written in C#, using SonarScanner for Msbuild.
I would like to use a custom XPATH XML rule to check, if the node “nullable” is present and raise an error if it has not the value “enabled” in the .csproj file (/Project/PropertyGroup/Nullable[not(text()=‘enable’)]).

The problem seems to be, that the .csproj-file is ignored in the analysis, even if it is configured as XML filetype (sonar.xml.file.suffixes).
This could be, because of the msbuild integration. csproj is a special file for msbuild.

I run the following commands:

dotnet sonarscanner begin /k:"Testprojekt" /k:"sonar.verbose=true"
dotnet build .\ConsoleApp1.sln
dotnet sonarscanner end

This is a stripped-down version of the build log:

21:25:28.313 DEBUG: Declared extensions of language XML were converted to sonar.lang.patterns.xml : **/*.xml,**/*.xsd,**/*.xsl,**/*.csproj
...
21:25:28.316 INFO: Indexing files...
21:25:28.316 INFO: Project configuration:
21:25:28.318 INFO: Indexing files of module 'ConsoleApp1'
21:25:28.318 INFO:   Base dir: C:\Users\segerers\source\repos\ConsoleApp1\ConsoleApp1
21:25:28.319 DEBUG:   Source paths: Program.cs, XMLFile1.xml
21:25:28.328 INFO: Load project repositories
21:25:28.334 DEBUG: GET 200 http://localhost:9000/batch/project.protobuf?key=Testprojekt | time=6ms
21:25:28.338 INFO: Load project repositories (done) | time=10ms
21:25:28.339 DEBUG: 'Program.cs' generated metadata with charset 'UTF-8'
21:25:28.340 DEBUG: 'Program.cs' indexed with language 'cs'
21:25:28.341 DEBUG: 'XMLFile1.xml' indexed with language 'xml'
21:25:28.342 INFO: Indexing files of module 'Testprojekt'
21:25:28.342 INFO:   Base dir: C:\Users\segerers\source\repos\ConsoleApp1\ConsoleApp1
21:25:28.343 INFO: 2 files indexed
21:25:28.343 INFO: Quality profile for cs: Sonar way
21:25:28.343 INFO: Quality profile for xml: XML Test

The contents of the folder look like this:

Is there still a possibility to analyze .csproj files?