Example #1
0
        private string CreateProjectFile(AnalysisConfig config, string projectSnippet)
        {
            var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
            var targetTestUtils  = new TargetsTestsUtils(TestContext);
            var projectTemplate  = targetTestUtils.GetProjectTemplate(config, projectDirectory, TestSpecificProperties, projectSnippet);

            return(targetTestUtils.CreateProjectFile(projectDirectory, projectTemplate));
        }
Example #2
0
        private string CreateProjectFile(string projectSnippet)
        {
            var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
            var targetTestUtils  = new TargetsTestsUtils(TestContext);
            var projectTemplate  = targetTestUtils.GetProjectTemplate(null, projectDirectory, null, projectSnippet);

            return(targetTestUtils.CreateProjectFile(projectDirectory, projectTemplate));
        }
Example #3
0
        private string CreateProjectFile(string projectSnippet)
        {
            // This target captures the ItemGroup we're interested in
            var captureReferences = $@"
<Project ToolsVersion='Current' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <Target Name='CaptureValues' AfterTargets='{TargetConstants.CategoriseProjectTarget}'>
    <Message Importance='high' Text='CAPTURE::ITEM::{TargetProperties.SonarResolvedReferences}::%({TargetProperties.SonarResolvedReferences}.Identity)' />
  </Target>
</Project>";
            var projectDirectory  = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
            var targetTestUtils   = new TargetsTestsUtils(TestContext);
            var capturePath       = targetTestUtils.CreateCaptureTargetsFile(projectDirectory, captureReferences);
            var projectTemplate   = targetTestUtils.GetProjectTemplate(null, projectDirectory, null, projectSnippet, $"<Import Project='{capturePath}' />");

            return(targetTestUtils.CreateProjectFile(projectDirectory, projectTemplate));
        }
Example #4
0
        private string CreateProjectFile(string projectFileName, string xmlSnippet, string analysisConfigDir)
        {
            var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");

            var sqTargetFile    = TestUtils.EnsureAnalysisTargetsExists(TestContext);
            var projectFilePath = Path.Combine(rootInputFolder, projectFileName);

            var targetTestUtils = new TargetsTestsUtils(TestContext);

            // Boilerplate XML for minimal project file that will execute the "categorise project" task
            var projectXml = Properties.Resources.CategoriseProjectTestTemplate;

            BuildUtilities.CreateFileFromTemplate(projectFilePath, TestContext, projectXml,
                                                  xmlSnippet,
                                                  Guid.NewGuid(),
                                                  typeof(WriteProjectInfoFile).Assembly.Location,
                                                  sqTargetFile,
                                                  analysisConfigDir);

            return(projectFilePath);
        }