Exemple #1
0
        public void WriteProjectInfo_BareProject()
        {
            // Checks the WriteProjectInfo target handles non-VB/C# project types
            // that don't import the standard targets or set the expected properties

            // Arrange
            string rootInputFolder  = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs");
            string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs");

            BuildLogger logger = new BuildLogger();

            string sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(this.TestContext);
            string projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            Guid   projectGuid     = Guid.NewGuid();

            string             projectXml  = @"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <ProjectGuid>{0}</ProjectGuid>

    <SonarQubeTempPath>{1}</SonarQubeTempPath>
    <SonarQubeOutputPath>{1}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{2}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <Import Project='{3}' />
</Project>
";
            ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml,
                                                                                      projectGuid.ToString(),
                                                                                      rootOutputFolder,
                                                                                      typeof(WriteProjectInfoFile).Assembly.Location,
                                                                                      sqTargetFile);

            // Act
            BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger,
                                                             TargetConstants.WriteProjectDataTarget);

            // Assert
            BuildAssertions.AssertTargetSucceeded(result, TargetConstants.WriteProjectDataTarget);

            ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            Assert.AreEqual(projectGuid, projectInfo.ProjectGuid, "Unexpected project guid");
            Assert.IsNull(projectInfo.ProjectLanguage, "Expecting the project language to be null");
            Assert.IsFalse(projectInfo.IsExcluded, "Project should not be marked as excluded");
            Assert.AreEqual(ProjectType.Product, projectInfo.ProjectType, "Project should be marked as a product project");
            Assert.AreEqual(0, projectInfo.AnalysisResults.Count, "Not expecting any analysis results to have been created");
        }
Exemple #2
0
        public void WriteProjectInfo_UnrecognisedLanguage()
        {
            // Checks the WriteProjectInfo target handles projects with unrecognised languages

            // Arrange
            string rootInputFolder  = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs");
            string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs");

            BuildLogger logger = new BuildLogger();

            string sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(this.TestContext);
            string projectFilePath = Path.Combine(rootInputFolder, "unrecognisedLanguage.proj.txt");

            string             projectXml  = @"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <Language>my.special.language</Language>
    <ProjectGuid>670DAF47-CBD4-4735-B7A3-42C0A02B1CB9</ProjectGuid>

    <SonarQubeTempPath>{0}</SonarQubeTempPath>
    <SonarQubeOutputPath>{0}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{1}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <Import Project='{2}' />
</Project>
";
            ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml,
                                                                                      rootOutputFolder,
                                                                                      typeof(WriteProjectInfoFile).Assembly.Location,
                                                                                      sqTargetFile);

            // Act
            BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger,
                                                             TargetConstants.WriteProjectDataTarget);

            // Assert
            BuildAssertions.AssertTargetSucceeded(result, TargetConstants.WriteProjectDataTarget);

            ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            Assert.AreEqual("my.special.language", projectInfo.ProjectLanguage, "Unexpected project language");
            Assert.AreEqual(0, projectInfo.AnalysisResults.Count, "Not expecting any analysis results to have been created");
        }
Exemple #3
0
        public void WriteProjectInfo_BareProject()
        {
            // Checks the WriteProjectInfo target handles non-VB/C# project types
            // that don't import the standard targets or set the expected properties

            // Arrange
            var rootInputFolder  = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
            var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            var projectGuid     = Guid.NewGuid();

            var projectXml  = $@"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <ProjectGuid>{projectGuid}</ProjectGuid>

    <SonarQubeTempPath>{rootOutputFolder}</SonarQubeTempPath>
    <SonarQubeBuildTasksAssemblyFile>{typeof(WriteProjectInfoFile).Assembly.Location}</SonarQubeBuildTasksAssemblyFile>
    <SonarQubeOutputPath>{rootOutputFolder}</SonarQubeOutputPath>
  </PropertyGroup>

  <Import Project='{sqTargetFile}' />
</Project>
";
            var projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, TestContext, projectXml);

            // Act
            var result = BuildRunner.BuildTargets(TestContext, projectRoot.FullPath,
                                                  TargetConstants.SonarWriteProjectData);

            // Assert
            result.AssertTargetSucceeded(TargetConstants.SonarWriteProjectData);

            var projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            projectInfo.ProjectGuid.Should().Be(projectGuid, "Unexpected project guid");
            projectInfo.ProjectLanguage.Should().BeNull("Expecting the project language to be null");
            projectInfo.IsExcluded.Should().BeFalse("Project should not be marked as excluded");
            projectInfo.ProjectType.Should().Be(ProjectType.Product, "Project should be marked as a product project");
            projectInfo.AnalysisResults.Should().BeEmpty("Not expecting any analysis results to have been created");
        }
Exemple #4
0
        public void WriteProjectInfo_UnrecognisedLanguage()
        {
            // Checks the WriteProjectInfo target handles projects with unrecognized languages

            // Arrange
            var rootInputFolder  = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
            var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(rootInputFolder, "unrecognisedLanguage.proj.txt");

            var projectXml  = $@"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <Language>my.special.language</Language>
    <ProjectGuid>670DAF47-CBD4-4735-B7A3-42C0A02B1CB9</ProjectGuid>

    <SonarQubeTempPath>{rootOutputFolder}</SonarQubeTempPath>
    <SonarQubeOutputPath>{rootOutputFolder}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{typeof(WriteProjectInfoFile).Assembly.Location}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <Import Project='{sqTargetFile}' />
</Project>
";
            var projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, TestContext, projectXml);

            // Act
            var result = BuildRunner.BuildTargets(TestContext, projectRoot.FullPath,
                                                  TargetConstants.SonarWriteProjectData);

            // Assert
            result.AssertTargetSucceeded(TargetConstants.SonarWriteProjectData);

            var projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            projectInfo.ProjectLanguage.Should().Be("my.special.language", "Unexpected project language");
            projectInfo.AnalysisResults.Should().BeEmpty("Not expecting any analysis results to have been created");
        }
Exemple #5
0
        public void E2E_RazorProject_ValidProjectInfoFilesGenerated()
        {
            // Checks that projects that don't include the standard managed targets are still
            // processed correctly e.g. can be excluded, marked as test projects etc

            // Arrange
            var rootInputFolder        = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
            var rootOutputFolder       = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
            var defaultProjectInfoPath = Path.Combine(rootOutputFolder, @"0\ProjectInfo.xml");
            var razorProjectInfoPath   = Path.Combine(rootOutputFolder, @"0.Razor\ProjectInfo.xml");

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            var projectGuid     = Guid.NewGuid();

            var defaultProjectOutPaths = Path.Combine(rootOutputFolder, @"0");
            var razorProjectOutPaths   = Path.Combine(rootOutputFolder, @"0.Razor");
            var defaultReportFilePaths = Path.Combine(defaultProjectOutPaths, @"Issues.json");
            var razorReportFilePaths   = Path.Combine(razorProjectOutPaths, @"Issues.Views.json");
            var filestoAnalyzePath     = Path.Combine(rootOutputFolder, @"conf\0\FilesToAnalyze.txt");

            var projectXml  = $@"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <Language>my.language</Language>

    <ProjectGuid>{projectGuid}</ProjectGuid>
    <SQLanguage>cs</SQLanguage>
    <SonarQubeTempPath>{rootOutputFolder}</SonarQubeTempPath>
    <SonarQubeOutputPath>{rootOutputFolder}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{typeof(WriteProjectInfoFile).Assembly.Location}</SonarQubeBuildTasksAssemblyFile>
    <TargetFramework>net5</TargetFramework>
    <RazorTargetNameSuffix>.Views</RazorTargetNameSuffix>
  </PropertyGroup>

  <ItemGroup>
    <RazorCompile Include='SomeRandomValue' />
    <SonarQubeAnalysisFiles Include='SomeRandomFile' />
  </ItemGroup>

  <Import Project='{sqTargetFile}' />

  <Target Name='CoreCompile'>
    <Message Importance='high' Text='In dummy core compile target' />
    <WriteLinesToFile File='$(ErrorLog)' Overwrite='true' />
  </Target>

  <Target Name='RazorCoreCompile' AfterTargets='CoreCompile'>
    <Message Importance='high' Text='In dummy razor core compile target' />
    <WriteLinesToFile File='$(RazorSonarErrorLog)' Overwrite='true' />
  </Target>

  <Target Name='Build' DependsOnTargets='CoreCompile;RazorCoreCompile'>
    <Message Importance='high' Text='In dummy build target' />
  </Target>

</Project>
";
            var projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, TestContext, projectXml);

            // Act
            var result = BuildRunner.BuildTargets(TestContext, projectRoot.FullPath, TargetConstants.DefaultBuild);

            // Assert
            result.BuildSucceeded.Should().BeTrue();

            result.AssertTargetOrdering(
                TargetConstants.SonarCategoriseProject,
                TargetConstants.SonarWriteFilesToAnalyze,
                TargetConstants.CoreCompile,
                TargetConstants.InvokeSonarWriteProjectData_RazorProject,
                TargetConstants.SonarWriteProjectData,
                TargetConstants.SonarPrepareRazorProjectCodeAnalysis,
                TargetConstants.RazorCoreCompile,
                TargetConstants.SonarFinishRazorProjectCodeAnalysis,
                TargetConstants.DefaultBuild);

            // Check the project info
            File.Exists(defaultProjectInfoPath).Should().BeTrue();
            File.Exists(razorProjectInfoPath).Should().BeTrue();
            var defaultProjectInfo = ProjectInfo.Load(defaultProjectInfoPath);
            var razorProjectInfo   = ProjectInfo.Load(razorProjectInfoPath);

            AssertProjectInfoContent(defaultProjectInfo, defaultReportFilePaths, defaultProjectOutPaths, filestoAnalyzePath);
            AssertProjectInfoContent(razorProjectInfo, razorReportFilePaths, razorProjectOutPaths, filestoAnalyzePath);
        }
Exemple #6
0
        public void E2E_BareProject_CorrectlyCategorised()
        {
            // Checks that projects that don't include the standard managed targets are still
            // processed correctly e.g. can be excluded, marked as test projects etc

            // Arrange
            var rootInputFolder  = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
            var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            var projectGuid     = Guid.NewGuid();

            var projectXml  = $@"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <SonarQubeExclude>true</SonarQubeExclude>
    <Language>my.language</Language>
    <ProjectTypeGuids>{TargetConstants.MsTestProjectTypeGuid}</ProjectTypeGuids>

    <ProjectGuid>{projectGuid}</ProjectGuid>

    <SonarQubeTempPath>{rootOutputFolder}</SonarQubeTempPath>
    <SonarQubeOutputPath>{rootOutputFolder}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{typeof(WriteProjectInfoFile).Assembly.Location}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <ItemGroup>
    <!-- no recognized content -->
  </ItemGroup>

  <Import Project='{sqTargetFile}' />

  <Target Name='CoreCompile' BeforeTargets=""Build"">
    <Message Importance='high' Text='In dummy core compile target' />
  </Target>

  <Target Name='Build'>
    <Message Importance='high' Text='In dummy build target' />
  </Target>

</Project>
";
            var projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, TestContext, projectXml);

            // Act
            var result = BuildRunner.BuildTargets(TestContext, projectRoot.FullPath,
                                                  TargetConstants.DefaultBuild);

            // Assert
            result.BuildSucceeded.Should().BeTrue();

            result.AssertTargetOrdering(
                TargetConstants.SonarCategoriseProject,
                TargetConstants.SonarWriteFilesToAnalyze,
                TargetConstants.CoreCompile,
                TargetConstants.DefaultBuild,
                TargetConstants.InvokeSonarWriteProjectData_NonRazorProject,
                TargetConstants.SonarWriteProjectData);

            // Check the project info
            var projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            projectInfo.IsExcluded.Should().BeTrue("Expecting the project to be marked as excluded");
            projectInfo.ProjectLanguage.Should().Be("my.language", "Unexpected project language");
            projectInfo.ProjectType.Should().Be(ProjectType.Test, "Project should be marked as a test project");
            projectInfo.AnalysisResults.Should().BeEmpty("Unexpected number of analysis results created");
        }
Exemple #7
0
        public void E2E_BareProject_FilesToAnalyze()
        {
            // Checks the integration targets handle non-VB/C# project types
            // that don't import the standard targets or set the expected properties
            // The project info should be created as normal and the correct files to analyze detected.

            // Arrange
            var context = CreateContext();

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(context.InputFolder, "project.txt");
            var projectGuid     = Guid.NewGuid();

            var codeFile       = context.CreateInputFile("code.cpp");
            var contentFile    = context.CreateInputFile("code.js");
            var unanalysedFile = context.CreateInputFile("text.shouldnotbeanalysed");
            var excludedFile   = context.CreateInputFile("excluded.cpp");

            var projectXml  = $@"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <ProjectGuid>{projectGuid}</ProjectGuid>

    <SonarQubeTempPath>{context.OutputFolder}</SonarQubeTempPath>
    <SonarQubeOutputPath>{context.OutputFolder}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{typeof(WriteProjectInfoFile).Assembly.Location}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <ItemGroup>
    <ClCompile Include='{codeFile}' />
    <Content Include='{contentFile}' />
    <ShouldBeIgnored Include='{unanalysedFile}' />
    <ClCompile Include='{excludedFile}'>
      <SonarQubeExclude>true</SonarQubeExclude>
    </ClCompile>
  </ItemGroup>

  <Import Project='{sqTargetFile}' />

  <Target Name='CoreCompile' BeforeTargets=""Build"">
    <Message Importance='high' Text='In dummy core compile target' />
  </Target>

  <Target Name='Build'>
    <Message Importance='high' Text='In dummy build target' />
  </Target>

</Project>
";
            var projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, TestContext, projectXml);

            // Act
            var result = BuildRunner.BuildTargets(TestContext, projectRoot.FullPath,
                                                  TargetConstants.DefaultBuild);

            // Assert
            result.BuildSucceeded.Should().BeTrue();

            result.AssertTargetOrdering(
                TargetConstants.SonarCategoriseProject,
                TargetConstants.SonarWriteFilesToAnalyze,
                TargetConstants.CoreCompile,
                TargetConstants.DefaultBuild,
                TargetConstants.InvokeSonarWriteProjectData_NonRazorProject,
                TargetConstants.SonarWriteProjectData);

            // Check the content of the project info xml
            var projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(context.OutputFolder, projectRoot.FullPath);

            projectInfo.ProjectGuid.Should().Be(projectGuid, "Unexpected project guid");
            projectInfo.ProjectLanguage.Should().BeNull("Expecting the project language to be null");
            projectInfo.IsExcluded.Should().BeFalse("Project should not be marked as excluded");
            projectInfo.ProjectType.Should().Be(ProjectType.Product, "Project should be marked as a product project");
            projectInfo.AnalysisResults.Should().HaveCount(1, "Unexpected number of analysis results created");

            // Check the correct list of files to analyze were returned
            var filesToAnalyze       = ProjectInfoAssertions.AssertAnalysisResultExists(projectInfo, AnalysisType.FilesToAnalyze.ToString());
            var actualFilesToAnalyze = File.ReadAllLines(filesToAnalyze.Location);

            actualFilesToAnalyze.Should().BeEquivalentTo(new string[] { codeFile, contentFile }, "Unexpected list of files to analyze");
        }
Exemple #8
0
        public void E2E_BareProject_CorrectlyCategorised()
        {
            // Checks that projects that don't include the standard managed targets are still
            // processed correctly e.g. can be excluded, marked as test projects etc

            // Arrange
            string rootInputFolder  = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs");
            string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs");

            BuildLogger logger = new BuildLogger();

            string sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(this.TestContext);
            string projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            Guid   projectGuid     = Guid.NewGuid();

            string             projectXml  = @"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <SonarQubeExclude>true</SonarQubeExclude>
    <Language>my.language</Language>
    <ProjectTypeGuids>{4}</ProjectTypeGuids>

    <ProjectGuid>{0}</ProjectGuid>

    <SonarQubeTempPath>{1}</SonarQubeTempPath>
    <SonarQubeOutputPath>{1}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{2}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <ItemGroup>
    <!-- no recognised content -->
  </ItemGroup>

  <Import Project='{3}' />

  <Target Name='Build'>
    <Message Importance='high' Text='In dummy build target' />
  </Target>

</Project>
";
            ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml,
                                                                                      projectGuid.ToString(),
                                                                                      rootOutputFolder,
                                                                                      typeof(WriteProjectInfoFile).Assembly.Location,
                                                                                      sqTargetFile,
                                                                                      TargetConstants.MsTestProjectTypeGuid
                                                                                      );

            // Act
            BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger,
                                                             TargetConstants.DefaultBuildTarget);

            // Assert
            BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget);

            logger.AssertExpectedTargetOrdering(
                TargetConstants.DefaultBuildTarget,
                TargetConstants.CategoriseProjectTarget,
                TargetConstants.CalculateFilesToAnalyzeTarget,
                TargetConstants.WriteProjectDataTarget);

            // Check the project info
            ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            Assert.IsTrue(projectInfo.IsExcluded, "Expecting the project to be marked as excluded");
            Assert.AreEqual("my.language", projectInfo.ProjectLanguage, "Unexpected project language");
            Assert.AreEqual(ProjectType.Test, projectInfo.ProjectType, "Project should be marked as a test project");
            Assert.AreEqual(0, projectInfo.AnalysisResults.Count, "Unexpected number of analysis results created");
        }
Exemple #9
0
        public void E2E_BareProject_FilesToAnalyse()
        {
            // Checks the integration targets handle non-VB/C# project types
            // that don't import the standard targets or set the expected properties
            // The project info should be created as normal and the correct files to analyse detected.

            // Arrange
            string rootInputFolder  = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs");
            string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs");

            BuildLogger logger = new BuildLogger();

            string sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(this.TestContext);
            string projectFilePath = Path.Combine(rootInputFolder, "project.txt");
            Guid   projectGuid     = Guid.NewGuid();

            string codeFile       = CreateEmptyFile(rootInputFolder, "cpp");
            string contentFile    = CreateEmptyFile(rootInputFolder, ".js");
            string unanalysedFile = CreateEmptyFile(rootInputFolder, ".shouldnotbeanalysed");
            string excludedFile   = CreateEmptyFile(rootInputFolder, "excluded.cpp");

            string             projectXml  = @"<?xml version='1.0' encoding='utf-8'?>
<Project ToolsVersion='12.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>

  <PropertyGroup>
    <ProjectGuid>{0}</ProjectGuid>

    <SonarQubeTempPath>{1}</SonarQubeTempPath>
    <SonarQubeOutputPath>{1}</SonarQubeOutputPath>
    <SonarQubeBuildTasksAssemblyFile>{2}</SonarQubeBuildTasksAssemblyFile>
  </PropertyGroup>

  <ItemGroup>
    <ClCompile Include='{4}' />
    <Content Include='{5}' />
    <ShouldBeIgnored Include='{6}' />
    <ClCompile Include='{7}'>
      <SonarQubeExclude>true</SonarQubeExclude>
    </ClCompile>
  </ItemGroup>

  <Import Project='{3}' />

  <Target Name='Build'>
    <Message Importance='high' Text='In dummy build target' />
  </Target>

</Project>
";
            ProjectRootElement projectRoot = BuildUtilities.CreateProjectFromTemplate(projectFilePath, this.TestContext, projectXml,
                                                                                      projectGuid.ToString(),
                                                                                      rootOutputFolder,
                                                                                      typeof(WriteProjectInfoFile).Assembly.Location,
                                                                                      sqTargetFile,
                                                                                      codeFile,
                                                                                      contentFile,
                                                                                      unanalysedFile,
                                                                                      excludedFile
                                                                                      );

            // Act
            BuildResult result = BuildUtilities.BuildTargets(projectRoot, logger,
                                                             TargetConstants.DefaultBuildTarget);

            // Assert
            BuildAssertions.AssertTargetSucceeded(result, TargetConstants.DefaultBuildTarget);

            logger.AssertExpectedTargetOrdering(
                TargetConstants.DefaultBuildTarget,
                TargetConstants.CategoriseProjectTarget,
                TargetConstants.CalculateFilesToAnalyzeTarget,
                TargetConstants.WriteProjectDataTarget);

            // Check the content of the project info xml
            ProjectInfo projectInfo = ProjectInfoAssertions.AssertProjectInfoExists(rootOutputFolder, projectRoot.FullPath);

            Assert.AreEqual(projectGuid, projectInfo.ProjectGuid, "Unexpected project guid");
            Assert.IsNull(projectInfo.ProjectLanguage, "Expecting the project language to be null");
            Assert.IsFalse(projectInfo.IsExcluded, "Project should not be marked as excluded");
            Assert.AreEqual(ProjectType.Product, projectInfo.ProjectType, "Project should be marked as a product project");
            Assert.AreEqual(1, projectInfo.AnalysisResults.Count, "Unexpected number of analysis results created");

            // Check the correct list of files to analyse were returned
            AnalysisResult filesToAnalyse = ProjectInfoAssertions.AssertAnalysisResultExists(projectInfo, AnalysisType.FilesToAnalyze.ToString());

            string[] actualFilesToAnalyse = File.ReadAllLines(filesToAnalyse.Location);
            CollectionAssert.AreEquivalent(new string[] { codeFile, contentFile }, actualFilesToAnalyse, "Unexpected list of files to analyse");
        }