title: Scanning single project in .NET solution with multiple projects using SonarQube
body: <p>I have the following issue.</p>
  
  <p>We have a .NET solution which contains several projects and have created a VSTS build definition per project because we don't want to build the entire solution every time there's a change in one of the individual projects.</p>
  
  <p>Of course in this case when using SonarQube we would only want to push the metrics of that particular project / buildefinition to the SonarQube server and not of the entire solution. 
  By default the latter is what's happening and that is what we want to change.</p>
  
  <p>We are using VSTS with Visual Studio 2015, SonarQube plugin version 4.1.1 and SonarQube version 6.7 (build 33306). The buildagents are running on Windows 8.1 at this time.</p>
  
  <p>Example solution structure:</p>
  
  <p>MainSolution</p>
  
  <ul>
  <li>ProjectA</li>
  <li>ProjectB</li>
  <li>ProjectC</li>
  </ul>
  
  <p>The root sources directory for VSTS in this case is <code>C:\buildagent\vsts-agent\_work\19\s</code></p>
  
  <p>Directory structure on build agent would look like this:</p>
  
  <pre><code>C:\buildagent\vsts-agent\_work\19\s\ProjectA
  C:\buildagent\vsts-agent\_work\19\s\ProjectB
  C:\buildagent\vsts-agent\_work\19\s\ProjectC
  </code></pre>
  
  <p>Let's say we have a VSTS build definition for ProjectB which only builds ProjectB.  In that case we only want to SonarQube to scan the contents of the ProjectB project.</p>
  
  <p>I've tried several things to accomplish this but none of them worked. </p>
  
  <ol>
  <li><p>sonar.inclusions / sonar.exclusions
  Only seems to work on file level, not directory or project. Tried several settings and no error occurs but everything is ignored by the scanner which results in nothing being pushed to SQ 
  server at all.</p></li>
  <li><p>sonar.sources</p></li>
  </ol>
  
  <p>Setting the property sonar.sources to <code>C:\buildagent\vsts-agent\_work\19\s\ProjectB</code> looked promising but we got the error message below when running the scanner:</p>
  
  <blockquote>
    <p>2018-04-04T07:12:51.0538120Z INFO: Base dir: C:\buildagent\vsts-agent_work\19\s
    2018-04-04T07:12:51.0538120Z INFO: Working dir: C:\buildagent\vsts-agent_work\19.sonarqube\out.sonar
    2018-04-04T07:12:51.0538120Z INFO: Source paths: ProjectB
    2018-04-04T07:12:51.0548120Z INFO: Source encoding: windows-1252, default locale: nl_NL
    2018-04-04T07:12:51.1518136Z ERROR: Error during SonarQube Scanner execution
    2018-04-04T07:12:51.1518136Z ERROR: File ProjectB/App.config can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files</p>
  </blockquote>
  
  <p>It looks like SonarQube is trying to index ProjectB twice. Once with BaseDir set to <code>C:\buildagent\vsts-agent\_work\19\s\ProjectB</code> 
  and once with BaseDir set to <code>C:\buildagent\vsts-agent\_work\19\s</code></p>
  
  <ol start="3">
  <li>sonar.projectBaseDir</li>
  </ol>
  
  <p>When setting the property sonar.projectBaseDir to C:\buildagent\vsts-agent_work\19\s\ProjectB we receive below error from SonarQube.</p>
  
  <blockquote>
    <p>2018-04-04T07:00:51.2906744Z ERROR: Error during SonarQube Scanner execution
    2018-04-04T07:00:51.2906744Z ERROR: Dir C:\buildagent\vsts-agent_work\19\s\ProjectA should be relative to project baseDir</p>
  </blockquote>
  
  <p>It looks like it is still trying to scan the entire VSTS root source directory <code>C:\buildagent\vsts-agent\_work\19\s</code> and not just <code>C:\buildagent\vsts-agent\_work\19\s\ProjectB</code>.</p>
  
  <p>So the question remains. How can we make this work?</p>