diff --git a/.gitignore b/.gitignore
index 22030f3b7..9ceb30938 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,8 @@
# Build results
+build/
+
[Dd]ebug/
[Rr]elease/
x64/
diff --git a/.sonarlint/SonarLint.xml b/.sonarlint/SonarLint.xml
index ea2fcf708..7cd29689f 100644
--- a/.sonarlint/SonarLint.xml
+++ b/.sonarlint/SonarLint.xml
@@ -14,7 +14,7 @@
headerFormat file -> server
// 0. Setup
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var config = new AnalysisConfig();
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalysisConfigTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalysisConfigTests.cs
index 44b7a4f3a..75966ca91 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalysisConfigTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalysisConfigTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -67,7 +67,7 @@ public void AnalysisConfig_Serialization_InvalidFileName()
public void AnalysisConfig_Serialization_SaveAndReload()
{
// 0. Setup
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var originalConfig = new AnalysisConfig
{
@@ -116,7 +116,7 @@ public void AnalysisConfig_Serialization_SaveAndReload()
public void AnalysisConfig_Serialization_SaveAndReload_EmptySettings()
{
// Arrange
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var originalConfig = new AnalysisConfig();
var fileName = Path.Combine(testFolder, "empty_config.xml");
@@ -130,7 +130,7 @@ public void AnalysisConfig_Serialization_SaveAndReload_EmptySettings()
public void AnalysisConfig_Serialization_AdditionalConfig()
{
// 0. Setup
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var originalConfig = new AnalysisConfig();
@@ -154,7 +154,7 @@ public void AnalysisConfig_Serialization_AdditionalConfig()
public void AnalysisConfig_SharedReadAllowed()
{
// 0. Setup
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var filePath = Path.Combine(testFolder, "config.txt");
var config = new AnalysisConfig();
@@ -214,7 +214,7 @@ public void AnalysisConfig_ExpectedXmlFormat()
";
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var fullPath = TestUtils.CreateTextFile(testDir, "input.txt", xml);
// Act
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerPluginTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerPluginTests.cs
index fe0e23dc8..f956fc518 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerPluginTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerPluginTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerSettingsTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerSettingsTests.cs
index a5cc3a4e8..d820ede2d 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerSettingsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/AnalyzerSettingsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/RuleSetTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/RuleSetTests.cs
index c5fb96ae8..760207408 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/RuleSetTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisConfig/RuleSetTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertiesTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertiesTests.cs
index b37583c69..a8e34d2ee 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertiesTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertiesTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertyProviderExtensionsTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertyProviderExtensionsTests.cs
index c4d9a8e88..10bd124b1 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertyProviderExtensionsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/AnalysisPropertyProviderExtensionsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/ListPropertiesProviderTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/ListPropertiesProviderTests.cs
index be5a081f6..6c70ea0a9 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/ListPropertiesProviderTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/ListPropertiesProviderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/PropertyTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/PropertyTests.cs
index 69e914a61..232568218 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/PropertyTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/AnalysisProperties/PropertyTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/CmdLineArgsPropertiesProviderTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/CmdLineArgsPropertiesProviderTests.cs
index 15037cb55..977963a64 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/CmdLineArgsPropertiesProviderTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/CmdLineArgsPropertiesProviderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentDescriptorTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentDescriptorTests.cs
index e5041a017..16cc50442 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentDescriptorTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentDescriptorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentInstanceTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentInstanceTests.cs
index f1195ed0c..0300093e9 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentInstanceTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/ArgumentInstanceTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineFlagPrefixTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineFlagPrefixTests.cs
index 0ebd19227..1ff175aab 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineFlagPrefixTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineFlagPrefixTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineParserTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineParserTests.cs
index 4e09f80ea..0db985cb0 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineParserTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/CommandLine/CommandLineParserTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/ConsoleLoggerTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/ConsoleLoggerTests.cs
index b4eb72b9f..5729260ab 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/ConsoleLoggerTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/ConsoleLoggerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/EnvScannerPropertiesProviderTest.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/EnvScannerPropertiesProviderTest.cs
index 76b71375b..6944bee4f 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/EnvScannerPropertiesProviderTest.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/EnvScannerPropertiesProviderTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/FilePropertyProviderTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/FilePropertyProviderTests.cs
index ffa8fdd76..f67ea6a86 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/FilePropertyProviderTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/FilePropertyProviderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -62,7 +62,7 @@ public void FileProvider_NoFileArguments()
// Arrange
IAnalysisPropertyProvider provider;
var logger = new TestLogger();
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Act
provider = CheckProcessingSucceeds(Enumerable.Empty(), defaultPropertiesDir, logger);
@@ -77,7 +77,7 @@ public void FileProvider_NoFileArguments()
public void FileProvider_UseDefaultPropertiesFile()
{
// Arrange
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var validPropertiesFile = CreateValidPropertiesFile(defaultPropertiesDir, FilePropertyProvider.DefaultFileName, "key1", "value1");
var logger = new TestLogger();
@@ -97,10 +97,10 @@ public void FileProvider_UseDefaultPropertiesFile()
public void FileProvider_UseSpecifiedPropertiesFile()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var validPropertiesFile = CreateValidPropertiesFile(testDir, "myPropertiesFile.xml", "xxx", "value with spaces");
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext, "Default");
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Default");
CreateFile(defaultPropertiesDir, FilePropertyProvider.DefaultFileName, "invalid file - will error if this file is loaded");
IList args = new List
@@ -125,7 +125,7 @@ public void FileProvider_MissingPropertiesFile()
{
// Arrange
var logger = new TestLogger();
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
IList args = new List
{
@@ -147,7 +147,7 @@ public void FileProvider_InvalidDefaultPropertiesFile()
{
// Arrange
var logger = new TestLogger();
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var invalidFile = CreateFile(defaultPropertiesDir, FilePropertyProvider.DefaultFileName, "not a valid XML properties file");
IList args = new List();
@@ -166,7 +166,7 @@ public void FileProvider_InvalidSpecifiedPropertiesFile()
{
// Arrange
var logger = new TestLogger();
- var defaultPropertiesDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var defaultPropertiesDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var invalidFile = CreateFile(defaultPropertiesDir, "invalidPropertiesFile.txt", "not a valid XML properties file");
IList args = new List
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputCaptureScope.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputCaptureScope.cs
index e1fa4ac9e..66634aaca 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputCaptureScope.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputCaptureScope.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputRecorder.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputRecorder.cs
index 1f8d57607..babc4880f 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputRecorder.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/Infrastructure/OutputRecorder.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/MsBuildPathSettingsTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/MsBuildPathSettingsTests.cs
index c0079c6ff..fc1b79fe2 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/MsBuildPathSettingsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/MsBuildPathSettingsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/MutexWrapperTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/MutexWrapperTests.cs
index 69cc13db8..d9d40438a 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/MutexWrapperTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/MutexWrapperTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProcessRunnerTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProcessRunnerTests.cs
index 3013da918..53a03591a 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProcessRunnerTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProcessRunnerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -244,7 +244,7 @@ public void ProcRunner_ArgumentQuoting()
// Checks arguments passed to the child process are correctly quoted
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create a dummy exe that will produce a log file showing any input args
var exeName = DummyExeHelper.CreateDummyPostProcessor(testDir, 0);
@@ -289,7 +289,7 @@ public void ProcRunner_ArgumentQuotingForwardedByBatchScript()
// Checks arguments passed to a batch script which itself passes them on are correctly escaped
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create a dummy exe that will produce a log file showing any input args
var exeName = DummyExeHelper.CreateDummyPostProcessor(testDir, 0);
@@ -335,7 +335,7 @@ public void ProcRunner_ArgumentQuotingForwardedByBatchScript()
public void ProcRunner_DoNotLogSensitiveData()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create a dummy exe that will produce a log file showing any input args
var exeName = DummyExeHelper.CreateDummyPostProcessor(testDir, 0);
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfo/ProjectInfoExtensionsTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfo/ProjectInfoExtensionsTests.cs
index 8078a2f45..3fee78c56 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfo/ProjectInfoExtensionsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfo/ProjectInfoExtensionsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfoTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfoTests.cs
index c8e261049..f63cc9948 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfoTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/ProjectInfoTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -62,7 +62,7 @@ public void ProjectInfo_Serialization_InvalidFileName()
public void ProjectInfo_Serialization_SaveAndReload()
{
// 0. Setup
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var projectGuid = Guid.NewGuid();
@@ -86,7 +86,7 @@ public void ProjectInfo_Serialization_SaveAndReload()
public void ProjectInfo_Serialization_AnalysisResults()
{
// 0. Setup
- var testFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var projectGuid = Guid.NewGuid();
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/Properties/AssemblyInfo.cs
index af1439206..bee3d48f2 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/SerializerTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/SerializerTests.cs
index 2edbd9a92..c519ff723 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/SerializerTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/SerializerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -62,7 +62,7 @@ public void Serializer_ArgumentValidation()
public void Serializer_RoundTrip_Succeeds()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var filePath = Path.Combine(testDir, "file1.txt");
var original = new MyDataClass() { Value1 = "val1", Value2 = 22 };
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/SonarScanner.MSBuild.Common.UnitTests.csproj b/Tests/SonarScanner.MSBuild.Common.UnitTests/SonarScanner.MSBuild.Common.UnitTests.csproj
index 3cff5c039..aa1c0fa3b 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/SonarScanner.MSBuild.Common.UnitTests.csproj
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/SonarScanner.MSBuild.Common.UnitTests.csproj
@@ -47,8 +47,11 @@
..\..\packages\FluentAssertions.5.9.0\lib\net47\FluentAssertions.dll
-
- ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+
+
+ ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
@@ -64,11 +67,7 @@
-
-
-
-
-
+
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/StringExtensions_ReplaceCaseInsensitive.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/StringExtensions_ReplaceCaseInsensitive.cs
index 7778b99d9..679c02250 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/StringExtensions_ReplaceCaseInsensitive.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/StringExtensions_ReplaceCaseInsensitive.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/UtilitiesTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/UtilitiesTests.cs
index 9ee65da05..b93b84e76 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/UtilitiesTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/UtilitiesTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -137,7 +137,7 @@ public void EnsureDirectoryExists_WhenDirectoryIsWhitespaces_ThrowsArgumentNullE
public void EnsureDirectoryExists_WhenDirectoryMissing_IsCreated()
{
// Arrange
- var baseDir =TestUtils.CreateTestSpecificFolder(TestContext);
+ var baseDir =TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var newDir = Path.Combine(baseDir, "newDir");
var logger = new TestLogger();
@@ -154,7 +154,7 @@ public void EnsureDirectoryExists_WhenDirectoryMissing_IsCreated()
public void EnsureDirectoryExists_WhenDirectoryExists_IsNoOp()
{
// Arrange
- var baseDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var baseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Act
@@ -202,7 +202,7 @@ public void EnsureEmptyDirectory_WhenLoggerIsInvalid_ThrowsArgumentNullException
public void EnsureEmptyDirectory_WhenDirectoryMissing_IsCreated()
{
// Arrange
- var baseDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var baseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var newDir = Path.Combine(baseDir, "newDir");
var logger = new TestLogger();
@@ -219,7 +219,7 @@ public void EnsureEmptyDirectory_WhenDirectoryMissing_IsCreated()
public void EnsureEmptyDirectory_WhenDirectoryExistsAndHasFiles_FilesAreDeleted()
{
// Arrange
- var baseDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var baseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
File.WriteAllText(Path.Combine(baseDir, "file1.txt"), "xxx");
File.WriteAllText(Path.Combine(baseDir, "file2.txt"), "xxx");
Directory.CreateDirectory(Path.Combine(baseDir, "subdir1"));
@@ -250,16 +250,16 @@ public void TryEnsureEmptyDirectories_WhenDirectoriesExistsAndHaveFiles_FilesAre
{
// Arrange
// Directory with file
- var baseDir1 = TestUtils.CreateTestSpecificFolder(TestContext, "baseDir1");
+ var baseDir1 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "baseDir1");
File.WriteAllText(Path.Combine(baseDir1, "file1.txt"), "xxx");
// Directory with file and sub-directory
- var baseDir2 = TestUtils.CreateTestSpecificFolder(TestContext, "baseDir2");
+ var baseDir2 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "baseDir2");
File.WriteAllText(Path.Combine(baseDir2, "file2.txt"), "xxx");
Directory.CreateDirectory(Path.Combine(baseDir2, "subdir1"));
// Empty directory
- var baseDir3 = TestUtils.CreateTestSpecificFolder(TestContext, "baseDir3");
+ var baseDir3 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "baseDir3");
var logger = new TestLogger();
@@ -287,12 +287,12 @@ public void TryEnsureEmptyDirectories_WhenIOException_ReturnsFalse()
{
// Arrange
// Directory with file
- var baseDir1 = TestUtils.CreateTestSpecificFolder(TestContext, "baseDir1");
+ var baseDir1 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "baseDir1");
var filePath = Path.Combine(baseDir1, "file1.txt");
File.WriteAllText(filePath, "xxx");
// Directory with file
- var baseDir2 = TestUtils.CreateTestSpecificFolder(TestContext, "baseDir2");
+ var baseDir2 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "baseDir2");
File.WriteAllText(Path.Combine(baseDir2, "file2.txt"), "xxx");
var logger = new TestLogger();
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/VerbosityCalculatorTests.cs b/Tests/SonarScanner.MSBuild.Common.UnitTests/VerbosityCalculatorTests.cs
index d6d1be5d1..e41cbdd84 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/VerbosityCalculatorTests.cs
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/VerbosityCalculatorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Common.UnitTests/packages.config b/Tests/SonarScanner.MSBuild.Common.UnitTests/packages.config
index 55c41ffe4..41056fdfc 100644
--- a/Tests/SonarScanner.MSBuild.Common.UnitTests/packages.config
+++ b/Tests/SonarScanner.MSBuild.Common.UnitTests/packages.config
@@ -1,7 +1,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/ArgumentProcessorTests.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/ArgumentProcessorTests.cs
index f09ed66f9..d13d2dad6 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/ArgumentProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/ArgumentProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSonarScanner.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSonarScanner.cs
index 268e1301e..f977f57cd 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSonarScanner.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSonarScanner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@
using System.Collections.Generic;
using FluentAssertions;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.Shim;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.PostProcessor.Tests
{
@@ -35,7 +35,7 @@ internal class MockSonarScanner : ISonarScanner
public string ErrorToLog { get; set; }
- public ProjectInfoAnalysisResult ValueToReturn { get; set; }
+ public bool ValueToReturn { get; set; }
public IEnumerable SuppliedCommandLineArgs { get; set; }
@@ -48,7 +48,7 @@ public MockSonarScanner(ILogger logger)
#region ISonarScanner interface
- public ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable userCmdLineArguments)
+ public bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, string fullPropertiesFilePath)
{
methodCalled.Should().BeFalse("Scanner should only be called once");
methodCalled = true;
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTFSProcessor.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTFSProcessor.cs
new file mode 100644
index 000000000..7b531c04c
--- /dev/null
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTFSProcessor.cs
@@ -0,0 +1,79 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using System.Collections.Generic;
+using FluentAssertions;
+using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Shim.Interfaces;
+
+namespace SonarScanner.MSBuild.PostProcessor.Tests
+{
+ internal class MockTfsProcessor : ITfsProcessor
+ {
+ private bool methodCalled;
+ private readonly ILogger logger;
+
+ #region Test Helpers
+
+ public string ErrorToLog { get; set; }
+
+ public bool ValueToReturn { get; set; }
+
+ public IEnumerable SuppliedCommandLineArgs { get; set; }
+
+ #endregion Test Helpers
+
+ public MockTfsProcessor(ILogger logger)
+ {
+ this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ }
+
+ #region ITfsProcessor interface
+
+ public bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, string fullPropertiesFilePath)
+ {
+ methodCalled = true;
+ SuppliedCommandLineArgs = userCmdLineArguments;
+ if (ErrorToLog != null)
+ {
+ logger.LogError(ErrorToLog);
+ }
+
+ return ValueToReturn;
+ }
+
+ #endregion ISonarScanner interface
+
+ #region Checks
+
+ public void AssertExecuted()
+ {
+ methodCalled.Should().BeTrue("Expecting the TFS processor to have been called");
+ }
+
+ public void AssertNotExecuted()
+ {
+ methodCalled.Should().BeFalse("Not expecting the TFS processor to have been called");
+ }
+
+ #endregion Checks
+ }
+}
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTeamBuildSettings.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTeamBuildSettings.cs
index 9fba4b6bc..30776eaad 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTeamBuildSettings.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockTeamBuildSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,8 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
namespace SonarScanner.MSBuild.PostProcessor.Tests
{
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/MSBuildPostProcessorTests.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/MSBuildPostProcessorTests.cs
index 789168959..244b71249 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/MSBuildPostProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/MSBuildPostProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -24,10 +24,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
-using SonarScanner.MSBuild.Shim;
using TestUtilities;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Shim;
+using SonarScanner.MSBuild.Shim.Interfaces;
+using System.IO;
+using System.Linq;
namespace SonarScanner.MSBuild.PostProcessor.Tests
{
@@ -40,84 +42,27 @@ public class MSBuildPostProcessorTests
#region Tests
- [TestMethod]
- public void PostProc_ExecutionFailsIfCodeCoverageFails()
- {
- // Arrange
- var context = new PostProcTestContext(TestContext);
- context.CodeCoverage.InitialiseValueToReturn = true;
- context.CodeCoverage.ProcessValueToReturn = false;
-
- // Act
- var success = Execute(context);
-
- // Assert
- success.Should().BeFalse("Not expecting post-processor to have succeeded");
-
- context.CodeCoverage.AssertInitializedCalled();
- context.CodeCoverage.AssertExecuteCalled();
- context.Scanner.AssertNotExecuted();
- context.ReportBuilder.AssertNotExecuted();
-
- context.Logger.AssertErrorsLogged(0);
- context.Logger.AssertWarningsLogged(0);
-
- // Verify that the method was called at least once
- context.TargetsUninstaller.Verify(m => m.UninstallTargets());
- }
[TestMethod]
- public void PostProc_ExecutionFailsIfSonarScannerFails()
+ public void PostProc_NoProjectsToAnalyze_NoExecutionTriggered()
{
// Arrange
var context = new PostProcTestContext(TestContext);
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = false
- };
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarConfigDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
+ context.Scanner.ValueToReturn = true;
+ context.TfsProcessor.ValueToReturn = true;
// Act
- var success = Execute(context);
+ var success = Execute_WithNoProject(context, true);
// Assert
- success.Should().BeFalse("Not expecting post-processor to have succeeded");
-
- context.CodeCoverage.AssertExecuteCalled();
- context.Scanner.AssertExecuted();
- context.ReportBuilder.AssertExecuted(); // should be called even if the sonar-scanner fails
-
- context.Logger.AssertErrorsLogged(0);
- context.Logger.AssertWarningsLogged(0);
-
- // Verify that the method was called at least once
- context.TargetsUninstaller.Verify(m => m.UninstallTargets());
- }
-
- [TestMethod]
- public void PostProc_ExecutionSucceeds()
- {
- // Arrange
- var context = new PostProcTestContext(TestContext);
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
-
- // Act
- var success = Execute(context);
-
- // Assert
- success.Should().BeTrue("Expecting post-processor to have succeeded");
-
- context.CodeCoverage.AssertInitializedCalled();
- context.CodeCoverage.AssertExecuteCalled();
- context.Scanner.AssertExecuted();
-
- context.ReportBuilder.AssertExecuted(); // should be called even if the sonar-scanner fails
+ success.Should().BeFalse("Expecting post-processor to have failed");
- context.Scanner.SuppliedCommandLineArgs.Should().Equal(
- new string[] { "-Dsonar.scanAllFiles=true" },
- "Unexpected command line args passed to the sonar-scanner");
+ context.TfsProcessor.AssertNotExecuted();
+ context.Scanner.AssertNotExecuted();
context.Logger.AssertErrorsLogged(0);
context.Logger.AssertWarningsLogged(0);
@@ -131,24 +76,23 @@ public void PostProc_ExecutionSucceedsWithErrorLogs()
{
// Arrange
var context = new PostProcTestContext(TestContext);
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarConfigDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
+ context.Scanner.ValueToReturn = true;
+ context.TfsProcessor.ValueToReturn = true;
context.Scanner.ErrorToLog = "Errors";
// Act
- var success = Execute(context);
+ var success = Execute(context, true);
// Assert
success.Should().BeTrue("Expecting post-processor to have succeeded");
- context.CodeCoverage.AssertInitializedCalled();
- context.CodeCoverage.AssertExecuteCalled();
+ context.TfsProcessor.AssertExecuted();
context.Scanner.AssertExecuted();
- context.ReportBuilder.AssertExecuted(); // should be called even if the sonar-scanner fails
-
context.Scanner.SuppliedCommandLineArgs.Should().Equal(
new string[] { "-Dsonar.scanAllFiles=true" },
"Unexpected command line args passed to the sonar-scanner");
@@ -160,56 +104,23 @@ public void PostProc_ExecutionSucceedsWithErrorLogs()
context.TargetsUninstaller.Verify(m => m.UninstallTargets());
}
- [TestMethod]
- [Description("The coverage processing has 2 paths for fail - initialization failures which are non-critical and processing errors that stop the post-processor workflow")]
- public void PostProc_ExecutionSucceedsIfCoverageNotInitialised()
- {
- // Arrange
- var context = new PostProcTestContext(TestContext);
- context.CodeCoverage.InitialiseValueToReturn = false;
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
-
- // Act
- var success = Execute(context);
-
- // Assert
- success.Should().BeTrue("Expecting post-processor to have succeeded");
-
- context.CodeCoverage.AssertInitializedCalled();
- context.CodeCoverage.AssertExecuteNotCalled();
- context.Scanner.AssertExecuted();
- context.ReportBuilder.AssertExecuted(); // should be called even if the sonar-scanner fails
-
- context.Scanner.SuppliedCommandLineArgs.Should().Equal(
- new string[] { "-Dsonar.scanAllFiles=true" },
- "Unexpected command line args passed to the sonar-scanner");
-
- context.Logger.AssertErrorsLogged(0);
- context.Logger.AssertWarningsLogged(0);
-
- // Verify that the method was called at least once
- context.TargetsUninstaller.Verify(m => m.UninstallTargets());
- }
-
[TestMethod]
public void PostProc_FailsOnInvalidArgs()
{
// Arrange
var context = new PostProcTestContext(TestContext);
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.TfsProcessor.ValueToReturn = false;
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
// Act
- var success = Execute(context, "/d:sonar.foo=bar");
+ var success = Execute(context, true, "/d:sonar.foo=bar");
// Assert
success.Should().BeFalse("Expecting post-processor to have failed");
- context.CodeCoverage.AssertInitialisedNotCalled();
- context.CodeCoverage.AssertExecuteNotCalled();
+ context.TfsProcessor.AssertNotExecuted();
context.Scanner.AssertNotExecuted();
- context.ReportBuilder.AssertNotExecuted();
context.Logger.AssertErrorsLogged(1);
context.Logger.AssertWarningsLogged(0);
@@ -224,10 +135,12 @@ public void PostProc_ValidArgsPassedThrough()
// Arrange
var context = new PostProcTestContext(TestContext);
context.Config.HasBeginStepCommandLineCredentials = true;
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarConfigDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
+ context.Scanner.ValueToReturn = true;
+ context.TfsProcessor.ValueToReturn = true;
var suppliedArgs = new string[]
{
@@ -247,15 +160,13 @@ public void PostProc_ValidArgsPassedThrough()
};
// Act
- var success = Execute(context, suppliedArgs);
+ var success = Execute(context, true, suppliedArgs);
// Assert
success.Should().BeTrue("Expecting post-processor to have succeeded");
- context.CodeCoverage.AssertExecuteCalled();
- context.CodeCoverage.AssertInitializedCalled();
+ context.TfsProcessor.AssertExecuted();
context.Scanner.AssertExecuted();
- context.ReportBuilder.AssertExecuted();
context.Scanner.SuppliedCommandLineArgs.Should().Equal(
@@ -275,18 +186,19 @@ public void PostProc_WhenSettingInFileButNoCommandLineArg_Fail()
// Arrange
var context = new PostProcTestContext(TestContext);
context.Config.HasBeginStepCommandLineCredentials = true;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.TfsProcessor.ValueToReturn = false;
// Act
- var success = Execute(context, args: new string[0]);
+ var success = Execute(context, true, args: new string[0]);
// Assert
success.Should().BeFalse();
context.Logger.AssertErrorLogged(CredentialsErrorMessage);
- context.CodeCoverage.AssertInitialisedNotCalled();
- context.CodeCoverage.AssertExecuteNotCalled();
+ context.TfsProcessor.AssertNotExecuted();
context.Scanner.AssertNotExecuted();
- context.ReportBuilder.AssertNotExecuted();
context.TargetsUninstaller.Verify(m => m.UninstallTargets());
}
@@ -296,23 +208,22 @@ public void PostProc_WhenNoSettingInFileAndCommandLineArg_Fail()
{
// Arrange
var context = new PostProcTestContext(TestContext);
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
context.Config.AdditionalConfig = new List();
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
+ context.Scanner.ValueToReturn = true;
+ context.TfsProcessor.ValueToReturn = false;
// Act
- var success = Execute(context, args: "/d:sonar.login=foo");
+ var success = Execute(context, true, args: "/d:sonar.login=foo");
// Assert
success.Should().BeFalse();
context.Logger.AssertErrorLogged(CredentialsErrorMessage);
- context.CodeCoverage.AssertInitialisedNotCalled();
- context.CodeCoverage.AssertExecuteNotCalled();
+ context.TfsProcessor.AssertNotExecuted();
context.Scanner.AssertNotExecuted();
- context.ReportBuilder.AssertNotExecuted();
context.TargetsUninstaller.Verify(m => m.UninstallTargets());
}
@@ -322,14 +233,15 @@ public void PostProc_WhenNoSettingInFileAndNoCommandLineArg_DoesNotFail()
{
// Arrange
var context = new PostProcTestContext(TestContext);
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarConfigDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
context.Config.AdditionalConfig = new List();
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
+ context.Scanner.ValueToReturn = true;
// Act
- var success = Execute(context, args: new string[0]);
+ var success = Execute(context, true, args: new string[0]);
// Assert
success.Should().BeTrue();
@@ -342,13 +254,14 @@ public void PostProc_WhenSettingInFileAndCommandLineArg_DoesNotFail()
// Arrange
var context = new PostProcTestContext(TestContext);
context.Config.HasBeginStepCommandLineCredentials = true;
- context.Scanner.ValueToReturn = new ProjectInfoAnalysisResult
- {
- RanToCompletion = true
- };
+ context.Config.SonarConfigDir = Environment.CurrentDirectory;
+ context.Config.SonarQubeHostUrl = "http://sonarqube.com";
+ context.Config.SonarOutputDir = Environment.CurrentDirectory;
+ context.Config.SonarScannerWorkingDirectory = Environment.CurrentDirectory;
+ context.Scanner.ValueToReturn = true;
// Act
- var success = Execute(context, args: "/d:sonar.login=foo");
+ var success = Execute(context, true, args: "/d:sonar.login=foo");
// Assert
success.Should().BeTrue();
@@ -388,12 +301,10 @@ private class PostProcTestContext
public PostProcTestContext(TestContext testContext)
{
Config = new AnalysisConfig();
- Settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(TestUtils.CreateTestSpecificFolder(testContext));
-
+ Settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(TestUtils.CreateTestSpecificFolderWithSubPaths(testContext));
Logger = new TestLogger();
- CodeCoverage = new MockCodeCoverageProcessor();
+ TfsProcessor = new MockTfsProcessor(Logger);
Scanner = new MockSonarScanner(Logger);
- ReportBuilder = new MockSummaryReportBuilder();
TargetsUninstaller = new Mock();
var callCount = 0;
TargetsUninstaller
@@ -405,23 +316,82 @@ public PostProcTestContext(TestContext testContext)
callCount++;
});
- CodeCoverage.InitialiseValueToReturn = true;
- CodeCoverage.ProcessValueToReturn = true;
}
public AnalysisConfig Config { get; set; }
public TeamBuildSettings Settings { get; }
- public MockCodeCoverageProcessor CodeCoverage { get; }
public MockSonarScanner Scanner { get; }
- public MockSummaryReportBuilder ReportBuilder { get; }
public TestLogger Logger { get; }
+
+ public MockTfsProcessor TfsProcessor { get; }
}
#region Private methods
- private static bool Execute(PostProcTestContext context, params string[] args)
+ private bool Execute_WithNoProject(PostProcTestContext context, bool propertyWriteSucceeded, params string[] args)
+ {
+ var sonarProjectPropertiesValidator = new Mock();
+
+ IEnumerable expectedValue;
+
+ sonarProjectPropertiesValidator
+ .Setup(propValidator => propValidator.AreExistingSonarPropertiesFilesPresent(It.IsAny(), It.IsAny>(), out expectedValue)).Returns(false);
+
+ var proc = new MSBuildPostProcessor(context.Scanner, context.Logger, context.TargetsUninstaller.Object, context.TfsProcessor, sonarProjectPropertiesValidator.Object);
+
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+
+ var projectInfo = TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir);
+
+ List listOfProjects = new List();
+ listOfProjects.Add(new ProjectData(ProjectInfo.Load(projectInfo)));
+
+ IEnumerable expectedListOfProjects = Enumerable.Empty();
+
+ var propertiesFileGenerator = Mock.Of();
+ Mock.Get(propertiesFileGenerator).Setup(m => m.TryWriteProperties(It.IsAny(), out expectedListOfProjects)).Returns(propertyWriteSucceeded);
+
+ var projectInfoAnalysisResult = new ProjectInfoAnalysisResult();
+ projectInfoAnalysisResult.Projects.AddRange(listOfProjects);
+ projectInfoAnalysisResult.RanToCompletion = true;
+ projectInfoAnalysisResult.FullPropertiesFilePath = null;
+
+ Mock.Get(propertiesFileGenerator).Setup(m => m.GenerateFile()).Returns(projectInfoAnalysisResult);
+ proc.SetPropertiesFileGenerator(propertiesFileGenerator);
+ var success = proc.Execute(args, context.Config, context.Settings);
+ return success;
+ }
+
+ private bool Execute(PostProcTestContext context, bool propertyWriteSucceeded, params string[] args)
{
- var proc = new MSBuildPostProcessor(context.CodeCoverage, context.Scanner, context.ReportBuilder, context.Logger, context.TargetsUninstaller.Object);
+ var sonarProjectPropertiesValidator = new Mock();
+
+ IEnumerable expectedValue;
+
+ sonarProjectPropertiesValidator
+ .Setup(propValidator => propValidator.AreExistingSonarPropertiesFilesPresent(It.IsAny(), It.IsAny>(), out expectedValue)).Returns(false);
+
+ var proc = new MSBuildPostProcessor(context.Scanner, context.Logger, context.TargetsUninstaller.Object, context.TfsProcessor, sonarProjectPropertiesValidator.Object);
+
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+
+ var projectInfo = TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir);
+
+ List listOfProjects = new List();
+ listOfProjects.Add(new ProjectData(ProjectInfo.Load(projectInfo)));
+
+ IEnumerable expectedListOfProjects = listOfProjects;
+
+ var propertiesFileGenerator = Mock.Of();
+ Mock.Get(propertiesFileGenerator).Setup(m => m.TryWriteProperties(It.IsAny(), out expectedListOfProjects)).Returns(propertyWriteSucceeded);
+
+ var projectInfoAnalysisResult = new ProjectInfoAnalysisResult();
+ projectInfoAnalysisResult.Projects.AddRange(listOfProjects);
+ projectInfoAnalysisResult.RanToCompletion = true;
+ projectInfoAnalysisResult.FullPropertiesFilePath = Path.Combine(testDir, "sonar-project.properties");
+
+ Mock.Get(propertiesFileGenerator).Setup(m => m.GenerateFile()).Returns(projectInfoAnalysisResult);
+ proc.SetPropertiesFileGenerator(propertiesFileGenerator);
var success = proc.Execute(args, context.Config, context.Settings);
return success;
}
@@ -429,7 +399,9 @@ private static bool Execute(PostProcTestContext context, params string[] args)
private void DummyPostProcessorExecute(string[] args, AnalysisConfig config, ITeamBuildSettings settings)
{
var context = new PostProcTestContext(TestContext);
- var proc = new MSBuildPostProcessor(context.CodeCoverage, context.Scanner, context.ReportBuilder, context.Logger, context.TargetsUninstaller.Object);
+ var sonarProjectPropertiesValidator = new Mock();
+
+ var proc = new MSBuildPostProcessor(context.Scanner, context.Logger, context.TargetsUninstaller.Object, context.TfsProcessor, sonarProjectPropertiesValidator.Object);
proc.Execute(args, config, settings);
}
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Properties/AssemblyInfo.cs
index 94ca38415..44a69df8a 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SonarScanner.MSBuild.PostProcessor.Tests.csproj b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SonarScanner.MSBuild.PostProcessor.Tests.csproj
index 34e546246..2e961c53c 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SonarScanner.MSBuild.PostProcessor.Tests.csproj
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SonarScanner.MSBuild.PostProcessor.Tests.csproj
@@ -44,13 +44,19 @@
..\..\packages\FluentAssertions.5.9.0\lib\net47\FluentAssertions.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+ ..\..\packages\Moq.4.10.0\lib\net45\Moq.dll
-
- ..\..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
+
+ ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -64,26 +70,18 @@
-
-
-
-
-
+
Properties\AssemblyInfo.Shared.cs
-
-
+
-
-
-
@@ -91,14 +89,6 @@
{e312fdbb-bc13-4559-8f21-76ca5b88ebc5}SonarScanner.MSBuild.Common
-
- {C3466723-5499-4FAD-B236-5C96094DE276}
- SonarScanner.MSBuild.TFS.Classic
-
-
- {66ce9491-1c14-45d2-beb6-a0695c63ebb2}
- SonarScanner.MSBuild.TFS
- {80f02fad-fe7e-41b6-9151-bb650fdd6103}SonarScanner.MSBuild.PostProcessor
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/TargetsUninstallerTests.cs b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/TargetsUninstallerTests.cs
index ac9543e1f..fec110988 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/TargetsUninstallerTests.cs
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/TargetsUninstallerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/app.config b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/app.config
index 557095a4b..9d688d54a 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/app.config
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/app.config
@@ -1,11 +1,19 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/packages.config b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/packages.config
index 34b3b6358..d88aa0f95 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/packages.config
+++ b/Tests/SonarScanner.MSBuild.PostProcessor.Tests/packages.config
@@ -4,6 +4,7 @@
-
+
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/AnalysisConfigGeneratorTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/AnalysisConfigGeneratorTests.cs
index 6e92c9955..2d614446a 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/AnalysisConfigGeneratorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/AnalysisConfigGeneratorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -25,7 +25,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.Tests
@@ -41,7 +40,7 @@ public class AnalysisConfigGeneratorTests
public void GenerateFile_WhenLocalSettingsNull_ThrowArgumentNullException()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var tbSettings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Action act = () => AnalysisConfigGenerator.GenerateFile(null, tbSettings, new Dictionary(),
new List(), new MockSonarQubeServer(), new TestLogger());
@@ -54,8 +53,11 @@ public void GenerateFile_WhenLocalSettingsNull_ThrowArgumentNullException()
public void GenerateFile_WhenBuildSettingsNull_ThrowArgumentNullException()
{
// Arrange
+
+ var testLogger = new TestLogger();
+
Action act = () => AnalysisConfigGenerator.GenerateFile(new ProcessedArgs("key", "name", "version", "org", false,
- EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance), null,
+ EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, testLogger), null,
new Dictionary(), new List(), new MockSonarQubeServer(), new TestLogger());
// Act & Assert
@@ -66,10 +68,11 @@ public void GenerateFile_WhenBuildSettingsNull_ThrowArgumentNullException()
public void GenerateFile_WhenServerPropertiesNull_ThrowArgumentNullException()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testLogger = new TestLogger();
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var tbSettings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Action act = () => AnalysisConfigGenerator.GenerateFile(new ProcessedArgs("key", "name", "version", "org", false,
- EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance), tbSettings,
+ EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, testLogger), tbSettings,
null, new List(), new MockSonarQubeServer(), new TestLogger());
// Act & Assert
@@ -80,10 +83,11 @@ public void GenerateFile_WhenServerPropertiesNull_ThrowArgumentNullException()
public void GenerateFile_WhenSonarQubeServerNull_ThrowArgumentNullException()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testLogger = new TestLogger();
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var tbSettings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Action act = () => AnalysisConfigGenerator.GenerateFile(new ProcessedArgs("key", "name", "version", "org", false,
- EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance), tbSettings,
+ EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, testLogger), tbSettings,
new Dictionary(), new List(), null, new TestLogger());
// Act & Assert
@@ -94,10 +98,11 @@ public void GenerateFile_WhenSonarQubeServerNull_ThrowArgumentNullException()
public void GenerateFile_WhenLoggerNull_ThrowArgumentNullException()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testLogger = new TestLogger();
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var tbSettings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Action act = () => AnalysisConfigGenerator.GenerateFile(new ProcessedArgs("key", "name", "version", "org", false,
- EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance), tbSettings,
+ EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, testLogger), tbSettings,
new Dictionary(), new List(), new MockSonarQubeServer(), null);
// Act & Assert
@@ -108,13 +113,13 @@ public void GenerateFile_WhenLoggerNull_ThrowArgumentNullException()
public void AnalysisConfGen_Simple()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var propertyProvider = new ListPropertiesProvider();
propertyProvider.AddProperty(SonarProperties.HostUrl, "http://foo");
- var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, propertyProvider, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, propertyProvider, EmptyPropertyProvider.Instance, logger);
var tbSettings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
@@ -178,7 +183,7 @@ public void AnalysisConfGen_FileProperties()
// Instead, a pointer to the file should be created.
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
@@ -193,7 +198,7 @@ public void AnalysisConfGen_FileProperties()
var fileProvider = FilePropertyProvider.Load(settingsFilePath);
- var args = new ProcessedArgs("key", "name", "version", "organization", false, EmptyPropertyProvider.Instance, fileProvider, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("key", "name", "version", "organization", false, EmptyPropertyProvider.Instance, fileProvider, EmptyPropertyProvider.Instance, logger);
var settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Directory.CreateDirectory(settings.SonarConfigDirectory); // config directory needs to exist
@@ -222,7 +227,7 @@ public void AnalysisConfGen_FileProperties()
public void AnalysisConfGen_AnalysisConfigDoesNotContainSensitiveData()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
@@ -248,7 +253,7 @@ public void AnalysisConfGen_AnalysisConfigDoesNotContainSensitiveData()
fileSettings.Save(fileSettingsPath);
var fileProvider = FilePropertyProvider.Load(fileSettingsPath);
- var args = new ProcessedArgs("key", "name", "1.0", null, false, cmdLineArgs, fileProvider, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("key", "name", "1.0", null, false, cmdLineArgs, fileProvider, EmptyPropertyProvider.Instance, logger);
IDictionary serverProperties = new Dictionary
{
@@ -293,7 +298,7 @@ public void AnalysisConfGen_AnalysisConfigDoesNotContainSensitiveData()
public void AnalysisConfGen_WhenLoginSpecified_StoresThatItWasSpecified()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
@@ -302,7 +307,7 @@ public void AnalysisConfGen_WhenLoginSpecified_StoresThatItWasSpecified()
var cmdLineArgs = new ListPropertiesProvider();
cmdLineArgs.AddProperty(SonarProperties.SonarUserName, "foo");
- var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, cmdLineArgs, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, cmdLineArgs, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, logger);
// Act
var config = AnalysisConfigGenerator.GenerateFile(args, settings, new Dictionary(), new List(), new MockSonarQubeServer(), logger);
@@ -316,14 +321,14 @@ public void AnalysisConfGen_WhenLoginSpecified_StoresThatItWasSpecified()
public void AnalysisConfGen_WhenLoginNotSpecified_DoesNotStoreThatItWasSpecified()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
Directory.CreateDirectory(settings.SonarConfigDirectory); // config directory needs to exist
- var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, logger);
// Act
var config = AnalysisConfigGenerator.GenerateFile(args, settings, new Dictionary(), new List(), new MockSonarQubeServer(), logger);
@@ -337,10 +342,11 @@ public void AnalysisConfGen_WhenLoginNotSpecified_DoesNotStoreThatItWasSpecified
public void GenerateFile_WritesSonarQubeVersion()
{
// Arrange
- var analysisDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testLogger = new TestLogger();
+ var analysisDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(analysisDir);
- var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance);
+ var args = new ProcessedArgs("valid.key", "valid.name", "1.0", null, false, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, EmptyPropertyProvider.Instance, testLogger);
var sonarqubeServer = new MockSonarQubeServer();
sonarqubeServer.Data.SonarQubeVersion = new Version(1, 2, 3, 4);
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ArgumentProcessorTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ArgumentProcessorTests.cs
index 24452f3fd..fb123f7f3 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ArgumentProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ArgumentProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -194,7 +194,7 @@ public void ArgProc_InstallTargets()
public void PreArgProc_PropertiesFileSpecifiedOnCommandLine()
{
// 0. Setup
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var propertiesFilePath = Path.Combine(testDir, "mysettings.txt");
// 1. File exists -> args ok
@@ -216,6 +216,25 @@ public void PreArgProc_PropertiesFileSpecifiedOnCommandLine()
logger.AssertErrorsLogged(1);
}
+ [TestMethod]
+ public void PreArgProc_With_PropertiesFileSpecifiedOnCommandLine_Organization_Set_Only_In_It_Should_Fail()
+ {
+ // 0. Setup
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+ var propertiesFilePath = Path.Combine(testDir, "mysettings.txt");
+
+ // 1. File exists -> args ok
+ var properties = new AnalysisProperties
+ {
+ new Property() { Id = SonarProperties.Organization, Value = "myorg1" },
+ new Property() { Id = SonarProperties.HostUrl, Value = "url" } // required property
+ };
+ properties.Save(propertiesFilePath);
+
+ var logger = CheckProcessingFails("/k:key", "/n:name", "/v:version", "/s:" + propertiesFilePath);
+ logger.AssertErrorsLogged(1);
+ }
+
[TestMethod]
public void PreArgProc_Aliases()
{
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/QualityProfile.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/QualityProfile.cs
index 61f6e0f8d..c6a50712e 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/QualityProfile.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/QualityProfile.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/ServerDataModel.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/ServerDataModel.cs
index ec7c8b9a7..c0007ca08 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/ServerDataModel.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/DataModel/ServerDataModel.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/EmbeddedAnalyzerInstallerTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/EmbeddedAnalyzerInstallerTests.cs
index 09f37e5df..bbd1975d4 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/EmbeddedAnalyzerInstallerTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/EmbeddedAnalyzerInstallerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -43,7 +43,7 @@ public class EmbeddedAnalyzerInstallerTests
public void EmbeddedInstall_SinglePlugin_SingleResource_Succeeds()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var requestedPlugin = new Plugin("plugin1", "1.0", "embeddedFile1.zip");
@@ -68,7 +68,7 @@ public void EmbeddedInstall_SinglePlugin_SingleResource_Succeeds()
public void EmbeddedInstall_MultiplePlugins_Succeeds()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var request1 = new Plugin("no.matching.resource.plugin", "2.0", "non.existent.resource.zip");
@@ -103,7 +103,7 @@ public void EmbeddedInstall_MultiplePlugins_Succeeds()
public void EmbeddedInstall_MissingResource_SucceedsWithWarningAndNoFiles()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var mockServer = CreateServerWithDummyPlugin("plugin1");
@@ -127,7 +127,7 @@ public void EmbeddedInstall_MissingResource_SucceedsWithWarningAndNoFiles()
public void EmbeddedInstall_NoPluginsSpecified_SucceedsButNoFiles()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var mockServer = CreateServerWithDummyPlugin("plugin1");
@@ -147,7 +147,7 @@ public void EmbeddedInstall_NoPluginsSpecified_SucceedsButNoFiles()
public void EmbeddedInstall_PluginWithNoFiles_Succeeds()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var request1 = new Plugin("plugin1", "1.0", "p1.resource1.zip");
@@ -186,7 +186,7 @@ public void EmbeddedInstall_PluginWithNoFiles_Succeeds()
public void EmbeddedInstall_CachingScenarios()
{
// Arrange
- var localCacheDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var localCacheDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
var requestA = new Plugin("p111", "1.0-SNAPSHOT", "p1.zip");
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockAnalyzerInstaller.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockAnalyzerInstaller.cs
index 78d85e176..b3f7ed928 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockAnalyzerInstaller.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockAnalyzerInstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockObjectFactory.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockObjectFactory.cs
index ca888ce87..ae62a1cad 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockObjectFactory.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockObjectFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockRoslynAnalyzerProvider.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockRoslynAnalyzerProvider.cs
index a7fc8f7e3..b9a06632a 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockRoslynAnalyzerProvider.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockRoslynAnalyzerProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
using FluentAssertions;
using SonarScanner.MSBuild.Common;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
-using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild.PreProcessor.Tests
{
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockSonarQubeServer.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockSonarQubeServer.cs
index 5fb85d1d3..3ecfb13ab 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockSonarQubeServer.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/MockSonarQubeServer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
using FluentAssertions;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
@@ -52,7 +53,13 @@ public void AssertMethodCalled(string methodName, int callCount)
#region ISonarQubeServer methods
- IList ISonarQubeServer.GetActiveRules(string qprofile)
+ Task ISonarQubeServer.IsServerLicenseValid()
+ {
+ LogMethodCalled();
+ return Task.FromResult(true);
+ }
+
+ Task> ISonarQubeServer.GetActiveRules(string qprofile)
{
LogMethodCalled();
@@ -61,40 +68,40 @@ IList ISonarQubeServer.GetActiveRules(string qprofile)
var profile = Data.QualityProfiles.FirstOrDefault(qp => string.Equals(qp.Id, qprofile));
if (profile == null)
{
- return null;
+ return Task.FromResult>(null);
}
- return profile.ActiveRules;
+ return Task.FromResult(profile.ActiveRules);
}
- IList ISonarQubeServer.GetInactiveRules(string qprofile, string language)
+ Task> ISonarQubeServer.GetInactiveRules(string qprofile, string language)
{
LogMethodCalled();
qprofile.Should().NotBeNullOrEmpty("Quality profile is required");
var profile = Data.QualityProfiles.FirstOrDefault(qp => string.Equals(qp.Id, qprofile));
if (profile == null)
{
- return null;
+ return Task.FromResult>(null);
}
- return profile.InactiveRules;
+ return Task.FromResult(profile.InactiveRules);
}
- IEnumerable ISonarQubeServer.GetAllLanguages()
+ Task> ISonarQubeServer.GetAllLanguages()
{
LogMethodCalled();
- return Data.Languages;
+ return Task.FromResult(Data.Languages.AsEnumerable());
}
- IDictionary ISonarQubeServer.GetProperties(string projectKey, string projectBranch)
+ Task> ISonarQubeServer.GetProperties(string projectKey, string projectBranch)
{
LogMethodCalled();
projectKey.Should().NotBeNullOrEmpty("Project key is required");
- return Data.ServerProperties;
+ return Task.FromResult(Data.ServerProperties);
}
- bool ISonarQubeServer.TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language, out string qualityProfileKey)
+ Task> ISonarQubeServer.TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language)
{
LogMethodCalled();
@@ -110,11 +117,11 @@ bool ISonarQubeServer.TryGetQualityProfile(string projectKey, string projectBran
var profile = Data.QualityProfiles
.FirstOrDefault(qp => string.Equals(qp.Language, language) && qp.Projects.Contains(projectId) && string.Equals(qp.Organization, organization));
- qualityProfileKey = profile?.Id;
- return profile != null;
+ var qualityProfileKey = profile?.Id;
+ return Task.FromResult(new Tuple(profile != null, qualityProfileKey));
}
- bool ISonarQubeServer.TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory)
+ Task ISonarQubeServer.TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory)
{
LogMethodCalled();
@@ -125,21 +132,21 @@ bool ISonarQubeServer.TryDownloadEmbeddedFile(string pluginKey, string embeddedF
var data = Data.FindEmbeddedFile(pluginKey, embeddedFileName);
if (data == null)
{
- return false;
+ return Task.FromResult(false);
}
else
{
var targetFilePath = Path.Combine(targetDirectory, embeddedFileName);
File.WriteAllBytes(targetFilePath, data);
- return true;
+ return Task.FromResult(true);
}
}
- Version ISonarQubeServer.GetServerVersion()
+ Task ISonarQubeServer.GetServerVersion()
{
LogMethodCalled();
- return Data.SonarQubeVersion;
+ return Task.FromResult(Data.SonarQubeVersion);
}
#endregion ISonarQubeServer methods
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreProcessAsserts.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreProcessAsserts.cs
index 0868d3c05..91cf27e23 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreProcessAsserts.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreProcessAsserts.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreprocessTestUtils.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreprocessTestUtils.cs
index 140ba0953..8aafc2369 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreprocessTestUtils.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Infrastructure/PreprocessTestUtils.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,7 +19,6 @@
*/
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.Tests
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreProcessorTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreProcessorTests.cs
index 83f3235cd..8ff7ab370 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,12 +22,13 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Common.TFS;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
-using SonarScanner.MSBuild.TFS;
using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.Tests
@@ -50,7 +51,8 @@ public void PreProc_InvalidArgs()
new TestLogger());
// Act and assert
- Action act = () => preprocessor.Execute(null); act.Should().ThrowExactly();
+ Func act = async() => await preprocessor.Execute(null);
+ act.Should().ThrowExactly();
}
[TestMethod]
@@ -64,7 +66,7 @@ public void PreProc_EndToEnd_SuccessCase()
// * config file is created
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -107,7 +109,7 @@ public void PreProc_EndToEnd_SuccessCase()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0"));
+ var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0")).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
@@ -135,7 +137,7 @@ public void PreProc_EndToEnd_SuccessCase_NoActiveRule()
// * config file is created
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -177,7 +179,7 @@ public void PreProc_EndToEnd_SuccessCase_NoActiveRule()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0"));
+ var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0")).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
@@ -205,7 +207,7 @@ public void PreProc_EndToEnd_SuccessCase_With_Organization()
// * config file is created
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -248,7 +250,7 @@ public void PreProc_EndToEnd_SuccessCase_With_Organization()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0", "organization"));
+ var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0", "organization")).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
@@ -269,7 +271,7 @@ public void PreProc_EndToEnd_SuccessCase_With_Organization()
public void PreProc_NoPlugin()
{
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -302,7 +304,7 @@ public void PreProc_NoPlugin()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0"));
+ var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0")).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
@@ -326,7 +328,7 @@ public void PreProc_NoPlugin()
public void PreProc_NoProject()
{
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -371,7 +373,7 @@ public void PreProc_NoProject()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0", null));
+ var success = preProcessor.Execute(CreateValidArgs("key", "name", "1.0", null)).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
@@ -399,7 +401,7 @@ public void PreProc_EndToEnd_Success_LocalSettingsAreUsedInSonarLintXML()
// overriding
// Arrange
- var workingDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var workingDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
// Configure the server
@@ -443,7 +445,7 @@ public void PreProc_EndToEnd_Success_LocalSettingsAreUsedInSonarLintXML()
var preProcessor = new TeamBuildPreProcessor(mockFactory, logger);
// Act
- var success = preProcessor.Execute(args.ToArray());
+ var success = preProcessor.Execute(args.ToArray()).Result;
success.Should().BeTrue("Expecting the pre-processing to complete successfully");
}
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreprocessorObjectFactoryTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreprocessorObjectFactoryTests.cs
index f4e8a85c2..fd7b48174 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreprocessorObjectFactoryTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/PreprocessorObjectFactoryTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -88,13 +88,15 @@ public void Factory_InvalidCallSequence_Fails()
private ProcessedArgs CreateValidArguments()
{
+ var logger = new TestLogger();
var cmdLineArgs = new Common.ListPropertiesProvider();
cmdLineArgs.AddProperty(Common.SonarProperties.HostUrl, "http://foo");
var validArgs = new ProcessedArgs("key", "name", "verions", "organization", false,
cmdLineArgs,
new Common.ListPropertiesProvider(),
- EmptyPropertyProvider.Instance);
+ EmptyPropertyProvider.Instance,
+ logger);
return validArgs;
}
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ProcessedArgsTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ProcessedArgsTests.cs
index ce9ae5140..98091b335 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ProcessedArgsTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/ProcessedArgsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
+using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.Tests
{
@@ -29,11 +30,13 @@ namespace SonarScanner.MSBuild.PreProcessor.Tests
public class ProcessedArgsTests
{
private ProcessedArgs args;
+ private TestLogger logger;
[TestInitialize]
public void TestInitialize()
{
// 0. Setup
+ logger = new TestLogger();
var cmdLineProps = new ListPropertiesProvider();
cmdLineProps.AddProperty("cmd.key.1", "cmd value 1");
cmdLineProps.AddProperty("shared.key.1", "shared cmd value");
@@ -48,7 +51,7 @@ public void TestInitialize()
envProps.AddProperty("shared.key.1", "shared env value");
envProps.AddProperty("shared.key.2", "shared env value");
- this.args = new ProcessedArgs("key", "branch", "ver", null, true, cmdLineProps, fileProps, envProps);
+ this.args = new ProcessedArgs("key", "branch", "ver", null, true, cmdLineProps, fileProps, envProps, logger);
}
#region Tests
@@ -57,7 +60,7 @@ public void TestInitialize()
public void ProcArgs_Organization()
{
this.args.Organization.Should().BeNull();
- this.args = new ProcessedArgs("key", "branch", "ver", "organization", true, new ListPropertiesProvider(), new ListPropertiesProvider(), new ListPropertiesProvider());
+ this.args = new ProcessedArgs("key", "branch", "ver", "organization", true, new ListPropertiesProvider(), new ListPropertiesProvider(), new ListPropertiesProvider(), logger);
this.args.Organization.Should().Be("organization");
}
@@ -139,7 +142,7 @@ public void ProcArgs_CmdLinePropertiesOverrideFileSettings()
fileProperties.AddProperty("XXX", "file line value XXX - upper case");
// Act
- var processedArgs = new ProcessedArgs("key", "branch", "version", null, false, cmdLineProperties, fileProperties, EmptyPropertyProvider.Instance);
+ var processedArgs = new ProcessedArgs("key", "branch", "version", null, false, cmdLineProperties, fileProperties, EmptyPropertyProvider.Instance, logger);
AssertExpectedValue("shared.key1", "cmd line value1 - should override server value", processedArgs);
AssertExpectedValue("cmd.line.only", "cmd line value4 - only on command line", processedArgs);
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Properties/AssemblyInfo.cs
index e5904126e..432d8dccb 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Roslyn/PluginTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Roslyn/PluginTests.cs
index 299c03376..c6bc20fbb 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Roslyn/PluginTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/Roslyn/PluginTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynAnalyzerProviderTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynAnalyzerProviderTests.cs
index c2cb80306..4e0e386c6 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynAnalyzerProviderTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynAnalyzerProviderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -28,7 +28,6 @@
using SonarScanner.MSBuild.Common;
using SonarScanner.MSBuild.PreProcessor.Roslyn;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
-using SonarScanner.MSBuild.TFS;
using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.Tests
@@ -58,7 +57,7 @@ public void RoslynConfig_SetupAnalyzers_ArgumentChecks()
IList inactiveRules = new List();
var pluginKey = RoslynAnalyzerProvider.CSharpPluginKey;
var sonarProperties = new ListPropertiesProvider();
- var settings = CreateSettings(TestUtils.CreateTestSpecificFolder(TestContext));
+ var settings = CreateSettings(TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext));
var testSubject = CreateTestSubject(logger);
@@ -84,7 +83,7 @@ public void RoslynConfig_NoActiveRules()
IList inactiveRules = new List();
var pluginKey = "csharp";
var sonarProperties = new ListPropertiesProvider();
- var settings = CreateSettings(TestUtils.CreateTestSpecificFolder(TestContext));
+ var settings = CreateSettings(TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext));
var testSubject = CreateTestSubject(logger);
@@ -276,7 +275,7 @@ private List createActiveRules()
private string CreateTestFolders()
{
- var rootFolder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var rootFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create the binary and conf folders that are created by the bootstrapper
Directory.CreateDirectory(GetBinaryPath(rootFolder));
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynRuleSetGeneratorTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynRuleSetGeneratorTests.cs
index 0a8136fa7..25750c9b3 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynRuleSetGeneratorTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RoslynRuleSetGeneratorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RulesetWriterTest.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RulesetWriterTest.cs
index 920b3ad70..c1848488d 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RulesetWriterTest.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/RulesetWriterTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarScanner.MSBuild.PreProcessor.Tests.csproj b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarScanner.MSBuild.PreProcessor.Tests.csproj
index 16521a4cc..e8c101fa8 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarScanner.MSBuild.PreProcessor.Tests.csproj
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarScanner.MSBuild.PreProcessor.Tests.csproj
@@ -44,18 +44,53 @@
..\..\packages\FluentAssertions.5.9.0\lib\net47\FluentAssertions.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+ ..\..\packages\Moq.4.10.0\lib\net45\Moq.dll
-
- ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
+ True
+
-
- ..\..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
+
+ ..\..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll
+ True
+
+
+ ..\..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll
+ True
+
+
+ ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll
+ True
+
+
+ ..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
+ True
+
+
+ ..\..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
+ True
+
+
+ ..\..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
+ True
+
+
+ ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -69,11 +104,7 @@
-
-
-
-
-
+
@@ -107,10 +138,6 @@
{e312fdbb-bc13-4559-8f21-76ca5b88ebc5}SonarScanner.MSBuild.Common
-
- {66ce9491-1c14-45d2-beb6-a0695c63ebb2}
- SonarScanner.MSBuild.TFS
- {f43364bb-e460-4ac4-87e9-de460a9f55f5}SonarScanner.MSBuild.PreProcessor
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarWebServiceTest.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarWebServiceTest.cs
index 52f4344ae..7c44cd06d 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarWebServiceTest.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/SonarWebServiceTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,10 +23,13 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using TestUtilities;
namespace SonarScanner.MSBuild.PreProcessor.UnitTests
@@ -81,137 +84,204 @@ public void Ctor_NullLogger_Throws()
[TestMethod]
public void LogWSOnError()
{
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] = "trash";
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] = "trash";
try
{
- this.ws.TryGetQualityProfile("foo bar", null, null, "cs", out string qualityProfile);
+ _ = this.ws.TryGetQualityProfile("foo bar", null, null, "cs").Result;
Assert.Fail("Exception expected");
}
catch (Exception)
{
- this.logger.AssertErrorLogged("Failed to request and parse 'http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar': Error parsing boolean value. Path '', line 1, position 2.");
+ this.logger.AssertErrorLogged("Failed to request and parse 'http://myhost:222/api/qualityprofiles/search?project=foo+bar': Error parsing boolean value. Path '', line 1, position 2.");
}
}
+ [TestMethod]
+ public void IsLicenseValid_IsSonarCloud_ShouldReturnTrue()
+ {
+ this.ws = new SonarWebService(this.downloader, "http://myhost:222", this.logger);
+ this.downloader.Pages["http://myhost:222/api/server/version"] = "8.0.0.68001";
+
+ var result = this.ws.IsServerLicenseValid().Result;
+
+ Assert.AreEqual(true, result);
+ }
+
+ [TestMethod]
+ public void IsLicenseValid_SonarQube_InvalidLicense()
+ {
+ this.ws = new SonarWebService(this.downloader, "http://myhost:222", this.logger);
+ this.downloader.Pages["http://myhost:222/api/server/version"] = "8.5.1.34001";
+ this.downloader.Pages["http://myhost:222/api/editions/is_valid_license"] =
+ @"{
+ ""isValidLicense"": false
+ }";
+
+ var result = this.ws.IsServerLicenseValid().Result;
+
+ Assert.AreEqual(false, result);
+ }
+
+ [TestMethod]
+ public void IsLicenseValid_SonarQube_ValidLicense()
+ {
+ this.ws = new SonarWebService(this.downloader, "http://myhost:222", this.logger);
+ this.downloader.Pages["http://myhost:222/api/server/version"] = "8.5.1.34001";
+ this.downloader.Pages["http://myhost:222/api/editions/is_valid_license"] =
+ @"{
+ ""isValidLicense"": true
+ }";
+
+ var result = this.ws.IsServerLicenseValid().Result;
+
+ Assert.AreEqual(true, result);
+ }
+
+ [TestMethod]
+ public void IsLicenseValid_SonarQube_ServerNotLicensed()
+ {
+ this.ws = new SonarWebService(this.downloader, "http://myhost:222", this.logger);
+ this.downloader.Pages["http://myhost:222/api/server/version"] = "8.5.1.34001";
+ this.downloader.Pages["http://myhost:222/api/editions/is_valid_license"] =
+ @"{
+ ""errors"":[{""msg"":""License not found""}]
+ }";
+
+ var result = this.ws.IsServerLicenseValid().Result;
+
+ Assert.AreEqual(false, result);
+ }
+
+ [TestMethod]
+ public void IsLicenseValid_SonarQube_CE_SkipLicenseCheck()
+ {
+ this.ws = new SonarWebService(this.downloader, "http://myhost:222", this.logger);
+ this.downloader.Pages["http://myhost:222/api/server/version"] = "8.5.1.34001";
+
+ var result = this.ws.IsServerLicenseValid().Result;
+
+ Assert.AreEqual(true, result);
+ }
+
[TestMethod]
public void TryGetQualityProfile64()
{
this.downloader.Pages["http://myhost:222/api/server/version"] = "6.4";
- bool result;
+ Tuple result;
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] =
"{ profiles: [{\"key\":\"profile1k\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AaBranch"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AaBranch"] =
"{ profiles: [{\"key\":\"profile2k\",\"name\":\"profile2\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AanotherBranch"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AanotherBranch"] =
"{ profiles: [{\"key\":\"profile3k\",\"name\":\"profile3\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
// main
- result = this.ws.TryGetQualityProfile("foo bar", null, null, "cs", out string qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile1k");
+ result = this.ws.TryGetQualityProfile("foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile1k");
// branch specific
- result = this.ws.TryGetQualityProfile("foo bar", "aBranch", null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile2k");
+ result = this.ws.TryGetQualityProfile("foo bar", "aBranch", null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile2k");
- result = this.ws.TryGetQualityProfile("foo bar", "anotherBranch", null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile3k");
+ result = this.ws.TryGetQualityProfile("foo bar", "anotherBranch", null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile3k");
// with organizations
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar&organization=my+org"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar&organization=my+org"] =
"{ profiles: [{\"key\":\"profileOrganization\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("foo bar", null, "my org", "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profileOrganization");
+ result = this.ws.TryGetQualityProfile("foo bar", null, "my org", "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profileOrganization");
// fallback to defaults
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?defaults=true"] =
"{ profiles: [{\"key\":\"profileDefault\",\"name\":\"profileDefault\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("non existing", null, null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profileDefault");
+ result = this.ws.TryGetQualityProfile("non existing", null, null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profileDefault");
// defaults with organizations
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?defaults=true&organization=my+org"] =
"{ profiles: [{\"key\":\"profileOrganizationDefault\",\"name\":\"profileDefault\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("non existing", null, "my org", "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profileOrganizationDefault");
+ result = this.ws.TryGetQualityProfile("non existing", null, "my org", "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profileOrganizationDefault");
// no cs in list of profiles
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=java+foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=java+foo+bar"] =
"{ profiles: [{\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs", out qualityProfile);
- result.Should().BeFalse();
- qualityProfile.Should().BeNull();
+ result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeFalse();
+ result.Item2.Should().BeNull();
// empty
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=empty+foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=empty+foo+bar"] =
"{ profiles: []}";
- result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs", out qualityProfile);
- result.Should().BeFalse();
- qualityProfile.Should().BeNull();
+ result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeFalse();
+ result.Item2.Should().BeNull();
}
[TestMethod]
public void TryGetQualityProfile56()
{
- bool result;
+ Tuple result;
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] =
"{ profiles: [{\"key\":\"profile1k\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AaBranch"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AaBranch"] =
"{ profiles: [{\"key\":\"profile2k\",\"name\":\"profile2\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AanotherBranch"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AanotherBranch"] =
"{ profiles: [{\"key\":\"profile3k\",\"name\":\"profile3\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
// main
- result = this.ws.TryGetQualityProfile("foo bar", null, null, "cs", out string qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile1k");
+ result = this.ws.TryGetQualityProfile("foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile1k");
// branch specific
- result = this.ws.TryGetQualityProfile("foo bar", "aBranch", null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile2k");
+ result = this.ws.TryGetQualityProfile("foo bar", "aBranch", null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile2k");
- result = this.ws.TryGetQualityProfile("foo bar", "anotherBranch", null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile3k");
+ result = this.ws.TryGetQualityProfile("foo bar", "anotherBranch", null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile3k");
// with organizations
- result = this.ws.TryGetQualityProfile("foo bar", null, "my org", "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profile1k");
+ result = this.ws.TryGetQualityProfile("foo bar", null, "my org", "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profile1k");
// fallback to defaults
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?defaults=true"] =
"{ profiles: [{\"key\":\"profileDefault\",\"name\":\"profileDefault\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("non existing", null, null, "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profileDefault");
+ result = this.ws.TryGetQualityProfile("non existing", null, null, "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profileDefault");
// defaults with organizations
- result = this.ws.TryGetQualityProfile("non existing", null, "my org", "cs", out qualityProfile);
- result.Should().BeTrue();
- qualityProfile.Should().Be("profileDefault");
+ result = this.ws.TryGetQualityProfile("non existing", null, "my org", "cs").Result;
+ result.Item1.Should().BeTrue();
+ result.Item2.Should().Be("profileDefault");
// no cs in list of profiles
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=java+foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=java+foo+bar"] =
"{ profiles: [{\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
- result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs", out qualityProfile);
- result.Should().BeFalse();
- qualityProfile.Should().BeNull();
+ result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeFalse();
+ result.Item2.Should().BeNull();
// empty
- this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=empty+foo+bar"] =
+ this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=empty+foo+bar"] =
"{ profiles: []}";
- result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs", out qualityProfile);
- result.Should().BeFalse();
- qualityProfile.Should().BeNull();
+ result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs").Result;
+ result.Item1.Should().BeFalse();
+ result.Item2.Should().BeNull();
}
[TestMethod]
@@ -250,7 +320,7 @@ public void GetSettingsSq63()
]
}
]}";
- var result = this.ws.GetProperties("comp", null);
+ var result = this.ws.GetProperties("comp", null).Result;
result.Should().HaveCount(7);
#pragma warning disable CollectionShouldHaveElementAt // Simplify Assertion
result["sonar.exclusions"].Should().Be("myfile,myfile2");
@@ -295,7 +365,7 @@ public void GetActiveRules_UseParamAsKey()
}
}";
- var actual = this.ws.GetActiveRules("qp");
+ var actual = this.ws.GetActiveRules("qp").Result;
actual.Should().ContainSingle();
actual[0].RepoKey.Should().Be("vbnet");
@@ -386,7 +456,7 @@ public void GetActiveRules()
}
}";
- var actual = this.ws.GetActiveRules("qp");
+ var actual = this.ws.GetActiveRules("qp").Result;
actual.Should().HaveCount(3);
actual[0].RepoKey.Should().Be("vbnet");
@@ -443,7 +513,7 @@ public void GetActiveRules_WhenActivesDoesNotContainRule_ThrowsJsonException()
}
}";
- Action act = () => this.ws.GetActiveRules("qp");
+ Func act = async () => await this.ws.GetActiveRules("qp");
// Act & Assert
act.Should().ThrowExactly().WithMessage("Malformed json response, \"actives\" field should contain rule 'key1'");
@@ -470,7 +540,7 @@ public void GetActiveRules_WhenActivesContainsRuleWithEmptyBody_ThrowsJsonExcept
}
}";
- Action act = () => this.ws.GetActiveRules("qp");
+ Func act = async () => await this.ws.GetActiveRules("qp");
// Act & Assert
act.Should().ThrowExactly().WithMessage("Malformed json response, \"actives\" field should contain rule 'key1'");
@@ -522,7 +592,7 @@ public void GetActiveRules_WhenActivesContainsRuleWithMultipleBodies_ThrowsJsonE
}
}";
- Action act = () => this.ws.GetActiveRules("qp");
+ Func act = async () => await this.ws.GetActiveRules("qp");
// Act & Assert
act.Should().ThrowExactly().WithMessage("Malformed json response, \"actives\" field should contain rule 'key1'");
@@ -554,7 +624,7 @@ public void GetInactiveRulesAndEscapeUrl()
}
]}";
- var rules = this.ws.GetInactiveRules("my#qp", "cs");
+ var rules = this.ws.GetInactiveRules("my#qp", "cs").Result;
rules.Should().HaveCount(3);
@@ -576,7 +646,7 @@ public void GetProperties_NullProjectKey_Throws()
{
// Arrange
var testSubject = new SonarWebService(new TestDownloader(), "http://myserver", new TestLogger());
- Action act = () => testSubject.GetProperties(null, null);
+ Action act = () => _ = testSubject.GetProperties(null, null).Result;
// Act & Assert
act.Should().Throw().And.ParamName.Should().Be("projectKey");
@@ -601,7 +671,7 @@ public void GetProperties()
["sonar.property2"] = "value2",
["sonar.msbuild.testProjectPattern"] = "pattern"
};
- var actual1 = this.ws.GetProperties("foo bar", null);
+ var actual1 = this.ws.GetProperties("foo bar", null).Result;
actual1.Should().HaveCount(expected1.Count);
actual1.Should().NotBeSameAs(expected1);
@@ -612,7 +682,7 @@ public void GetProperties()
["sonar.property1"] = "anotherValue1",
["sonar.property2"] = "anotherValue2"
};
- var actual2 = this.ws.GetProperties("foo bar", "aBranch");
+ var actual2 = this.ws.GetProperties("foo bar", "aBranch").Result;
actual2.Should().HaveCount(expected2.Count);
actual2.Should().NotBeSameAs(expected2);
@@ -627,7 +697,7 @@ public void GetInstalledPlugins()
"cs",
"flex"
};
- var actual = new List(this.ws.GetAllLanguages());
+ var actual = new List(this.ws.GetAllLanguages().Result);
expected.SequenceEqual(actual).Should().BeTrue();
}
@@ -637,7 +707,7 @@ public void TryDownloadEmbeddedFile_NullPluginKey_Throws()
{
// Arrange
var testSubject = new SonarWebService(new TestDownloader(), "http://myserver", new TestLogger());
- Action act = () => testSubject.TryDownloadEmbeddedFile(null, "filename", "targetDir");
+ Func act = async () => await testSubject.TryDownloadEmbeddedFile(null, "filename", "targetDir");
// Act & Assert
act.Should().Throw().And.ParamName.Should().Be("pluginKey");
@@ -648,7 +718,7 @@ public void TryDownloadEmbeddedFile_NullEmbeddedFileName_Throws()
{
// Arrange
var testSubject = new SonarWebService(new TestDownloader(), "http://myserver", new TestLogger());
- Action act = () => testSubject.TryDownloadEmbeddedFile("key", null, "targetDir");
+ Func act = async () => await testSubject.TryDownloadEmbeddedFile("key", null, "targetDir");
// Act & Assert
act.Should().Throw().And.ParamName.Should().Be("embeddedFileName");
@@ -659,7 +729,7 @@ public void TryDownloadEmbeddedFile_NullTargetDirectory_Throws()
{
// Arrange
var testSubject = new SonarWebService(new TestDownloader(), "http://myserver", new TestLogger());
- Action act = () => testSubject.TryDownloadEmbeddedFile("pluginKey", "filename", null);
+ Func act = async () => await testSubject.TryDownloadEmbeddedFile("pluginKey", "filename", null);
// Act & Assert
act.Should().Throw().And.ParamName.Should().Be("targetDirectory");
@@ -669,11 +739,11 @@ public void TryDownloadEmbeddedFile_NullTargetDirectory_Throws()
public void TryDownloadEmbeddedFile_RequestedFileExists()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
this.downloader.Pages["http://myhost:222/static/csharp/dummy.txt"] = "dummy file content";
// Act
- var success = this.ws.TryDownloadEmbeddedFile("csharp", "dummy.txt", testDir);
+ var success = this.ws.TryDownloadEmbeddedFile("csharp", "dummy.txt", testDir).Result;
// Assert
success.Should().BeTrue("Expected success");
@@ -685,10 +755,10 @@ public void TryDownloadEmbeddedFile_RequestedFileExists()
public void TryDownloadEmbeddedFile_RequestedFileDoesNotExist()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Act
- var success = this.ws.TryDownloadEmbeddedFile("csharp", "dummy.txt", testDir);
+ var success = this.ws.TryDownloadEmbeddedFile("csharp", "dummy.txt", testDir).Result;
// Assert
success.Should().BeFalse("Expected failure");
@@ -707,20 +777,18 @@ public void GetProperties_Old_Forbidden()
var downloaderMock = new Mock();
downloaderMock
- .Setup(x => x.Download($"{serverUrl}/api/server/version"))
- .Returns("1.2.3.4");
+ .Setup(x => x.Download($"{serverUrl}/api/server/version", false))
+ .Returns(Task.FromResult("1.2.3.4"));
downloaderMock
- .Setup(x => x.Download($"{serverUrl}/api/properties?resource={projectKey}"))
- .Throws(new WebException("Forbidden", new Exception(), WebExceptionStatus.ConnectionClosed, responseMock.Object));
+ .Setup(x => x.Download($"{serverUrl}/api/properties?resource={projectKey}", true))
+ .Throws(new HttpRequestException("Forbidden"));
var service = new SonarWebService(downloaderMock.Object, serverUrl, this.logger);
- Action action = () => service.GetProperties(projectKey, null);
- action.Should().Throw();
+ Func action = async () => await service.GetProperties(projectKey, null);
+ action.Should().Throw();
this.logger.Errors.Should().HaveCount(1);
- this.logger.Warnings.Should().HaveCount(1);
- this.logger.Warnings[0].Should().Be("To analyze private projects make sure the scanner user has 'Browse' permission.");
}
[TestMethod]
@@ -729,27 +797,21 @@ public void GetProperties_63plus_Forbidden()
const string serverUrl = "http://localhost";
const string projectKey = "my-project";
- var responseMock = new Mock();
- responseMock.SetupGet(x => x.StatusCode).Returns(HttpStatusCode.Forbidden);
-
var downloaderMock = new Mock();
downloaderMock
- .Setup(x => x.Download($"{serverUrl}/api/server/version"))
- .Returns("6.3.0.0");
+ .Setup(x => x.Download($"{serverUrl}/api/server/version", false))
+ .Returns(Task.FromResult("6.3.0.0"));
- var content = string.Empty;
downloaderMock
- .Setup(x => x.TryDownloadIfExists($"{serverUrl}/api/settings/values?component={projectKey}", out content))
- .Throws(new WebException("Forbidden", new Exception(), WebExceptionStatus.ConnectionClosed, responseMock.Object));
+ .Setup(x => x.TryDownloadIfExists($"{serverUrl}/api/settings/values?component={projectKey}", true))
+ .Throws(new HttpRequestException("Forbidden"));
var service = new SonarWebService(downloaderMock.Object, serverUrl, this.logger);
- Action action = () => service.GetProperties(projectKey, null);
- action.Should().Throw();
+ Action action = () => _ = service.GetProperties(projectKey, null).Result;
+ action.Should().Throw();
this.logger.Errors.Should().HaveCount(1);
- this.logger.Warnings.Should().HaveCount(1);
- this.logger.Warnings[0].Should().Be("To analyze private projects make sure the scanner user has 'Browse' permission.");
}
private sealed class TestDownloader : IDownloader
@@ -757,43 +819,41 @@ private sealed class TestDownloader : IDownloader
public IDictionary Pages = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
public List AccessedUrls = new List();
- public bool TryDownloadIfExists(string url, out string contents)
+ public Task> TryDownloadIfExists(string url, bool logPermissionDenied = false)
{
this.AccessedUrls.Add(url);
if (this.Pages.ContainsKey(url))
{
- contents = this.Pages[url];
- return true;
+ return Task.FromResult(new Tuple(true, this.Pages[url]));
}
else
{
- contents = null;
- return false;
+ return Task.FromResult(new Tuple(false, null));
}
}
- public string Download(string url)
+ public Task Download(string url, bool logPermissionDenied = false)
{
this.AccessedUrls.Add(url);
if (this.Pages.ContainsKey(url))
{
- return this.Pages[url];
+ return Task.FromResult(this.Pages[url]);
}
throw new ArgumentException("Cannot find URL " + url);
}
- public bool TryDownloadFileIfExists(string url, string targetFilePath)
+ public Task TryDownloadFileIfExists(string url, string targetFilePath, bool logPermissionDenied = false)
{
this.AccessedUrls.Add(url);
if (this.Pages.ContainsKey(url))
{
File.WriteAllText(targetFilePath, this.Pages[url]);
- return true;
+ return Task.FromResult(true);
}
else
{
- return false;
+ return Task.FromResult(false);
}
}
@@ -801,6 +861,27 @@ public void Dispose()
{
// Nothing to do here
}
+
+ public Task IsLicenseValid(string url)
+ {
+ this.AccessedUrls.Add(url);
+ if (this.Pages.ContainsKey(url))
+ {
+ var json = JObject.Parse(this.Pages[url]);
+
+ if (json["errors"] != null)
+ {
+ return Task.FromResult(false);
+ }
+
+ return Task.FromResult(json["isValidLicense"].ToObject());
+ }
+ else
+ {
+ //Simulating a 404 on that one.
+ return Task.FromResult(true);
+ }
+ }
}
}
}
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/TargetsInstallerTests.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/TargetsInstallerTests.cs
index 8bee10961..b1ad8ee41 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/TargetsInstallerTests.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/TargetsInstallerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -49,7 +49,7 @@ public class TargetsInstallerTests
public void Init()
{
CleanupMsbuildDirectories();
- this.WorkingDirectory = TestUtils.CreateTestSpecificFolder(TestContext, "sonarqube");
+ this.WorkingDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "sonarqube");
this.logger = new TestLogger();
this.msBuildPathSettingsMock = new Mock();
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/WebClientDownloaderTest.cs b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/WebClientDownloaderTest.cs
index 7b5ae4274..a0de36d37 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/WebClientDownloaderTest.cs
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/WebClientDownloaderTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/app.config b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/app.config
index 557095a4b..12605fd3d 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/app.config
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/app.config
@@ -6,6 +6,14 @@
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/packages.config b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/packages.config
index 0cbc30d88..1b2d8cb94 100644
--- a/Tests/SonarScanner.MSBuild.PreProcessor.Tests/packages.config
+++ b/Tests/SonarScanner.MSBuild.PreProcessor.Tests/packages.config
@@ -4,7 +4,15 @@
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/MockProcessRunner.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/MockProcessRunner.cs
index aaab611b2..08aa702b4 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/MockProcessRunner.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/MockProcessRunner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/MockRoslynV1SarifFixer.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/MockRoslynV1SarifFixer.cs
index 7e4be62ad..cd102b2de 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/MockRoslynV1SarifFixer.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/MockRoslynV1SarifFixer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,6 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using SonarScanner.MSBuild.Shim.Interfaces;
+
namespace SonarScanner.MSBuild.Shim.Tests
{
internal class MockRoslynV1SarifFixer : IRoslynV1SarifFixer
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/PathHelperTests.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/PathHelperTests.cs
index 1bc6e3191..de1991128 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/PathHelperTests.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/PathHelperTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectInfoReportBuilderTests.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectInfoReportBuilderTests.cs
index aee54db97..f72572c38 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectInfoReportBuilderTests.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectInfoReportBuilderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -57,7 +57,7 @@ public void PIRB_WriteSummaryReport_InvalidArgs_Throws()
public void PIRB_WriteSummaryReport_ValidArgs_FileCreated()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var analysisConfig = new AnalysisConfig()
{
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectLoaderTest.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectLoaderTest.cs
index fd75d5137..e1d5c7046 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectLoaderTest.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/ProjectLoaderTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -40,10 +40,10 @@ public class ProjectLoaderTest
public void ProjectLoader()
{
// Arrange
- var testSourcePath = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testSourcePath = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create sub-directories, some with project info XML files and some without
- TestUtils.CreateTestSpecificFolder(TestContext, "EmptyDir1");
+ TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "EmptyDir1");
var validTestProject = new ProjectDescriptor()
{
@@ -58,7 +58,7 @@ public void ProjectLoader()
validTestProject.AddContentFile("contentFile1.js", true);
CreateFilesFromDescriptor(validTestProject, "testCompileListFile", "testVisualStudioCodeCoverageReport");
- TestUtils.CreateTestSpecificFolder(TestContext, "EmptyDir2");
+ TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "EmptyDir2");
var validNonTestProject = new ProjectDescriptor()
{
@@ -101,7 +101,7 @@ public void ProjectLoader()
public void ProjectLoader_NonRecursive()
{
// 0. Setup
- var rootTestDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var rootTestDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var childDir = Path.Combine(rootTestDir, "Child1");
// Create a valid project in the child directory
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/Properties/AssemblyInfo.cs
index f1bd0079d..9e9f47fd3 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests.cs
index 453414234..9093014d9 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -44,15 +44,15 @@ public void FileGen_NoProjectInfoFiles()
// Properties file should not be generated if there are no project info files.
// Arrange - two sub-directories, neither containing a ProjectInfo.xml
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
- var subDir1 = TestUtils.CreateTestSpecificFolder(TestContext, "dir1");
- var subDir2 = TestUtils.CreateTestSpecificFolder(TestContext, "dir2");
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+ var subDir1 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "dir1");
+ var subDir2 = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "dir2");
- CreateEmptyFile(subDir1, "file1.txt");
- CreateEmptyFile(subDir2, "file2.txt");
+ TestUtils.CreateEmptyFile(subDir1, "file1.txt");
+ TestUtils.CreateEmptyFile(subDir2, "file2.txt");
var logger = new TestLogger();
- var config = new AnalysisConfig() { SonarOutputDir = testDir };
+ var config = new AnalysisConfig() { SonarOutputDir = testDir, SonarQubeHostUrl = "http://sonarqube.com" };
// Act
var result = new PropertiesFileGenerator(config, logger).GenerateFile();
@@ -68,11 +68,11 @@ public void FileGen_ValidFiles()
// Only non-excluded projects with files to analyze should be marked as valid
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- CreateProjectInfoInSubDir(testDir, "withoutFiles", Guid.NewGuid(), ProjectType.Product, false, "c:\\abc\\withoutfile.proj", "UTF-8"); // not excluded
- CreateProjectWithFiles("withFiles1", testDir);
- CreateProjectWithFiles("withFiles2", testDir);
+ TestUtils.CreateProjectInfoInSubDir(testDir, "withoutFiles", Guid.NewGuid(), ProjectType.Product, false, "c:\\abc\\withoutfile.proj", "UTF-8"); // not excluded
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles2", testDir);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -93,27 +93,35 @@ public void FileGen_ValidFiles()
[TestMethod]
public void FileGen_Duplicate_SameGuid_DifferentCase_ShouldNotIgnoreCase()
{
- // Casing can be ignored on windows OS
+ var projectName1 = "withFiles1";
+ var projectName2 = "withFiles2";
- // Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "projects");
+ var project1Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, Path.Combine("projects", projectName1));
+ // Casing should not be ignored on non-windows OS
var mockRuntimeInformation = new Mock();
mockRuntimeInformation.Setup(m => m.IsOS(System.Runtime.InteropServices.OSPlatform.Windows)).Returns(false);
var guid = Guid.NewGuid();
- CreateProjectInfoInSubDir(testDir, "withoutFiles", guid, ProjectType.Product, false, "c:\\abc\\withoutfile.proj", "UTF-8");
- CreateProjectInfoInSubDir(testDir, "withoutFiles1", guid, ProjectType.Product, false, "C:\\abc\\withoutFile.proj", "UTF-8"); // not excluded
+ var contentProjectInfo1 = TestUtils.CreateProjectInfoInSubDir(testRootDir, projectName1, guid, ProjectType.Product, false, project1Dir + "\\withoutfile.proj", "UTF-8");
+ TestUtils.CreateProjectInfoInSubDir(testRootDir, projectName2, guid, ProjectType.Product, false, project1Dir + "\\withoutFile.proj", "UTF-8"); // not excluded
+
+ // Create content / managed files if required
+ var contentFile1 = TestUtils.CreateEmptyFile(project1Dir, "contentFile1.txt");
+ var contentFileList1 = TestUtils.CreateFile(project1Dir, "contentList.txt", contentFile1);
+
+ TestUtils.AddAnalysisResult(contentProjectInfo1, AnalysisType.FilesToAnalyze, contentFileList1);
var logger = new TestLogger();
- var config = CreateValidConfig(testDir);
+ var config = CreateValidConfig(testRootDir);
// Act
var result = new PropertiesFileGenerator(config, logger, new RoslynV1SarifFixer(logger), mockRuntimeInformation.Object).GenerateFile();
// Assert
- AssertExpectedStatus("withoutFiles", ProjectInfoValidity.DuplicateGuid, result);
+ AssertExpectedStatus(projectName1, ProjectInfoValidity.DuplicateGuid, result);
AssertExpectedProjectCount(1, result);
logger.Warnings.Should().HaveCount(2);
@@ -121,35 +129,45 @@ public void FileGen_Duplicate_SameGuid_DifferentCase_ShouldNotIgnoreCase()
logger.Warnings.Should().BeEquivalentTo(
new[]
{
- $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed by SonarQube. Project file: \"c:\\abc\\withoutfile.proj\"",
- $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed by SonarQube. Project file: \"C:\\abc\\withoutFile.proj\"",
+ $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed. Project file: \"{project1Dir}\\withoutfile.proj\"",
+ $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed. Project file: \"{project1Dir}\\withoutFile.proj\"",
});
}
[TestMethod]
public void FileGen_Duplicate_SameGuid_DifferentCase_ShouldIgnoreCase()
{
- // Casing can be ignored on windows OS
-
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var projectName1 = "withFiles1";
+ var projectName2 = "withFiles2";
+
+ var testRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "projects");
+ var project1Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, Path.Combine("projects", projectName1));
+
+ // Casing can be ignored on windows OS
var mockRuntimeInformation = new Mock();
mockRuntimeInformation.Setup(m => m.IsOS(System.Runtime.InteropServices.OSPlatform.Windows)).Returns(true);
var guid = Guid.NewGuid();
- CreateProjectInfoInSubDir(testDir, "withoutFiles", guid, ProjectType.Product, false, "c:\\abc\\withoutfile.proj", "UTF-8");
- CreateProjectInfoInSubDir(testDir, "withoutFiles1", guid, ProjectType.Product, false, "C:\\abc\\withoutFile.proj", "UTF-8"); // not excluded
+ var contentProjectInfo1 = TestUtils.CreateProjectInfoInSubDir(testRootDir, projectName1, guid, ProjectType.Product, false, project1Dir + "\\withoutfile.proj", "UTF-8");
+ TestUtils.CreateProjectInfoInSubDir(testRootDir, projectName2, guid, ProjectType.Product, false, project1Dir + "\\withoutFile.proj", "UTF-8"); // not excluded
+
+ // Create content / managed files if required
+ var contentFile1 = TestUtils.CreateEmptyFile(project1Dir, "contentFile1.txt");
+ var contentFileList1 = TestUtils.CreateFile(project1Dir, "contentList.txt", contentFile1);
+
+ TestUtils.AddAnalysisResult(contentProjectInfo1, AnalysisType.FilesToAnalyze, contentFileList1);
var logger = new TestLogger();
- var config = CreateValidConfig(testDir);
+ var config = CreateValidConfig(testRootDir);
// Act
var result = new PropertiesFileGenerator(config, logger, new RoslynV1SarifFixer(logger), mockRuntimeInformation.Object).GenerateFile();
// Assert
- AssertExpectedStatus("withoutFiles", ProjectInfoValidity.NoFilesToAnalyze, result);
+ AssertExpectedStatus(projectName1, ProjectInfoValidity.Valid, result);
AssertExpectedProjectCount(1, result);
}
@@ -158,9 +176,9 @@ public void FileGen_Duplicate_SameGuid_DifferentCase_ShouldIgnoreCase()
public void FileGen_ValidFiles_SourceEncoding_Provided()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- CreateProjectWithFiles("withFiles1", testDir);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -183,9 +201,9 @@ public void FileGen_ValidFiles_SourceEncoding_Provided()
public void FileGen_TFS_Coverage_Trx_Are_Written()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- CreateProjectWithFiles("withFiles1", testDir);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -210,7 +228,7 @@ public void FileGen_TFS_Coverage_Trx_Are_Written()
public void FileGen_ValidFiles_WithAlreadyValidSarif()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// SARIF file path
var testSarifPath = Path.Combine(testDir, "testSarif.json");
@@ -218,10 +236,10 @@ public void FileGen_ValidFiles_WithAlreadyValidSarif()
// Create SARIF report path property and add it to the project info
var projectSettings = new AnalysisProperties
{
- new Property() { Id = PropertiesFileGenerator.ReportFileCsharpPropertyKey, Value = testSarifPath }
+ new Property() { Id = PropertiesFileGenerator.ReportFilesCsharpPropertyKey, Value = testSarifPath }
};
var projectGuid = Guid.NewGuid();
- CreateProjectWithFiles("withFiles1", testDir, projectGuid, true, projectSettings);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir, projectGuid, true, projectSettings);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -238,14 +256,14 @@ public void FileGen_ValidFiles_WithAlreadyValidSarif()
// Already valid SARIF -> no change in file -> unchanged property
var provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
- provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFileCsharpPropertyKey, mockReturnPath);
+ provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFilesCsharpPropertyKey, mockReturnPath);
}
[TestMethod]
public void FileGen_ValidFiles_WithFixableSarif()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// SARIF file path
var testSarifPath = Path.Combine(testDir, "testSarif.json");
@@ -253,10 +271,10 @@ public void FileGen_ValidFiles_WithFixableSarif()
// Create SARIF report path property and add it to the project info
var projectSettings = new AnalysisProperties
{
- new Property() { Id = PropertiesFileGenerator.ReportFileCsharpPropertyKey, Value = testSarifPath }
+ new Property() { Id = PropertiesFileGenerator.ReportFilesCsharpPropertyKey, Value = testSarifPath }
};
var projectGuid = Guid.NewGuid();
- CreateProjectWithFiles("withFiles1", testDir, projectGuid, true, projectSettings);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir, projectGuid, true, projectSettings);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -277,14 +295,14 @@ public void FileGen_ValidFiles_WithFixableSarif()
// Fixable SARIF -> new file saved -> changed property
var provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
- provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFileCsharpPropertyKey, escapedMockReturnPath);
+ provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFilesCsharpPropertyKey, escapedMockReturnPath);
}
[TestMethod]
public void FileGen_ValidFiles_WithFixableSarif_VBNet()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// SARIF file path
var testSarifPath = Path.Combine(testDir, "testSarif.json");
@@ -292,10 +310,10 @@ public void FileGen_ValidFiles_WithFixableSarif_VBNet()
// Create SARIF report path property and add it to the project info
var projectSettings = new AnalysisProperties
{
- new Property() { Id = PropertiesFileGenerator.ReportFileVbnetPropertyKey, Value = testSarifPath }
+ new Property() { Id = PropertiesFileGenerator.ReportFilesVbnetPropertyKey, Value = testSarifPath }
};
var projectGuid = Guid.NewGuid();
- CreateProjectWithFiles("withFiles1", testDir, projectGuid, true, projectSettings);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir, projectGuid, true, projectSettings);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -316,14 +334,52 @@ public void FileGen_ValidFiles_WithFixableSarif_VBNet()
// Fixable SARIF -> new file saved -> changed property
var provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
- provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFileVbnetPropertyKey, escapedMockReturnPath);
+ provider.AssertSettingExists(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFilesVbnetPropertyKey, escapedMockReturnPath);
+ }
+
+ [TestMethod]
+ public void FileGen_WithMultipleAnalyzerAndRoslynOutputPaths_ShouldBeSupported()
+ {
+ // Arrange
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+
+ var logger = new TestLogger();
+ var config = CreateValidConfig(testDir);
+
+ var testSarifPath1 = Path.Combine(testDir, "testSarif1.json");
+ var testSarifPath2 = Path.Combine(testDir, "testSarif2.json");
+ var testSarifPath3 = Path.Combine(testDir, "testSarif3.json");
+
+ // Mock SARIF fixer simulates fixable SARIF with fixed name
+
+ var mockSarifFixer = new MockRoslynV1SarifFixer(testSarifPath1);
+
+ var projectSettings = new AnalysisProperties
+ {
+ new Property() {
+ Id = PropertiesFileGenerator.ReportFilesVbnetPropertyKey,
+ Value = String.Join(PropertiesFileGenerator.RoslynReportPathsDelimiter.ToString(), testSarifPath1, testSarifPath2, testSarifPath3)
+ }
+ };
+
+ var projectGuid = Guid.NewGuid();
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir, projectGuid, true, projectSettings);
+
+ var result = new PropertiesFileGenerator(config, logger, mockSarifFixer, new RuntimeInformationWrapper()).GenerateFile();
+
+ var provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
+ provider.AssertSettingExists
+ (projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFilesVbnetPropertyKey,
+ //MockRoslynSarifFixer takes only one path as a param, so the same one will be output 3 times instead of the 3 different ones.
+ String.Join(PropertiesFileGenerator.RoslynReportPathsDelimiter.ToString(), testSarifPath1, testSarifPath1, testSarifPath1));
+
}
[TestMethod]
public void FileGen_ValidFiles_WithUnfixableSarif()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// SARIF file path
var testSarifPath = Path.Combine(testDir, "testSarif.json");
@@ -331,10 +387,10 @@ public void FileGen_ValidFiles_WithUnfixableSarif()
// Create SARIF report path property and add it to the project info
var projectSettings = new AnalysisProperties
{
- new Property() { Id = PropertiesFileGenerator.ReportFileCsharpPropertyKey, Value = testSarifPath }
+ new Property() { Id = PropertiesFileGenerator.ReportFilesCsharpPropertyKey, Value = testSarifPath }
};
var projectGuid = Guid.NewGuid();
- CreateProjectWithFiles("withFiles1", testDir, projectGuid, true, projectSettings);
+ TestUtils.CreateProjectWithFiles(TestContext, "withFiles1", testDir, projectGuid, true, projectSettings);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -353,7 +409,7 @@ public void FileGen_ValidFiles_WithUnfixableSarif()
// Unfixable SARIF -> cannot fix -> report file property removed
var provider = new SQPropertiesFileReader(result.FullPropertiesFilePath);
- provider.AssertSettingDoesNotExist(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFileCsharpPropertyKey);
+ provider.AssertSettingDoesNotExist(projectGuid.ToString().ToUpper() + "." + PropertiesFileGenerator.ReportFilesCsharpPropertyKey);
}
[TestMethod]
@@ -362,18 +418,18 @@ public void FileGen_FilesOutsideProjectPath()
// Files outside the project root should be ignored
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- var projectDir = TestUtils.CreateTestSpecificFolder(TestContext, "project");
+ var projectDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project");
var projectPath = Path.Combine(projectDir, "project.proj");
- var projectInfo = CreateProjectInfoInSubDir(testDir, "projectName", Guid.NewGuid(), ProjectType.Product, false, "UTF-8", projectPath); // not excluded
+ var projectInfo = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName", Guid.NewGuid(), ProjectType.Product, false, "UTF-8", projectPath); // not excluded
// Create a content file, but not under the project directory
- var contentFileList = CreateFile(projectDir, "contentList.txt", Path.Combine(testDir, "contentFile1.txt"));
- AddAnalysisResult(projectInfo, AnalysisType.FilesToAnalyze, contentFileList);
+ var contentFileList = TestUtils.CreateFile(projectDir, "contentList.txt", Path.Combine(testDir, "contentFile1.txt"));
+ TestUtils.AddAnalysisResult(projectInfo, AnalysisType.FilesToAnalyze, contentFileList);
var logger = new TestLogger();
- var config = CreateValidConfig(testDir);
+ var config = CreateValidConfig(testDir);
// Act
var result = new PropertiesFileGenerator(config, logger).GenerateFile();
@@ -392,25 +448,25 @@ public void FileGen_SharedFiles()
// Shared files should be attached to the root project
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- var project1Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project1");
+ var project1Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project1");
var project1Path = Path.Combine(project1Dir, "project1.proj");
- var project1Info = CreateProjectInfoInSubDir(testDir, "projectName1", Guid.NewGuid(), ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
+ var project1Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName1", Guid.NewGuid(), ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
var sharedFile = Path.Combine(testDir, "contentFile.txt");
- CreateEmptyFile(testDir, "contentFile.txt");
+ TestUtils.CreateEmptyFile(testDir, "contentFile.txt");
// Reference shared file, but not under the project directory
- var contentFileList1 = CreateFile(project1Dir, "contentList.txt", sharedFile);
- AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
+ var contentFileList1 = TestUtils.CreateFile(project1Dir, "contentList.txt", sharedFile);
+ TestUtils.AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
- var project2Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project2");
+ var project2Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project2");
var project2Path = Path.Combine(project2Dir, "project2.proj");
- var project2Info = CreateProjectInfoInSubDir(testDir, "projectName2", Guid.NewGuid(), ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
+ var project2Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName2", Guid.NewGuid(), ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
// Reference shared file, but not under the project directory
- var contentFileList2 = CreateFile(project2Dir, "contentList.txt", sharedFile);
- AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
+ var contentFileList2 = TestUtils.CreateFile(project2Dir, "contentList.txt", sharedFile);
+ TestUtils.AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -429,29 +485,29 @@ public void FileGen_SharedFiles()
public void FileGen_SharedFiles_CaseInsensitive()
{
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Create 2 uuids and order them so that test is reproducible
var uuids = new Guid[] { Guid.NewGuid(), Guid.NewGuid() };
Array.Sort(uuids);
- var project1Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project1");
+ var project1Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project1");
var project1Path = Path.Combine(project1Dir, "project1.proj");
- var project1Info = CreateProjectInfoInSubDir(testDir, "projectName1", uuids[0], ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
+ var project1Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName1", uuids[0], ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
var sharedFile = Path.Combine(testDir, "contentFile.txt");
var sharedFileDifferentCase = Path.Combine(testDir, "ContentFile.TXT");
- CreateEmptyFile(testDir, "contentFile.txt");
+ TestUtils.CreateEmptyFile(testDir, "contentFile.txt");
// Reference shared file, but not under the project directory
- var contentFileList1 = CreateFile(project1Dir, "contentList.txt", sharedFile);
- AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
+ var contentFileList1 = TestUtils.CreateFile(project1Dir, "contentList.txt", sharedFile);
+ TestUtils.AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
- var project2Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project2");
+ var project2Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project2");
var project2Path = Path.Combine(project2Dir, "project2.proj");
- var project2Info = CreateProjectInfoInSubDir(testDir, "projectName2", uuids[1], ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
+ var project2Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName2", uuids[1], ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
// Reference shared file, but not under the project directory
- var contentFileList2 = CreateFile(project2Dir, "contentList.txt", sharedFileDifferentCase);
- AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
+ var contentFileList2 = TestUtils.CreateFile(project2Dir, "contentList.txt", sharedFileDifferentCase);
+ TestUtils.AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -473,26 +529,26 @@ public void FileGen_SharedFiles_BelongToAnotherProject()
// Shared files that belong to another project should NOT be attached to the root project
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
- var project1Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project1");
+ var project1Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project1");
var project1Path = Path.Combine(project1Dir, "project1.proj");
var project1Guid = Guid.NewGuid();
- var project1Info = CreateProjectInfoInSubDir(testDir, "projectName1", project1Guid, ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
+ var project1Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName1", project1Guid, ProjectType.Product, false, project1Path, "UTF-8"); // not excluded
var fileInProject1 = Path.Combine(project1Dir, "contentFile.txt");
- CreateEmptyFile(project1Dir, "contentFile.txt");
+ TestUtils.CreateEmptyFile(project1Dir, "contentFile.txt");
// Reference shared file, but not under the project directory
- var contentFileList1 = CreateFile(project1Dir, "contentList.txt", fileInProject1);
- AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
+ var contentFileList1 = TestUtils.CreateFile(project1Dir, "contentList.txt", fileInProject1);
+ TestUtils.AddAnalysisResult(project1Info, AnalysisType.FilesToAnalyze, contentFileList1);
- var project2Dir = TestUtils.CreateTestSpecificFolder(TestContext, "project2");
+ var project2Dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project2");
var project2Path = Path.Combine(project2Dir, "project2.proj");
- var project2Info = CreateProjectInfoInSubDir(testDir, "projectName2", Guid.NewGuid(), ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
+ var project2Info = TestUtils.CreateProjectInfoInSubDir(testDir, "projectName2", Guid.NewGuid(), ProjectType.Product, false, project2Path, "UTF-8"); // not excluded
// Reference shared file, but not under the project directory
- var contentFileList2 = CreateFile(project2Dir, "contentList.txt", fileInProject1);
- AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
+ var contentFileList2 = TestUtils.CreateFile(project2Dir, "contentList.txt", fileInProject1);
+ TestUtils.AddAnalysisResult(project2Info, AnalysisType.FilesToAnalyze, contentFileList2);
var logger = new TestLogger();
var config = CreateValidConfig(testDir);
@@ -515,12 +571,12 @@ public void FileGen_MissingFilesAreSkipped()
// The missing files should not appear in the generated properties file.
// Arrange
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
- var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "Project1");
- var projectFullPath = CreateEmptyFile(projectBaseDir, "project1.proj");
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+ var projectBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Project1");
+ var projectFullPath = TestUtils.CreateEmptyFile(projectBaseDir, "project1.proj");
- var existingManagedFile = CreateEmptyFile(projectBaseDir, "File1.cs");
- var existingContentFile = CreateEmptyFile(projectBaseDir, "Content1.txt");
+ var existingManagedFile = TestUtils.CreateEmptyFile(projectBaseDir, "File1.cs");
+ var existingContentFile = TestUtils.CreateEmptyFile(projectBaseDir, "Content1.txt");
var missingManagedFile = Path.Combine(projectBaseDir, "MissingFile1.cs");
var missingContentFile = Path.Combine(projectBaseDir, "MissingContent1.txt");
@@ -539,13 +595,14 @@ public void FileGen_MissingFilesAreSkipped()
var analysisFileList = CreateFileList(projectBaseDir, "filesToAnalyze.txt", existingManagedFile, missingManagedFile, existingContentFile, missingContentFile);
projectInfo.AddAnalyzerResult(AnalysisType.FilesToAnalyze, analysisFileList);
- var projectInfoDir = TestUtils.CreateTestSpecificFolder(TestContext, "ProjectInfo1Dir");
+ var projectInfoDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "ProjectInfo1Dir");
var projectInfoFilePath = Path.Combine(projectInfoDir, FileConstants.ProjectInfoFileName);
projectInfo.Save(projectInfoFilePath);
var logger = new TestLogger();
var config = new AnalysisConfig()
{
+ SonarQubeHostUrl = "http://sonarqube.com",
SonarProjectKey = "my_project_key",
SonarProjectName = "my_project_name",
SonarProjectVersion = "1.0",
@@ -573,10 +630,10 @@ public void FileGen_MissingFilesAreSkipped()
public void FileGen_AdditionalProperties()
{
// 0. Arrange
- var analysisRootDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
- CreateProjectWithFiles("project1", analysisRootDir);
+ TestUtils.CreateProjectWithFiles(TestContext, "project1", analysisRootDir);
var config = CreateValidConfig(analysisRootDir);
// Add additional properties
@@ -621,10 +678,10 @@ public void FileGen_AdditionalProperties()
public void FileGen_WhenNoGuid_LogWarnings()
{
// Arrange
- var analysisRootDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var analysisRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var logger = new TestLogger();
- CreateProjectWithFiles("project1", analysisRootDir, Guid.Empty);
+ TestUtils.CreateProjectWithFiles(TestContext, "project1", analysisRootDir, Guid.Empty);
var config = CreateValidConfig(analysisRootDir);
// Act
@@ -770,7 +827,7 @@ public void ProjectData_Orders_AnalyzerOutPaths()
TargetFramework = "netstandard2.0",
AnalysisSettings = new AnalysisProperties
{
- new Property { Id = ".analyzer.projectOutPath", Value = "1" }
+ new Property { Id = ".analyzer.projectOutPaths", Value = "1" }
},
},
new ProjectInfo
@@ -781,7 +838,7 @@ public void ProjectData_Orders_AnalyzerOutPaths()
TargetFramework = "netstandard2.0",
AnalysisSettings = new AnalysisProperties
{
- new Property { Id = ".analyzer.projectOutPath", Value = "2" }
+ new Property { Id = ".analyzer.projectOutPaths", Value = "2" }
},
},
new ProjectInfo
@@ -792,7 +849,7 @@ public void ProjectData_Orders_AnalyzerOutPaths()
TargetFramework = "net46",
AnalysisSettings = new AnalysisProperties
{
- new Property { Id = ".analyzer.projectOutPath", Value = "3" }
+ new Property { Id = ".analyzer.projectOutPaths", Value = "3" }
},
},
new ProjectInfo
@@ -803,14 +860,14 @@ public void ProjectData_Orders_AnalyzerOutPaths()
TargetFramework = "netstandard2.0",
AnalysisSettings = new AnalysisProperties
{
- new Property { Id = ".analyzer.projectOutPath", Value = "4" }
+ new Property { Id = ".analyzer.projectOutPaths", Value = "4" }
},
},
};
var logger = new TestLogger();
- var analysisRootDir = TestUtils.CreateTestSpecificFolder(TestContext, "project");
+ var analysisRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project");
var propertiesFileGenerator = new PropertiesFileGenerator(CreateValidConfig(analysisRootDir), logger, new RoslynV1SarifFixer(logger), new RuntimeInformationWrapper());
var results = propertiesFileGenerator.ToProjectData(projectInfos.GroupBy(p => p.ProjectGuid).First()).AnalyzerOutPaths.ToList();
@@ -847,7 +904,7 @@ public void ToProjectData_ProjectsWithDuplicateGuid()
};
var logger = new TestLogger();
- var analysisRootDir = TestUtils.CreateTestSpecificFolder(TestContext, "project");
+ var analysisRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "project");
var propertiesFileGenerator = new PropertiesFileGenerator(CreateValidConfig(analysisRootDir), logger);
var result = propertiesFileGenerator.ToProjectData(projectInfos.GroupBy(p => p.ProjectGuid).First());
@@ -855,8 +912,8 @@ public void ToProjectData_ProjectsWithDuplicateGuid()
logger.Warnings.Should().BeEquivalentTo(
new[]
{
- $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed by SonarQube. Project file: \"path1\"",
- $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed by SonarQube. Project file: \"path2\"",
+ $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed. Project file: \"path1\"",
+ $"Duplicate ProjectGuid: \"{guid}\". The project will not be analyzed. Project file: \"path2\"",
});
}
@@ -963,7 +1020,7 @@ public void GetClosestProjectOrDefault_WhenMultipleProjectsMatch_ReturnsProjectW
}
[TestMethod]
- public void GetClosestProjectOrDefault_WhenMultipleProjectsMatchWithSameLength_ReturnsNull()
+ public void GetClosestProjectOrDefault_WhenMultipleProjectsMatchWithSameLength_ReturnsClosestProject()
{
// Arrange
var projects = new[]
@@ -977,7 +1034,7 @@ public void GetClosestProjectOrDefault_WhenMultipleProjectsMatchWithSameLength_R
var actual = PropertiesFileGenerator.GetSingleClosestProjectOrDefault(new FileInfo("C:\\foo\\foo.cs"), projects);
// Assert
- actual.Should().BeNull();
+ actual.Should().Be(projects[0]);
}
#endregion Tests
@@ -989,9 +1046,9 @@ public void GetClosestProjectOrDefault_WhenMultipleProjectsMatchWithSameLength_R
///
private ProjectInfoAnalysisResult ExecuteAndCheckSucceeds(string projectName, TestLogger logger, params Property[] localSettings)
{
- var analysisRootDir = TestUtils.CreateTestSpecificFolder(TestContext, projectName);
+ var analysisRootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, projectName);
- CreateProjectWithFiles(projectName, analysisRootDir);
+ TestUtils.CreateProjectWithFiles(TestContext, projectName, analysisRootDir);
var config = CreateValidConfig(analysisRootDir);
config.LocalSettings = new AnalysisProperties();
@@ -1096,37 +1153,6 @@ private void VerifyProjectBaseDir(string expectedValue, string teamBuildValue, s
result.Should().Be(expectedValue);
}
- ///
- /// Creates a project info under the specified analysis root directory
- /// together with the supporting project and content files, along with additional properties (if specified)
- ///
- private void CreateProjectWithFiles(string projectName, string analysisRootPath, bool createContentFiles = true, AnalysisProperties additionalProperties = null)
- {
- CreateProjectWithFiles(projectName, analysisRootPath, Guid.NewGuid(), createContentFiles, additionalProperties);
- }
-
- ///
- /// Creates a project info under the specified analysis root directory
- /// together with the supporting project and content files, along with GUID and additional properties (if specified)
- ///
- private void CreateProjectWithFiles(string projectName, string analysisRootPath, Guid projectGuid, bool createContentFiles = true, AnalysisProperties additionalProperties = null)
- {
- // Create a project with content files in a new subdirectory
- var projectDir = TestUtils.CreateTestSpecificFolder(TestContext, Path.Combine("projects", projectName));
- var projectFilePath = Path.Combine(projectDir, Path.ChangeExtension(projectName, "proj"));
-
- // Create a project info file in the correct location under the analysis root
- var contentProjectInfo = CreateProjectInfoInSubDir(analysisRootPath, projectName, projectGuid, ProjectType.Product, false, projectFilePath, "UTF-8", additionalProperties); // not excluded
-
- // Create content / managed files if required
- if (createContentFiles)
- {
- var contentFile = CreateEmptyFile(projectDir, "contentFile1.txt");
- var contentFileList = CreateFile(projectDir, "contentList.txt", contentFile);
- AddAnalysisResult(contentProjectInfo, AnalysisType.FilesToAnalyze, contentFileList);
- }
- }
-
private static AnalysisConfig CreateValidConfig(string outputDir)
{
var dummyProjectKey = Guid.NewGuid().ToString();
@@ -1134,7 +1160,7 @@ private static AnalysisConfig CreateValidConfig(string outputDir)
var config = new AnalysisConfig()
{
SonarOutputDir = outputDir,
-
+ SonarQubeHostUrl = "http://sonarqube.com",
SonarProjectKey = dummyProjectKey,
SonarProjectName = dummyProjectKey,
SonarConfigDir = Path.Combine(outputDir, "config"),
@@ -1144,54 +1170,6 @@ private static AnalysisConfig CreateValidConfig(string outputDir)
return config;
}
- private static string CreateEmptyFile(string parentDir, string fileName)
- {
- return CreateFile(parentDir, fileName, string.Empty);
- }
-
- private static string CreateFile(string parentDir, string fileName, string content)
- {
- var fullPath = Path.Combine(parentDir, fileName);
- File.WriteAllText(fullPath, content);
- return fullPath;
- }
-
- ///
- /// Creates a new project info file in a new subdirectory with the given additional properties.
- ///
- private static string CreateProjectInfoInSubDir(string parentDir,
- string projectName, Guid projectGuid, ProjectType projectType, bool isExcluded, string fullProjectPath, string encoding,
- AnalysisProperties additionalProperties = null)
- {
- var newDir = Path.Combine(parentDir, projectName);
- Directory.CreateDirectory(newDir); // ensure the directory exists
-
- var project = new ProjectInfo()
- {
- FullPath = fullProjectPath,
- ProjectName = projectName,
- ProjectGuid = projectGuid,
- ProjectType = projectType,
- IsExcluded = isExcluded,
- Encoding = encoding
- };
-
- if (additionalProperties != null)
- {
- project.AnalysisSettings = additionalProperties;
- }
-
- var filePath = Path.Combine(newDir, FileConstants.ProjectInfoFileName);
- project.Save(filePath);
- return filePath;
- }
-
- private static void AddAnalysisResult(string projectInfoFile, AnalysisType resultType, string location)
- {
- var projectInfo = ProjectInfo.Load(projectInfoFile);
- projectInfo.AddAnalyzerResult(resultType, location);
- projectInfo.Save(projectInfoFile);
- }
private static string CreateFileList(string parentDir, string fileName, params string[] files)
{
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests_MultiTarget.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests_MultiTarget.cs
index 240b0d6ac..b57f24615 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests_MultiTarget.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesFileGeneratorTests_MultiTarget.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -55,7 +55,7 @@ public void Same_Files_In_All_Targets_Are_Not_Duplicated()
*/
// Arrange
- var solutionDir = TestUtils.CreateTestSpecificFolder(TestContext, "Solution1");
+ var solutionDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Solution1");
var projectRoot = CreateProject(solutionDir, out List files);
@@ -111,7 +111,7 @@ public void Different_Files_Per_Target_Are_Merged()
*/
// Arrange
- var solutionDir = TestUtils.CreateTestSpecificFolder(TestContext, "Solution1");
+ var solutionDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Solution1");
var projectRoot = CreateProject(solutionDir, out List files);
@@ -167,7 +167,7 @@ public void Different_Files_Per_Target_The_Ignored_Compilations_Are_Not_Included
*/
// Arrange
- var solutionDir = TestUtils.CreateTestSpecificFolder(TestContext, "Solution1");
+ var solutionDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Solution1");
var projectRoot = CreateProject(solutionDir, out List files);
@@ -223,7 +223,7 @@ public void All_Targets_Ignored_Compilations_Are_Not_Included()
*/
// Arrange
- var solutionDir = TestUtils.CreateTestSpecificFolder(TestContext, "Solution1");
+ var solutionDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Solution1");
var projectRoot = CreateProject(solutionDir, out List files);
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesWriterTest.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesWriterTest.cs
index 1f16ec3cc..bc0e8e8ab 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesWriterTest.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/PropertiesWriterTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -83,7 +83,7 @@ public void WriteAnalyzerOutputPaths_WritesEncodedAnalyzerOutPaths()
[TestMethod]
public void PropertiesWriterToString()
{
- var productBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_ProductBaseDir");
+ var productBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_ProductBaseDir");
var productProject = CreateEmptyFile(productBaseDir, "MyProduct.csproj");
var productFile = CreateEmptyFile(productBaseDir, "File.cs");
var productChineseFile = CreateEmptyFile(productBaseDir, "你好.cs");
@@ -92,7 +92,7 @@ public void PropertiesWriterToString()
CreateEmptyFile(productBaseDir, "productTrx.trx");
var productFileListFilePath = Path.Combine(productBaseDir, "productManagedFiles.txt");
- var otherDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_OtherDir");
+ var otherDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_OtherDir");
var missingFileOutsideProjectDir = new FileInfo(Path.Combine(otherDir, "missing.cs"));
var productFiles = new List
@@ -109,7 +109,7 @@ public void PropertiesWriterToString()
var productVB = new ProjectData(CreateProjectInfo("vbProject", "B51622CF-82F4-48C9-9F38-FB981FAFAF3A", productProject, false, productFiles, productFileListFilePath, productCoverageFilePath, ProjectLanguages.VisualBasic, "UTF-8"));
productVB.SonarQubeModuleFiles.Add(productFile);
- var testBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_TestBaseDir");
+ var testBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_TestBaseDir");
var testProject = CreateEmptyFile(testBaseDir, "MyTest.csproj");
var testFile = CreateEmptyFile(testBaseDir, "File.cs");
var testFileListFilePath = Path.Combine(testBaseDir, "testManagedFiles.txt");
@@ -211,7 +211,7 @@ public void Flush_WhenCalledTwice_ThrowsInvalidOperationException()
SonarProjectKey = "key",
SonarProjectName = "name",
SonarProjectVersion = "1.0",
- SonarOutputDir = TestUtils.CreateTestSpecificFolder(TestContext)
+ SonarOutputDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext)
};
var writer = new PropertiesWriter(validConfig, new TestLogger());
@@ -231,7 +231,7 @@ public void WriteSettingsForProject_WhenFlushed_ThrowsInvalidOperationException(
SonarProjectKey = "key",
SonarProjectName = "name",
SonarProjectVersion = "1.0",
- SonarOutputDir = TestUtils.CreateTestSpecificFolder(TestContext)
+ SonarOutputDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext)
};
var writer = new PropertiesWriter(validConfig, new TestLogger());
@@ -250,7 +250,7 @@ public void PropertiesWriter_AnalysisSettingsWritten()
{
// Tests that analysis settings in the ProjectInfo are written to the file
// Arrange
- var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
+ var projectBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
var productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj");
var productFile = CreateEmptyFile(projectBaseDir, "File.cs");
@@ -294,7 +294,7 @@ public void PropertiesWriter_WorkdirPerModuleExplicitlySet()
// Tests that .sonar.working.directory is explicitly set per module
// Arrange
- var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
+ var projectBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
var productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj");
var productFile = CreateEmptyFile(projectBaseDir, "File.cs");
@@ -343,7 +343,7 @@ public void PropertiesWriter_GlobalSettingsWritten()
// Tests that global settings in the ProjectInfo are written to the file
// Arrange
- var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_GlobalSettingsWritten");
+ var projectBaseDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "PropertiesWriterTest_GlobalSettingsWritten");
var config = new AnalysisConfig()
{
@@ -481,7 +481,7 @@ private void EncodeAsSonarQubeMultiValueProperty_WhenGivenSQVersionAndInvalidPat
// Assert
actual.Should().Be(@"C:\foo.cs");
logger.Warnings.Should().HaveCount(1);
- logger.Warnings[0].Should().Be("The following paths contain invalid characters for this version of SonarQube and will be excluded from this analysis: C:\\foo,bar.cs");
+ logger.Warnings[0].Should().Be("The following paths contain invalid characters and will be excluded from this analysis: C:\\foo,bar.cs");
}
#endregion Tests
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/RoslynV1SarifFixerTests.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/RoslynV1SarifFixerTests.cs
index 17b77e4bc..6c45dec33 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/RoslynV1SarifFixerTests.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/RoslynV1SarifFixerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -25,7 +25,7 @@
using SonarScanner.MSBuild.Shim;
using TestUtilities;
-namespace SonarQube.Shim.Tests
+namespace SonarScanner.Shim.Tests
{
[TestClass]
public class RoslynV1SarifFixerTests
@@ -43,7 +43,7 @@ public void SarifFixer_ShouldNotChange_Valid()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -90,7 +90,7 @@ public void SarifFixer_ShouldNotChange_Unfixable()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -146,7 +146,7 @@ public void SarifFixer_ShouldNotChange_MultipleLineValues()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -185,7 +185,7 @@ public void SarifFixer_ShouldChange_EscapeBackslashes()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -251,7 +251,7 @@ public void SarifFixer_ShouldChange_EscapeQuotes()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -309,7 +309,7 @@ public void SarifFixer_ShouldChange_EscapeCharsInAllAffectedFields()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -389,7 +389,7 @@ public void SarifFixer_VBNet()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
@@ -458,7 +458,7 @@ public void SarifFixer_ShouldNotFixInvalid()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var testSarifString = @"{
""version"": ""0.1"",
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarProjectPropertiesValidatorTest.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarProjectPropertiesValidatorTest.cs
index 4657ec722..6ca9f5eb5 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarProjectPropertiesValidatorTest.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarProjectPropertiesValidatorTest.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
@@ -37,26 +38,23 @@ public class SonarProjectPropertiesValidatorTest
[TestMethod]
public void SonarProjectPropertiesValidatorTest_FailCurrentDirectory()
{
- var folder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var folder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
File.Create(Path.Combine(folder, "sonar-project.properties"));
- var called = false;
- SonarProjectPropertiesValidator.Validate(
- folder, new List(),
- onValid: () => Assert.Fail("expected validation to fail"),
- onInvalid: (paths) =>
- {
- called = true;
- paths.Count.Should().Be(1);
- paths[0].Should().Be(folder);
- });
- called.Should().BeTrue("Callback not called");
+ var underTest = new SonarProjectPropertiesValidator();
+
+ var result = underTest.AreExistingSonarPropertiesFilesPresent(folder, new List(), out var expectedInvalidFolders);
+
+ Assert.IsTrue(result);
+
+ Assert.AreEqual(1, expectedInvalidFolders.Count());
+ Assert.AreEqual(folder, expectedInvalidFolders.First());
}
[TestMethod]
public void SonarProjectPropertiesValidatorTest_FailProjectDirectory()
{
- var folder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var folder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var p1 = new ProjectData(MockProject(folder, "Project1")) { Status = ProjectInfoValidity.Valid };
var p2 = new ProjectData(MockProject(folder, "Project2")) { Status = ProjectInfoValidity.Valid };
@@ -72,24 +70,21 @@ public void SonarProjectPropertiesValidatorTest_FailProjectDirectory()
p3,
};
- var called = false;
- SonarProjectPropertiesValidator.Validate(
- folder, projects,
- onValid: () => Assert.Fail("expected validation to fail"),
- onInvalid: (paths) =>
- {
- called = true;
- paths.Count.Should().Be(2);
- paths[0].Should().Be(Path.GetDirectoryName(p1.Project.FullPath));
- paths[1].Should().Be(Path.GetDirectoryName(p3.Project.FullPath));
- });
- called.Should().BeTrue("Callback not called");
+ var underTest = new SonarProjectPropertiesValidator();
+
+ var result = underTest.AreExistingSonarPropertiesFilesPresent(folder, projects, out var expectedInvalidFolders);
+
+ Assert.IsTrue(result);
+
+ Assert.AreEqual(2, expectedInvalidFolders.Count());
+ Assert.AreEqual(Path.GetDirectoryName(p1.Project.FullPath), expectedInvalidFolders.ElementAt(0));
+ Assert.AreEqual(Path.GetDirectoryName(p3.Project.FullPath), expectedInvalidFolders.ElementAt(1));
}
[TestMethod]
public void SonarProjectPropertiesValidatorTest_SucceedAndSkipInvalidProjects()
{
- var folder = TestUtils.CreateTestSpecificFolder(TestContext);
+ var folder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var p1 = new ProjectData(MockProject(folder, "Project1")) { Status = ProjectInfoValidity.Valid };
var p2 = new ProjectData(MockProject(folder, "Project3")) { Status = ProjectInfoValidity.ExcludeFlagSet };
@@ -108,15 +103,12 @@ public void SonarProjectPropertiesValidatorTest_SucceedAndSkipInvalidProjects()
p4,
};
- var called = false;
- SonarProjectPropertiesValidator.Validate(
- folder, projects,
- onValid: () => called = true,
- onInvalid: (paths) =>
- {
- Assert.Fail("Expected to succeed");
- });
- called.Should().BeTrue("Callback not called");
+ var underTest = new SonarProjectPropertiesValidator();
+
+ var result = underTest.AreExistingSonarPropertiesFilesPresent(folder, projects, out var expectedInvalidFolders);
+
+ Assert.IsFalse(result);
+ Assert.AreEqual(0, expectedInvalidFolders.Count());
}
#endregion Tests
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScanner.MSBuild.Shim.Tests.csproj b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScanner.MSBuild.Shim.Tests.csproj
index b0669f4f8..212701ae1 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScanner.MSBuild.Shim.Tests.csproj
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScanner.MSBuild.Shim.Tests.csproj
@@ -44,26 +44,32 @@
..\..\packages\FluentAssertions.5.9.0\lib\net47\FluentAssertions.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+ ..\..\packages\Moq.4.10.0\lib\net45\Moq.dll
+
+ ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
+
-
- ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
-
+
+ ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+ ..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
-
- ..\..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
+
+ ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -77,11 +83,7 @@
-
-
-
-
-
+
@@ -99,6 +101,7 @@
+
@@ -109,6 +112,10 @@
{c28a09bf-6025-4ea1-90d7-4d5ec0af815d}SonarScanner.MSBuild.Shim
+
+ {aeff9994-48e2-4d7a-9c97-641e3db82411}
+ SonarScanner.MSBuild.TFS.Classic
+ {2fa8e679-3bec-4679-a543-8cadb117c9eb}TestUtilities
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScannerWrapperTests.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScannerWrapperTests.cs
index 8dee10b2a..e513466c3 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScannerWrapperTests.cs
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/SonarScannerWrapperTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -43,7 +43,7 @@ public void Execute_WhenConfigIsNull_Throws()
{
// Arrange
var testSubject = new SonarScannerWrapper(new TestLogger());
- Action act = () => testSubject.Execute(null, new string[] { });
+ Action act = () => testSubject.Execute(null, new string[] { }, String.Empty);
// Act & Assert
act.Should().ThrowExactly().And.ParamName.Should().Be("config");
@@ -54,7 +54,7 @@ public void Execute_WhenUserCmdLineArgumentsIsNull_Throws()
{
// Arrange
var testSubject = new SonarScannerWrapper(new TestLogger());
- Action act = () => testSubject.Execute(new AnalysisConfig(), null);
+ Action act = () => testSubject.Execute(new AnalysisConfig(), null, String.Empty);
// Act & Assert
act.Should().ThrowExactly().And.ParamName.Should().Be("userCmdLineArguments");
@@ -179,7 +179,7 @@ public void SonarScanner_SensitiveArgsPassedOnCommandLine()
new Property() { Id = "file.not.sensitive.key", Value = "not sensitive value" }
};
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var settingsFilePath = Path.Combine(testDir, "fileSettings.txt");
fileSettings.Save(settingsFilePath);
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/TFSProcessorWrapperTest.cs b/Tests/SonarScanner.MSBuild.Shim.Tests/TFSProcessorWrapperTest.cs
new file mode 100644
index 000000000..d69de27e7
--- /dev/null
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/TFSProcessorWrapperTest.cs
@@ -0,0 +1,209 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SonarScanner.MSBuild.Common;
+using TestUtilities;
+
+namespace SonarScanner.MSBuild.Shim.Tests
+{
+ [TestClass]
+ public class TFSProcessorWrapperTest
+ {
+
+ public TestContext TestContext { get; set; }
+
+ #region Tests
+
+ [TestMethod]
+ public void Execute_WhenConfigIsNull_Throws()
+ {
+ // Arrange
+ var testSubject = new TfsProcessorWrapper(new TestLogger());
+ Action act = () => testSubject.Execute(null, new string[] { }, String.Empty);
+
+ // Act & Assert
+ act.Should().ThrowExactly().And.ParamName.Should().Be("config");
+ }
+
+ [TestMethod]
+ public void Execute_WhenUserCmdLineArgumentsIsNull_Throws()
+ {
+ // Arrange
+ var testSubject = new TfsProcessorWrapper(new TestLogger());
+ Action act = () => testSubject.Execute(new AnalysisConfig(), null, String.Empty);
+
+ // Act & Assert
+ act.Should().ThrowExactly().And.ParamName.Should().Be("userCmdLineArguments");
+ }
+
+ [TestMethod]
+ public void Ctor_WhenLoggerIsNull_Throws()
+ {
+ // Arrange
+ Action act = () => new TfsProcessorWrapper(null);
+
+ // Act & Assert
+ act.Should().ThrowExactly().And.ParamName.Should().Be("logger");
+ }
+
+
+ [TestMethod]
+ public void TfsProcessor_StandardAdditionalArgumentsPassed()
+ {
+ // Arrange
+ var logger = new TestLogger();
+ var mockRunner = new MockProcessRunner(executeResult: true);
+ var config = new AnalysisConfig() { SonarScannerWorkingDirectory = "c:\\work" };
+
+ // Act
+ var success = ExecuteTFSProcessorIgnoringAsserts(config, Enumerable.Empty(), logger, "c:\\exe.Path", "d:\\propertiesFile.Path", mockRunner);
+
+ // Assert
+ VerifyProcessRunOutcome(mockRunner, logger, "c:\\work", success, true);
+ }
+
+ [TestMethod]
+ public void TfsProcessor_CmdLineArgsOrdering()
+ {
+ // Check that user arguments are passed through to the wrapper and that they appear first
+
+ // Arrange
+ var logger = new TestLogger();
+ var args = new string[] { "ConvertCoverage", "d:\\propertiesFile.Path" };
+
+ var mockRunner = new MockProcessRunner(executeResult: true);
+
+ // Act
+ var success = ExecuteTFSProcessorIgnoringAsserts(
+ new AnalysisConfig() { SonarScannerWorkingDirectory = "D:\\dummyWorkingDirectory" },
+ args,
+ logger,
+ "c:\\dummy.exe",
+ "c:\\foo.properties",
+ mockRunner);
+
+ // Assert
+ VerifyProcessRunOutcome(mockRunner, logger, "D:\\dummyWorkingDirectory", success, true);
+
+ CheckArgExists("ConvertCoverage", mockRunner);
+ CheckArgExists("d:\\propertiesFile.Path", mockRunner);
+ }
+
+
+ [TestMethod]
+ public void WrapperError_Success_NoStdErr()
+ {
+ TestWrapperErrorHandling(executeResult: true, addMessageToStdErr: false, expectedOutcome: true);
+ }
+
+ [TestMethod]
+ public void WrapperError_Success_StdErr()
+ {
+ TestWrapperErrorHandling(executeResult: true, addMessageToStdErr: true, expectedOutcome: true);
+ }
+
+ [TestMethod]
+ public void WrapperError_Fail_NoStdErr()
+ {
+ TestWrapperErrorHandling(executeResult: false, addMessageToStdErr: false, expectedOutcome: false);
+ }
+
+ [TestMethod]
+ public void WrapperError_Fail_StdErr()
+ {
+ TestWrapperErrorHandling(executeResult: false, addMessageToStdErr: true, expectedOutcome: false);
+ }
+
+ private void TestWrapperErrorHandling(bool executeResult, bool addMessageToStdErr, bool expectedOutcome)
+ {
+ // Arrange
+ var logger = new TestLogger();
+ var mockRunner = new MockProcessRunner(executeResult);
+
+ var config = new AnalysisConfig() { SonarScannerWorkingDirectory = "C:\\working" };
+
+ if (addMessageToStdErr)
+ {
+ logger.LogError("Dummy error");
+ }
+
+ // Act
+ var success = ExecuteTFSProcessorIgnoringAsserts(config, Enumerable.Empty(), logger, "c:\\bar.exe", "c:\\props.xml", mockRunner);
+
+ // Assert
+ VerifyProcessRunOutcome(mockRunner, logger, "C:\\working", success, expectedOutcome);
+ }
+
+ #endregion Tests
+
+ #region Private methods
+
+ private static bool ExecuteTFSProcessorIgnoringAsserts(AnalysisConfig config, IEnumerable userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName, IProcessRunner runner)
+ {
+ using (new AssertIgnoreScope())
+ {
+ return TfsProcessorWrapper.ExecuteProcessorRunner(config, logger, exeFileName, userCmdLineArguments, propertiesFileName, runner);
+ }
+ }
+
+ #endregion Private methods
+
+ #region Checks
+
+ private static void VerifyProcessRunOutcome(MockProcessRunner mockRunner, TestLogger testLogger, string expectedWorkingDir, bool actualOutcome, bool expectedOutcome)
+ {
+ actualOutcome.Should().Be(expectedOutcome);
+
+ mockRunner.SuppliedArguments.WorkingDirectory.Should().Be(expectedWorkingDir);
+
+ if (actualOutcome)
+ {
+ // Errors can still be logged when the process completes successfully, so
+ // we don't check the error log in this case
+ testLogger.AssertInfoMessageExists(Resources.MSG_TFSProcessorCompleted);
+ }
+ else
+ {
+ testLogger.AssertErrorsLogged();
+ testLogger.AssertErrorLogged(Resources.ERR_TFSProcessorExecutionFailed);
+ }
+ }
+
+ ///
+ /// Checks that the argument exists, and returns the start position of the argument in the list of
+ /// concatenated arguments so we can check that the arguments are passed in the correct order
+ ///
+ private int CheckArgExists(string expectedArg, MockProcessRunner mockRunner)
+ {
+ var allArgs = string.Join(" ", mockRunner.SuppliedArguments.CmdLineArgs);
+ var index = allArgs.IndexOf(expectedArg);
+ index.Should().BeGreaterThan(-1, "Expected argument was not found. Arg: '{0}', all args: '{1}'", expectedArg, allArgs);
+ return index;
+
+ }
+
+ #endregion Checks
+ }
+}
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/app.config b/Tests/SonarScanner.MSBuild.Shim.Tests/app.config
index 557095a4b..98b766e9c 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/app.config
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/app.config
@@ -6,6 +6,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.Shim.Tests/packages.config b/Tests/SonarScanner.MSBuild.Shim.Tests/packages.config
index 38c300dd5..ef0d163b5 100644
--- a/Tests/SonarScanner.MSBuild.Shim.Tests/packages.config
+++ b/Tests/SonarScanner.MSBuild.Shim.Tests/packages.config
@@ -4,8 +4,9 @@
-
+
+
-
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageReportProcessorTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageReportProcessorTests.cs
index 3a521ca6c..0b1b46ba0 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageReportProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageReportProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
@@ -84,10 +83,10 @@ public void SearchFallbackShouldBeCalled_IfNoTrxFilesFound()
public void SearchFallbackNotShouldBeCalled_IfTrxFilesFound()
{
var mockSearchFallback = new MockSearchFallback();
- var testDir = Path.GetTempPath();
+ var testDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())).FullName;
var testResultsDir = Path.Combine(testDir, "TestResults");
Directory.CreateDirectory(testResultsDir);
- TestUtils.CreateTextFile(testResultsDir, "dummy.trx", "");
+ TestUtils.CreateTextFile(testResultsDir, "dummy.trx", TRX_PAYLOAD);
var testSubject = new BuildVNextCoverageReportProcessor(new MockReportConverter(), new TestLogger(), mockSearchFallback);
@@ -142,7 +141,7 @@ public void ProcessCoverageReports_VsCoverageXmlPathProvided_NotCoverageXmlFileA
analysisConfig.LocalSettings.Add(new Property { Id = SonarProperties.VsCoverageXmlReportsPaths, Value = coveragePathValue });
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
// Act
var result = testSubject.ProcessCoverageReports();
@@ -159,7 +158,7 @@ public void ProcessCoverageReports_VsTestReportsPathsProvided_ShouldSkipSearchin
{
// Arrange
var mockSearchFallback = new MockSearchFallback();
- var testDir = Path.GetTempPath();
+ var testDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())).FullName;
var analysisConfig = new AnalysisConfig { LocalSettings = new AnalysisProperties() };
var testLogger = new TestLogger();
@@ -174,7 +173,7 @@ public void ProcessCoverageReports_VsTestReportsPathsProvided_ShouldSkipSearchin
analysisConfig.LocalSettings.Add(new Property { Id = SonarProperties.VsTestReportsPaths, Value = String.Empty });
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
// Act
var result = testSubject.ProcessCoverageReports();
@@ -215,7 +214,7 @@ public void ProcessCoverageReports_VsCoverageXmlPathProvided_CoverageXmlFileAlre
analysisConfig.LocalSettings.Add(new Property { Id = SonarProperties.VsCoverageXmlReportsPaths, Value = String.Empty });
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
try
{
@@ -262,7 +261,7 @@ public void ProcessCoverageReports_NotVsCoverageXmlPathProvided_CoverageXmlFileA
BuildDirectory = testDir
};
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
// Act
try
@@ -310,7 +309,7 @@ public void ProcessCoverageReports_NotVsCoverageXmlPathProvided_NotCoverageXmlFi
BuildDirectory = testDir
};
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
// Act
var result = testSubject.ProcessCoverageReports();
@@ -349,7 +348,7 @@ public void ProcessCoverageReports_NotVsCoverageXmlPathProvided_NotCoverageXmlFi
BuildDirectory = testDir
};
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, testDir + "\\sonar-project.properties");
// Act
var result = testSubject.ProcessCoverageReports();
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageSearchFallbackTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageSearchFallbackTests.cs
index 343933ec1..77f48c263 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageSearchFallbackTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/BuildVNextCoverageSearchFallbackTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -39,7 +39,7 @@ public void Fallback_AgentDirectory_CalculatedCorrectly()
{
// Arrange
var testSubject = new BuildVNextCoverageSearchFallback(new TestLogger());
- var rootDir = TestUtils.CreateTestSpecificFolder(this.TestContext);
+ var rootDir = TestUtils.CreateTestSpecificFolderWithSubPaths(this.TestContext);
var envDir = Path.Combine(rootDir, "DirSpecifiedInEnvDir");
using (var envVars = new EnvironmentVariableScope())
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/BinaryToXmlCoverageReportConverterTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/BinaryToXmlCoverageReportConverterTests.cs
index 421a245f6..01ed6afea 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/BinaryToXmlCoverageReportConverterTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/BinaryToXmlCoverageReportConverterTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -40,7 +40,7 @@ public class BinaryToXmlCoverageReportConverterTests
[TestMethod]
public void Conv_Ctor_InvalidArgs_Throws()
{
- Action op = () => new BinaryToXmlCoverageReportConverter(null);
+ Action op = () => new BinaryToXmlCoverageReportConverter(null, new AnalysisConfig());
op.Should().Throw().And.ParamName.Should().Be("logger");
}
@@ -49,7 +49,7 @@ public void Conv_Ctor_InvalidArgs_Throws()
public void Conv_ConvertToXml_InvalidArgs_Throws()
{
ILogger loggerMock = new Mock().Object;
- var testSubject = new BinaryToXmlCoverageReportConverter(loggerMock);
+ var testSubject = new BinaryToXmlCoverageReportConverter(loggerMock, new AnalysisConfig());
// 1. Null input path
Action op = () => testSubject.ConvertToXml(null, "dummypath");
@@ -72,7 +72,7 @@ public void Conv_OutputIsCaptured()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var outputFilePath = Path.Combine(testDir, "output.txt");
@@ -106,7 +106,7 @@ public void Conv_FailsIfFileNotFound()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var outputFilePath = Path.Combine(testDir, "output.txt");
@@ -133,7 +133,7 @@ public void Conv_FailsIfFileConverterReturnsAnErrorCode()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var outputFilePath = Path.Combine(testDir, "output.txt");
@@ -159,7 +159,7 @@ public void Conv_HasThreeArguments()
{
// Arrange
var logger = new TestLogger();
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var outputFilePath = Path.Combine(testDir, "output.txt");
@@ -192,7 +192,7 @@ public void Initialize_CanGetGetExeToolPathFromSetupConfiguration()
var factory = CreateVisualStudioSetupConfigurationFactory("Microsoft.VisualStudio.TestTools.CodeCoverage");
- var reporter = new BinaryToXmlCoverageReportConverter(factory, logger);
+ var reporter = new BinaryToXmlCoverageReportConverter(factory, logger, new AnalysisConfig());
// Act
var result = reporter.Initialize();
@@ -203,6 +203,25 @@ public void Initialize_CanGetGetExeToolPathFromSetupConfiguration()
logger.AssertDebugLogged("Code coverage command line tool: x:\\foo\\Team Tools\\Dynamic Code Coverage Tools\\CodeCoverage.exe");
}
+ [TestMethod]
+ public void Initialize_CanGetGetExeToolPathFromEnvironmentVariable()
+ {
+ // Arrange
+ var logger = new TestLogger();
+ var config = new AnalysisConfig();
+ config.SetVsCoverageConverterToolPath(@"My:\Path\To\CodeCoverage.exe");
+
+ var reporter = new BinaryToXmlCoverageReportConverter(logger, config);
+
+ // Act
+ var result = reporter.Initialize();
+
+ // Assert
+ result.Should().BeTrue();
+
+ logger.AssertDebugLogged(@"VsTestToolsInstallerInstalledToolLocation environment variable detected, taking this one as tool path for CodeCoverage.exe.");
+ }
+
[TestMethod]
public void Initialize_CanGetGetExeToolPathFromSetupConfigurationForBuildAgent()
{
@@ -211,7 +230,7 @@ public void Initialize_CanGetGetExeToolPathFromSetupConfigurationForBuildAgent()
var factory = CreateVisualStudioSetupConfigurationFactory("Microsoft.VisualStudio.TestTools.CodeCoverage.Msi");
- var reporter = new BinaryToXmlCoverageReportConverter(factory, logger);
+ var reporter = new BinaryToXmlCoverageReportConverter(factory, logger, new AnalysisConfig());
// Act
var result = reporter.Initialize();
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportDownloaderTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportDownloaderTests.cs
index 5db07f7f6..82c633041 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportDownloaderTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportDownloaderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportUrlProviderTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportUrlProviderTests.cs
index fc714c38e..a8339c918 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportUrlProviderTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/CoverageReportUrlProviderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyBuildSummaryLoggerTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyBuildSummaryLoggerTests.cs
index 0b661d0e6..8b0aa8d30 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyBuildSummaryLoggerTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyBuildSummaryLoggerTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyTeamBuildFactoryTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyTeamBuildFactoryTests.cs
index dab4885d9..c12a59c53 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyTeamBuildFactoryTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/LegacyTeamBuildFactoryTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -32,14 +32,14 @@ public class LegacyTeamBuildFactoryTests
[TestMethod]
public void Ctor_Argument_Check()
{
- Action action = () => new LegacyTeamBuildFactory(null);
+ Action action = () => new LegacyTeamBuildFactory(null, new Common.AnalysisConfig());
action.Should().ThrowExactly().And.ParamName.Should().Be("logger");
}
[TestMethod]
public void BuildLegacyBuildSummaryLogger_Arguments_Check()
{
- var factory = new LegacyTeamBuildFactory(new TestLogger());
+ var factory = new LegacyTeamBuildFactory(new TestLogger(), new Common.AnalysisConfig());
factory.BuildLegacyBuildSummaryLogger(tfsUri: "tfsUri", buildUri: "buildUri")
.Should().BeOfType();
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/TfsLegacyCoverageReportProcessorTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/TfsLegacyCoverageReportProcessorTests.cs
index 40d4b7ab8..d4b34b01e 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/TfsLegacyCoverageReportProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Classic/TfsLegacyCoverageReportProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using System;
using System.IO;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -66,7 +67,7 @@ public void ReportProcessor_CannotConvertFiles()
var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);
// Act
- var initResult = processor.Initialise(context, settings);
+ var initResult = processor.Initialise(context, settings, string.Empty);
// Assert
initResult.Should().BeFalse("Expecting false: processor should not have been initialized successfully");
@@ -90,11 +91,12 @@ public void ReportProcessor_NoUrlsFound()
var context = CreateValidContext();
var settings = CreateValidSettings();
var logger = new TestLogger();
+ var testDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);
// Act
- var initResult = processor.Initialise(context, settings);
+ var initResult = processor.Initialise(context, settings, testDir + "\\sonar-project.properties");
initResult.Should().BeTrue("Expecting true: processor should have been initialized successfully");
var result = processor.ProcessCoverageReports();
@@ -119,13 +121,17 @@ public void ReportProcessor_MultipleUrlsFound()
var context = CreateValidContext();
var settings = CreateValidSettings();
var logger = new TestLogger();
+ var testDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
+ Directory.CreateDirectory(testDir);
+
+ TestUtils.CreateTextFile(testDir, "sonar-project.properties", String.Empty);
downloader.CreateFileOnDownloadRequest = true;
var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);
// Act
- var initResult = processor.Initialise(context, settings);
+ var initResult = processor.Initialise(context, settings, testDir + "\\sonar-project.properties");
initResult.Should().BeTrue("Expecting true: processor should have been initialized successfully");
var result = processor.ProcessCoverageReports();
@@ -155,7 +161,7 @@ public void ReportProcessor_SingleUrlFound_NotDownloaded()
var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);
// Act
- var initResult = processor.Initialise(context, settings);
+ var initResult = processor.Initialise(context, settings, string.Empty);
initResult.Should().BeTrue("Expecting true: processor should have been initialized successfully");
var result = processor.ProcessCoverageReports();
@@ -183,13 +189,17 @@ public void ReportProcessor_SingleUrlFound_DownloadedOk()
var context = CreateValidContext();
var settings = CreateValidSettings();
var logger = new TestLogger();
+ var testDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
+ Directory.CreateDirectory(testDir);
+
+ TestUtils.CreateTextFile(testDir, "sonar-project.properties", String.Empty);
downloader.CreateFileOnDownloadRequest = true;
var processor = new TfsLegacyCoverageReportProcessor(urlProvider, downloader, converter, logger);
// Act
- var initResult = processor.Initialise(context, settings);
+ var initResult = processor.Initialise(context, settings, testDir + "\\sonar-project.properties");
initResult.Should().BeTrue("Expecting true: processor should have been initialized successfully");
var result = processor.ProcessCoverageReports();
@@ -205,7 +215,9 @@ public void ReportProcessor_SingleUrlFound_DownloadedOk()
logger.AssertWarningsLogged(0);
logger.AssertErrorsLogged(0);
- context.LocalSettings.Should().Contain(x => x.Id == SonarProperties.VsCoverageXmlReportsPaths);
+ var linesWritten = File.ReadAllLines(testDir + "\\sonar-project.properties");
+
+ linesWritten[0].Should().Contain(SonarProperties.VsCoverageXmlReportsPaths);
}
#endregion Tests
@@ -216,8 +228,8 @@ private AnalysisConfig CreateValidContext()
{
var context = new AnalysisConfig()
{
- SonarOutputDir = TestUtils.CreateTestSpecificFolder(TestContext, "out"), // tests can write to this directory
- SonarConfigDir = TestUtils.CreateTestSpecificFolder(TestContext, "conf"), // we don't read anything from this directory, we just want it to be different from the output directory
+ SonarOutputDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "out"), // tests can write to this directory
+ SonarConfigDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "conf"), // we don't read anything from this directory, we just want it to be different from the output directory
LocalSettings = new AnalysisProperties(),
};
return context;
@@ -225,7 +237,7 @@ private AnalysisConfig CreateValidContext()
private TeamBuildSettings CreateValidSettings()
{
- return TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(TestUtils.CreateTestSpecificFolder(TestContext));
+ return TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext));
}
#endregion Private methods
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/CoverageReportProcessorTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/CoverageReportProcessorTests.cs
similarity index 93%
rename from Tests/SonarScanner.MSBuild.PostProcessor.Tests/CoverageReportProcessorTests.cs
rename to Tests/SonarScanner.MSBuild.TFS.Tests/CoverageReportProcessorTests.cs
index cde818c99..fad64f79e 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/CoverageReportProcessorTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/CoverageReportProcessorTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,12 +19,14 @@
*/
using System;
+using System.IO;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
using TestUtilities;
namespace SonarScanner.MSBuild.PostProcessor.Tests
@@ -76,7 +78,7 @@ public void Initialize_Checks_Arguments_For_Null()
{
// Arrange
var analysisConfig = new AnalysisConfig();
- Action act = () => processor.Initialise(analysisConfig, null);
+ Action act = () => processor.Initialise(analysisConfig, null, string.Empty);
// Act & Assert
act.Should().ThrowExactly().And.ParamName.Should().Be("settings");
@@ -92,7 +94,7 @@ public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsFalse_WhenProce
// Set up the factory to return a processor that returns success
var processorMock = new Mock();
- processorMock.Setup(x => x.Initialise(It.IsAny(), It.IsAny())).Returns(true);
+ processorMock.Setup(x => x.Initialise(It.IsAny(), It.IsAny(), It.IsAny())).Returns(true);
processorMock.Setup(x => x.ProcessCoverageReports()).Returns(true);
legacyFactoryMock.Setup(x => x.BuildTfsLegacyCoverageReportProcessor()).Returns(processorMock.Object);
@@ -101,7 +103,7 @@ public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsFalse_WhenProce
scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "false");
var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);
- testSubject.Initialise(analysisConfig, settingsMock);
+ testSubject.Initialise(analysisConfig, settingsMock, String.Empty);
// Act
var result = testSubject.ProcessCoverageReports();
@@ -109,7 +111,7 @@ public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsFalse_WhenProce
// Assert
result.Should().BeTrue();
legacyFactoryMock.Verify(x => x.BuildTfsLegacyCoverageReportProcessor(), Times.Once);
- processorMock.Verify(x => x.Initialise(It.IsAny(), It.IsAny()), Times.Once);
+ processorMock.Verify(x => x.Initialise(It.IsAny(), It.IsAny(), It.IsAny()), Times.Once);
processorMock.Verify(x => x.ProcessCoverageReports(), Times.Once);
}
}
@@ -127,7 +129,7 @@ public void ProcessCoverageReports_LegacyTeamBuild_SkipCoverageIsTrue_WhenProces
scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SkipLegacyCodeCoverage, "true");
var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);
- testSubject.Initialise(analysisConfig, settingsMock);
+ testSubject.Initialise(analysisConfig, settingsMock, String.Empty);
// Act
var result = false;
@@ -151,7 +153,7 @@ public void ProcessCoverageReports_Standalone_WhenProcess_ReturnsTrue()
var logger = new TestLogger();
var testSubject = new CoverageReportProcessor(legacyFactoryMock.Object, converterMock.Object, logger);
- testSubject.Initialise(analysisConfig, settings);
+ testSubject.Initialise(analysisConfig, settings, String.Empty);
// Act
var result = false;
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockBuildSettings.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockBuildSettings.cs
index 03e2bd7f2..80313613e 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockBuildSettings.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockBuildSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,7 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
namespace SonarScanner.MSBuild.TFS.Tests.Infrastructure
{
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockCodeCoverageProcessor.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockCodeCoverageProcessor.cs
similarity index 93%
rename from Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockCodeCoverageProcessor.cs
rename to Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockCodeCoverageProcessor.cs
index cd3c9b4c1..2a5f97d97 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockCodeCoverageProcessor.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockCodeCoverageProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,10 +20,9 @@
using FluentAssertions;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
-namespace SonarScanner.MSBuild.PostProcessor.Tests
+namespace SonarScanner.MSBuild.TFS.Tests
{
internal class MockCodeCoverageProcessor : ICoverageReportProcessor
{
@@ -39,7 +38,7 @@ internal class MockCodeCoverageProcessor : ICoverageReportProcessor
#region ICoverageReportProcessor interface
- public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings)
+ public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings, string propertiesFilePath)
{
initalisedCalled.Should().BeFalse("Expecting Initialize to be called only once");
initalisedCalled = true;
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs
similarity index 92%
rename from Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs
rename to Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs
index ee2a72c20..5c7708766 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockLegacyTeamBuildFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using SonarScanner.MSBuild.TFS;
-
-namespace SonarScanner.MSBuild.PostProcessorTests
+namespace SonarScanner.MSBuild.TFS.Tests
{
internal class MockLegacyTeamBuildFactory : ILegacyTeamBuildFactory
{
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportConverter.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportConverter.cs
index 69bd07023..206448c72 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportConverter.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportConverter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportDownloader.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportDownloader.cs
index 47910f70a..3e1e77275 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportDownloader.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportDownloader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportUrlProvider.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportUrlProvider.cs
index ec4b477a5..eac608186 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportUrlProvider.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockReportUrlProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSearchFallback.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSearchFallback.cs
index 3e61416c7..4073a829d 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSearchFallback.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSearchFallback.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSummaryReportBuilder.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSummaryReportBuilder.cs
similarity index 89%
rename from Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSummaryReportBuilder.cs
rename to Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSummaryReportBuilder.cs
index 4683d1aa0..5fa471acc 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/Infrastructure/MockSummaryReportBuilder.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Infrastructure/MockSummaryReportBuilder.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,8 +20,8 @@
using FluentAssertions;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.Shim;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild.PostProcessor.Tests
{
@@ -31,7 +31,7 @@ internal class MockSummaryReportBuilder : ISummaryReportBuilder
#region ISummaryReportBuilder interface
- public void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, ProjectInfoAnalysisResult result)
+ public void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, bool ranToCompletion, string fullPropertiesFilePath)
{
methodCalled.Should().BeFalse("Generate reports has already been called");
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/ProgramTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/ProgramTests.cs
new file mode 100644
index 000000000..ef1f4a73e
--- /dev/null
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/ProgramTests.cs
@@ -0,0 +1,129 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using System.IO;
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+using SonarScanner.MSBuild.Common;
+using TestUtilities;
+
+namespace SonarScanner.MSBuild.TFS.Classic.Tests
+{
+ [TestClass]
+ public class ProgramTests
+ {
+ [TestMethod]
+ public void Execute_WhenNoArgs_ShouldLogError()
+ {
+ var logger = new TestLogger();
+ var result = Program.Execute(new string[] { }, logger);
+
+ result.Should().Be(1);
+ logger.Warnings.Should().BeEmpty();
+ logger.Errors.Should().HaveCount(1);
+ logger.Errors.Should().Contain(new string[] { "No argument found. Exiting..." });
+ }
+
+ [TestMethod]
+ public void Execute_Method_Is_Uknown_Should_Log_Error()
+ {
+ var logger = new TestLogger();
+ var result = Program.Execute(new string[] { "MockMethod" }, logger);
+
+ result.Should().Be(1);
+ logger.Errors.Should().HaveCount(1);
+ logger.Errors.Should().Contain(new string[] { "Failed to parse or retrieve arguments for command line." });
+ }
+
+ [TestMethod]
+ public void Execute_ShouldExecute_CoverageConverter_ShouldSucceeed()
+ {
+ var logger = new TestLogger();
+ var tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())).FullName;
+ var text = @"
+
+ ";
+
+ File.WriteAllText(Path.Combine(tempDir, "temp.xml"), text);
+ File.WriteAllText(Path.Combine(tempDir, "sonar-project.properties"), string.Empty);
+
+
+ using (var scope = new EnvironmentVariableScope())
+ {
+ //Faking TeamBuild
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamFoundationBuild, "true");
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, "vsts://test/test");
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, tempDir);
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SourcesDirectory_TFS2015, tempDir);
+
+ var result = Program.Execute(new string[] { "ConvertCoverage", Path.Combine(tempDir, "temp.xml"), Path.Combine(tempDir, "sonar-project.properties") }, logger);
+
+ result.Should().Be(0);
+ logger.Errors.Should().HaveCount(0);
+ logger.InfoMessages.Should().Contain("Coverage report conversion completed successfully.");
+ }
+ }
+
+ [TestMethod]
+ public void Execute_ShouldExecute_SummaryReportBuilder_ShouldSucceeed()
+ {
+ var logger = new TestLogger();
+ var tempDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())).FullName;
+ var text = $@"
+
+ {tempDir}
+ http://localhost/
+ ";
+
+ File.WriteAllText(Path.Combine(tempDir, "temp.xml"), text);
+ File.WriteAllText(Path.Combine(tempDir, "sonar-project.properties"), string.Empty);
+
+ //Faking TeamBuild
+ Environment.SetEnvironmentVariable("TF_Build", "true");
+ Environment.SetEnvironmentVariable("BUILD_BUILDURI", "vsts://test/test");
+ Environment.SetEnvironmentVariable("AGENT_BUILDDIRECTORY", tempDir);
+ Environment.SetEnvironmentVariable("BUILD_SOURCESDIRECTORY", tempDir);
+
+ using (var scope = new EnvironmentVariableScope())
+ {
+ //Faking TeamBuild
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.IsInTeamFoundationBuild, "true");
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildUri_TFS2015, "vsts://test/test");
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.BuildDirectory_TFS2015, tempDir);
+ scope.SetVariable(TeamBuildSettings.EnvironmentVariables.SourcesDirectory_TFS2015, tempDir);
+
+ var result = Program.Execute(new string[] { "SummaryReportBuilder", Path.Combine(tempDir, "temp.xml"), Path.Combine(tempDir, "sonar-project.properties"), "true" }, logger);
+
+ result.Should().Be(0);
+ logger.Errors.Should().HaveCount(1);
+ logger.Errors.Should().Contain(@"The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
+Possible causes:
+ 1. The project has not been built - the project must be built in between the begin and end steps
+ 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
+ 3. The begin, build and end steps have not all been launched from the same folder
+ 4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)");
+ }
+ }
+ }
+}
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/Properties/AssemblyInfo.cs
index ace78f84f..0ac874857 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/SonarScanner.MSBuild.TFS.Tests.csproj b/Tests/SonarScanner.MSBuild.TFS.Tests/SonarScanner.MSBuild.TFS.Tests.csproj
index 9bba1bef9..fdc4b8f1d 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/SonarScanner.MSBuild.TFS.Tests.csproj
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/SonarScanner.MSBuild.TFS.Tests.csproj
@@ -44,6 +44,9 @@
..\..\packages\FluentAssertions.5.9.0\lib\net47\FluentAssertions.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+ ..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.11.2273\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dllFalse
@@ -53,8 +56,11 @@
-
- ..\..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll
+
+ ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -68,11 +74,7 @@
-
-
-
-
-
+
@@ -86,12 +88,18 @@
+
+
+
+
+
+
@@ -100,12 +108,16 @@
{e312fdbb-bc13-4559-8f21-76ca5b88ebc5}SonarScanner.MSBuild.Common
+
+ {ec07bb1b-219c-46df-9079-ad74ca929697}
+ SonarScanner.MSBuild.Shim
+
- {c3466723-5499-4fad-b236-5c96094de276}
+ {aeff9994-48e2-4d7a-9c97-641e3db82411}SonarScanner.MSBuild.TFS.Classic
- {66ce9491-1c14-45d2-beb6-a0695c63ebb2}
+ {cefbb4ad-d00d-4b55-9b19-88f3b3235966}SonarScanner.MSBuild.TFS
diff --git a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SummaryReportBuilderTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/SummaryReportBuilderTests.cs
similarity index 96%
rename from Tests/SonarScanner.MSBuild.PostProcessor.Tests/SummaryReportBuilderTests.cs
rename to Tests/SonarScanner.MSBuild.TFS.Tests/SummaryReportBuilderTests.cs
index 792af7641..55dd8cbfd 100644
--- a/Tests/SonarScanner.MSBuild.PostProcessor.Tests/SummaryReportBuilderTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/SummaryReportBuilderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,19 +20,15 @@
using System;
using System.Collections.Generic;
-using System.IO;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.PostProcessor;
-using SonarScanner.MSBuild.PostProcessor.Tests;
+using SonarScanner.MSBuild.Common.TFS;
using SonarScanner.MSBuild.Shim;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Classic.XamlBuild;
using TestUtilities;
-namespace SonarScanner.MSBuild.PostProcessorTests
+namespace SonarScanner.MSBuild.TFS.Tests
{
[TestClass]
public class SummaryReportBuilderTests
@@ -175,7 +171,7 @@ public void Deprecated_Warning_Logged_On_XAML_Build()
config.SonarOutputDir = TestContext.TestDeploymentDir; // this will be cleaned up by VS when there are too many results
// Act
- builder.GenerateReports(settings, config, result);
+ builder.GenerateReports(settings, config, result.RanToCompletion, result.FullPropertiesFilePath);
// Assert
summaryLogger.Messages[0].Should().Be("** WARNING: Support for XAML builds is deprecated since version 4.1 and will be removed in version 5.0 of the Scanner for MSBuild **");
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/TeamBuildSettingsTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/TeamBuildSettingsTests.cs
index 0fe940c16..a3af1f405 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/TeamBuildSettingsTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/TeamBuildSettingsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Common.TFS;
using TestUtilities;
namespace SonarScanner.MSBuild.TFS.Tests
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/TrxFileReaderTests.cs b/Tests/SonarScanner.MSBuild.TFS.Tests/TrxFileReaderTests.cs
index b7defa0e7..9b89821ad 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/TrxFileReaderTests.cs
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/TrxFileReaderTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -45,7 +45,7 @@ public class TrxFileReaderTests
/// we don't create actual files, but regardless we still use test-specific folders.
///
private string RootDirectory =>
- TestUtils.CreateTestSpecificFolder(TestContext);
+ TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
[TestInitialize]
public void TestInitialize()
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/app.config b/Tests/SonarScanner.MSBuild.TFS.Tests/app.config
index 557095a4b..9d688d54a 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/app.config
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/app.config
@@ -1,11 +1,19 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/Tests/SonarScanner.MSBuild.TFS.Tests/packages.config b/Tests/SonarScanner.MSBuild.TFS.Tests/packages.config
index f4283e38a..a664e161a 100644
--- a/Tests/SonarScanner.MSBuild.TFS.Tests/packages.config
+++ b/Tests/SonarScanner.MSBuild.TFS.Tests/packages.config
@@ -5,6 +5,7 @@
-
+
+
\ No newline at end of file
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/E2ETests/E2EAnalysisTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/E2ETests/E2EAnalysisTests.cs
index c871a4bad..cb17fac1b 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/E2ETests/E2EAnalysisTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/E2ETests/E2EAnalysisTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -49,8 +49,8 @@ public void E2E_OutputFolderStructure()
// Checks the output folder structure is correct for a simple solution
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var codeFilePath = CreateEmptyFile(rootInputFolder, "codeFile1.txt");
var projectXml = $@"
@@ -76,20 +76,20 @@ public void E2E_OutputFolderStructure()
TargetConstants.WriteProjectDataTarget);
var projectSpecificOutputDir = CheckProjectSpecificOutputStructure(rootOutputFolder);
- var actualProjectInfo = CheckProjectInfoExists(projectSpecificOutputDir);
+ CheckProjectInfoExists(projectSpecificOutputDir);
}
[TestMethod]
[TestCategory("E2E"), TestCategory("Targets")]
[Description("Tests that projects with missing project guids are handled correctly")]
- public void E2E_MissingProjectGuid()
+ public void E2E_MissingProjectGuid_ShouldGenerateRandomOne()
{
// Projects with missing guids should have a warning emitted. The project info
// should still be generated.
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Include a compilable file to avoid warnings about no files
var codeFilePath = CreateEmptyFile(rootInputFolder, "codeFile1.txt");
@@ -112,13 +112,10 @@ public void E2E_MissingProjectGuid()
var projectSpecificOutputDir = CheckProjectSpecificOutputStructure(rootOutputFolder);
var actualProjectInfo = CheckProjectInfoExists(projectSpecificOutputDir);
- actualProjectInfo.ProjectGuid.Should().Be(Guid.Empty);
-
- result.AssertExpectedErrorCount(0);
- result.AssertExpectedWarningCount(1);
+ actualProjectInfo.ProjectGuid.Should().NotBeEmpty();
+ actualProjectInfo.ProjectGuid.Should().NotBe(Guid.Empty);
- var warning = result.Warnings[0];
- warning.Should().Contain(projectFilePath, "Expecting the warning to contain the full path to the bad project file");
+ result.AssertNoWarningsOrErrors();
}
[TestMethod]
@@ -130,8 +127,8 @@ public void E2E_InvalidGuid()
// should not be generated.
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Include a compilable file to avoid warnings about no files
var codeFilePath = CreateEmptyFile(rootInputFolder, "codeFile1.txt");
@@ -168,8 +165,8 @@ public void E2E_InvalidGuid()
public void E2E_HasAnalyzableFiles()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Mix of analyzable and non-analyzable files
var none1 = CreateEmptyFile(rootInputFolder, "none1.txt");
@@ -208,7 +205,7 @@ public void E2E_HasAnalyzableFiles()
// Check the list of files to be analyzed
var expectedFilesToAnalyzeFilePath = AssertFileExists(projectSpecificOutputDir, ExpectedAnalysisFilesListFileName);
var fileList = File.ReadLines(expectedFilesToAnalyzeFilePath);
- fileList.Should().BeEquivalentTo(new string []
+ fileList.Should().BeEquivalentTo(new string[]
{
rootInputFolder + "\\none1.txt",
rootInputFolder + "\\content1.txt",
@@ -233,8 +230,8 @@ public void E2E_HasAnalyzableFiles()
public void E2E_NoAnalyzableFiles()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Only non-analyzable files
var foo1 = CreateEmptyFile(rootInputFolder, "foo1.txt");
@@ -269,8 +266,8 @@ public void E2E_NoAnalyzableFiles()
public void E2E_HasManagedAndContentFiles_VB()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Mix of analyzable and non-analyzable files
var none1 = CreateEmptyFile(rootInputFolder, "none1.txt");
@@ -311,20 +308,20 @@ public void E2E_HasManagedAndContentFiles_VB()
var actualFilesToAnalyze = actualProjectInfo.AssertAnalysisResultExists("FilesToAnalyze");
actualFilesToAnalyze.Location.Should().Be(expectedFilesToAnalyzeFilePath);
}
-
+
[TestMethod]
[TestCategory("E2E"), TestCategory("Targets")] // SONARMSBRU-104: files under the obj folder should be excluded from analysis
public void E2E_IntermediateOutputFilesAreExcluded()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext);
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Add files that should be analyzed
var nonObjFolder = Path.Combine(rootInputFolder, "foo");
Directory.CreateDirectory(nonObjFolder);
- var compile1 = CreateEmptyFile(rootInputFolder, "compile1.cs");
- var foo_compile2 = CreateEmptyFile(nonObjFolder, "compile2.cs");
+ var compile1 = CreateEmptyFile(rootInputFolder, "compile1.cs");
+ CreateEmptyFile(nonObjFolder, "compile2.cs");
// Add files under the obj folder that should not be analyzed
var objFolder = Path.Combine(rootInputFolder, "obj");
@@ -337,7 +334,7 @@ public void E2E_IntermediateOutputFilesAreExcluded()
var objFile = CreateEmptyFile(objFolder, "objFile1.cs");
// File in obj\debug
- var objDebugFile = CreateEmptyFile(objSubFolder1, "objDebugFile1.cs");
+ CreateEmptyFile(objSubFolder1, "objDebugFile1.cs");
// File in obj\xxx
var objFooFile = CreateEmptyFile(objSubFolder2, "objFooFile.cs");
@@ -375,8 +372,8 @@ public void E2E_IntermediateOutputFilesAreExcluded()
public void E2E_UsingTaskHandlesBracketsInName()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "folder with brackets in name (SONARMSBRU-12)");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "folder with brackets in name (SONARMSBRU-12)");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Copy the task assembly and supporting assemblies to a folder with brackets in the name
var taskAssemblyFilePath = typeof(WriteProjectInfoFile).Assembly.Location;
@@ -417,7 +414,7 @@ public void E2E_UsingTaskHandlesBracketsInName()
fileList.Should().BeEquivalentTo(rootInputFolder + "\\code1.vb");
// Check the projectInfo.xml file points to the file containing the list of files to analyze
- var actualProjectInfo = CheckProjectInfoExists(projectSpecificOutputDir);
+ CheckProjectInfoExists(projectSpecificOutputDir);
}
[TestMethod]
@@ -426,8 +423,8 @@ public void E2E_ExcludedProjects()
{
// Project info should still be written for files with $(SonarQubeExclude) set to true
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Mix of analyzable and non-analyzable files
var foo1 = CreateEmptyFile(rootInputFolder, "foo1.txt");
@@ -476,8 +473,8 @@ public void E2E_BareProject_FilesToAnalyse()
// The project info should be created as normal and the correct files to analyze detected.
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(TestContext);
var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
@@ -563,8 +560,8 @@ public void E2E_BareProject_CorrectlyCategorised()
// processed correctly e.g. can be excluded, marked as test projects etc
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(TestContext);
var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
@@ -669,8 +666,8 @@ private BuildLog Execute_E2E_TestProjects_ProtobufsUpdated(bool isTestProject, s
// as expected, depending on the type of the project being built.
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var code1 = CreateEmptyFile(rootInputFolder, "code1.cs");
@@ -743,7 +740,7 @@ private static string CreateFile(string folder, string fileName, string content)
private string CreateProjectFile(string testSpecificProjectXml, string sonarQubeOutputPath, bool isVB = false)
{
- var projectDirectory = TestUtils.CreateTestSpecificFolder(TestContext);
+ var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var language = isVB ? "VB" : "C#";
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildAssertions.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildAssertions.cs
index 6620b4549..79c91b01d 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildAssertions.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildAssertions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildUtilities.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildUtilities.cs
index 36f1c9bb9..d3b04a6fb 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildUtilities.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/BuildUtilities.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/TargetConstants.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/TargetConstants.cs
index 673ce1e61..d14ddcbdb 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/TargetConstants.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/TargetConstants.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/WellKnownProjectProperties.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/WellKnownProjectProperties.cs
index ad19e5057..a763f3c2f 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/WellKnownProjectProperties.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Infrastructure/WellKnownProjectProperties.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildLogAssertions.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildLogAssertions.cs
index 016819258..85477d000 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildLogAssertions.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildLogAssertions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildRunner.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildRunner.cs
index d765b3749..529cdb254 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildRunner.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/BuildRunner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/MSBuildLocator.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/MSBuildLocator.cs
index 2b4075808..8a1adfc7d 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/MSBuildLocator.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/MSBuildLocator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/SimpleXmlLogger.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/SimpleXmlLogger.cs
index 2787fbc2a..a23d28288 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/SimpleXmlLogger.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/MSBuildExecution/SimpleXmlLogger.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Properties/AssemblyInfo.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Properties/AssemblyInfo.cs
index a1b0e406c..620593c9f 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Properties/AssemblyInfo.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/SonarScanner.MSBuild.Tasks.IntegrationTests.csproj b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/SonarScanner.MSBuild.Tasks.IntegrationTests.csproj
index 2afc73c13..74094f26d 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/SonarScanner.MSBuild.Tasks.IntegrationTests.csproj
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/SonarScanner.MSBuild.Tasks.IntegrationTests.csproj
@@ -53,57 +53,63 @@
..\..\packages\Microsoft.Build.Utilities.Core.16.3.0\lib\net472\Microsoft.Build.Utilities.Core.dll
+
+ ..\Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
+ ..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.16.30\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dllTrue
-
- ..\..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll
+
+ ..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
-
- ..\..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll
+
+ ..\..\packages\System.Collections.Immutable.1.7.1\lib\net461\System.Collections.Immutable.dll..\..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dllTrue
- True..\..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dllTrue
- True
- ..\..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll
+ ..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
-
- ..\..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll
+
+ ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
-
- ..\..\packages\System.Resources.Extensions.4.6.0\lib\netstandard2.0\System.Resources.Extensions.dll
+
+ ..\..\packages\System.Reflection.Metadata.1.8.1\lib\net461\System.Reflection.Metadata.dll
+
+
+ ..\..\packages\System.Resources.Extensions.4.7.1\lib\net461\System.Resources.Extensions.dll..\..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dllTrue
- True
-
- ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
+
+ ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll..\..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dllTrue
- True
-
- ..\..\packages\System.Threading.Tasks.Dataflow.4.9.0\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll
+
+ ..\..\packages\System.Threading.Tasks.Dataflow.4.11.1\lib\net461\System.Threading.Tasks.Dataflow.dll
+
+
+ ..\..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll
+ True..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll
@@ -113,28 +119,9 @@
-
- ..\..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll
- True
-
-
- ..\..\packages\System.Threading.Thread.4.0.0\lib\net46\System.Threading.Thread.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
Properties\AssemblyInfo.Shared.cs
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/ImportBeforeTargetsTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/ImportBeforeTargetsTests.cs
index 86f6d0ee5..6cdc8ea11 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/ImportBeforeTargetsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/ImportBeforeTargetsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -216,7 +216,7 @@ private string EnsureDummyIntegrationTargetsFileExists()
// This can't just be in the TestContext.DeploymentDirectory as this will
// be shared with other tests, and some of those tests might be deploying
// the real analysis targets to that location.
- var testSpecificDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testSpecificDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var fullPath = Path.Combine(testSpecificDir, TargetConstants.AnalysisTargetFile);
if (!File.Exists(fullPath))
@@ -237,10 +237,10 @@ private string EnsureDummyIntegrationTargetsFileExists()
private string CreateProjectFile(string testSpecificProjectXml)
{
- var projectDirectory = TestUtils.CreateTestSpecificFolder(TestContext);
+ var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
// Locate the real "ImportsBefore" target file
- var importsBeforeTargets = Path.Combine(TestUtils.CreateTestSpecificFolder(TestContext), TargetConstants.ImportsBeforeFile);
+ var importsBeforeTargets = Path.Combine(TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext), TargetConstants.ImportsBeforeFile);
File.Exists(importsBeforeTargets).Should().BeTrue("Test error: the SonarQube imports before target file does not exist. Path: {0}", importsBeforeTargets);
var template = @"
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/RoslynTargetsTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/RoslynTargetsTests.cs
index 6c5b8123d..81fd2f1f3 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/RoslynTargetsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/RoslynTargetsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +23,6 @@
using System.IO;
using System.Linq;
using FluentAssertions;
-using Microsoft.Build.Construction;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SonarScanner.MSBuild.Common;
using TestUtilities;
@@ -33,8 +32,8 @@ namespace SonarScanner.MSBuild.Tasks.IntegrationTests.TargetsTests
[TestClass]
public class RoslynTargetsTests
{
- private const string RoslynAnalysisResultsSettingName = "sonar.cs.roslyn.reportFilePath";
- private const string AnalyzerWorkDirectoryResultsSettingName = "sonar.cs.analyzer.projectOutPath";
+ private const string RoslynAnalysisResultsSettingName = "sonar.cs.roslyn.reportFilePaths";
+ private const string AnalyzerWorkDirectoryResultsSettingName = "sonar.cs.analyzer.projectOutPaths";
private const string ErrorLogFilePattern = "{0}.RoslynCA.json";
public TestContext TestContext { get; set; }
@@ -135,11 +134,12 @@ public BuildLog Execute_Roslyn_Settings_ValidSetup(bool isTestProject, string ms
// Arrange
// Set the config directory so the targets know where to look for the analysis config file
- var confDir = TestUtils.CreateTestSpecificFolder(TestContext, "config");
+ var confDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "config");
// Create a valid config file containing analyzer settings for both VB and C#
var config = new AnalysisConfig
{
+ SonarQubeHostUrl = "http://sonarqube.com",
SonarQubeVersion = "7.3", // legacy behaviour i.e. overwrite existing analyzer settings
AnalyzersSettings = new List
{
@@ -215,6 +215,7 @@ public void Roslyn_Settings_ValidSetup_LegacyServer_Override_Analyzers()
// Create a valid config containing analyzer settings
var config = new AnalysisConfig
{
+ SonarQubeHostUrl = "http://sonarqube.com",
SonarQubeVersion = "6.7", // legacy version
AnalyzersSettings = new List
{
@@ -289,7 +290,7 @@ public void Roslyn_Settings_ValidSetup_NonLegacyServer_MergeSettings()
{
// Arrange
- var dir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var dir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var dummyQpRulesetPath = TestUtils.CreateValidEmptyRuleset(dir, "dummyQp");
// Create a valid config containing analyzer settings
@@ -380,7 +381,7 @@ public void Roslyn_Settings_LanguageMissing_NoError()
// Arrange
// Set the config directory so the targets know where to look for the analysis config file
- var confDir = TestUtils.CreateTestSpecificFolder(TestContext, "config");
+ var confDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "config");
// Create a valid config file that does not contain analyzer settings
var config = new AnalysisConfig();
@@ -432,7 +433,7 @@ public void Roslyn_Settings_SettingsMissing_NoError()
// Arrange
// Set the config directory so the targets know where to look for the analysis config file
- var confDir = TestUtils.CreateTestSpecificFolder(TestContext, "config");
+ var confDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "config");
// Create a valid config file that does not contain analyzer settings
var config = new AnalysisConfig();
@@ -587,7 +588,7 @@ public void Roslyn_SetResults_TempFolderIsNotSet()
public void Roslyn_SetResults_ResultsFileDoesNotExist()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
var projectSnippet = $@"
@@ -609,7 +610,7 @@ public void Roslyn_SetResults_ResultsFileDoesNotExist()
public void Roslyn_SetResults_ResultsFileExists()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
var resultsFile = TestUtils.CreateTextFile(rootInputFolder, "error.report.txt", "dummy report content");
var projectSnippet = $@"
@@ -639,7 +640,7 @@ public void Roslyn_SetResults_ResultsFileExists()
public void Roslyn_SetResults_BothResultsFilesCreated()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
var resultsFile = TestUtils.CreateTextFile(rootInputFolder, "error.report.txt", "dummy report content");
var razorResultsFile = TestUtils.CreateTextFile(rootInputFolder, "razor.error.report.txt", "dummy report content");
@@ -676,8 +677,8 @@ public void Roslyn_SetResults_BothResultsFilesCreated()
public void Roslyn_TargetExecutionOrder()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// We need to set the CodeAnalyisRuleSet property if we want ResolveCodeAnalysisRuleSet
// to be executed. See test bug https://github.com/SonarSource/sonar-scanner-msbuild/issues/776
@@ -836,7 +837,7 @@ private static void AssertExpectedAnalysisSetting(BuildLog actualResult, string
///
private string CreateProjectFile(AnalysisConfig analysisConfig, string testSpecificProjectXml)
{
- var projectDirectory = TestUtils.CreateTestSpecificFolder(TestContext);
+ var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
CreateCaptureDataTargetsFile(projectDirectory);
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarIntegrationTargetsTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarIntegrationTargetsTests.cs
index 7a85ce4b0..6038470d9 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarIntegrationTargetsTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarIntegrationTargetsTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -171,7 +171,7 @@ public void IntTargets_SonarPaths_OutputAndConfigPathsAreSet()
public static string CreateProjectFile(TestContext testContext, string testSpecificProjectXml)
{
- var projectDirectory = TestUtils.CreateTestSpecificFolder(testContext);
+ var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(testContext);
var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(testContext);
File.Exists(sqTargetFile).Should().BeTrue("Test error: the SonarQube analysis targets file could not be found. Full path: {0}", sqTargetFile);
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarQubeCategoriseProjectTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarQubeCategoriseProjectTests.cs
index 77fb27796..40b981fc7 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarQubeCategoriseProjectTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/SonarQubeCategoriseProjectTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -419,7 +419,7 @@ private BuildLog BuildAndRunTarget(string projectFileName, string projectXmlSnip
private string CreateProjectFile(string projectFileName, string xmlSnippet, string analysisConfigDir)
{
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(TestContext);
var projectFilePath = Path.Combine(rootInputFolder, projectFileName);
@@ -477,7 +477,7 @@ private string CreateAnalysisConfigWithRegEx(string regExExpression)
};
}
- var testDir = TestUtils.CreateTestSpecificFolder(TestContext);
+ var testDir = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
var fullPath = Path.Combine(testDir, "SonarQubeAnalysisConfig.xml");
if (File.Exists(fullPath))
{
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/WriteProjectInfoFileTargetTests.cs b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/WriteProjectInfoFileTargetTests.cs
index 2a5e04a56..33bbaac1e 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/WriteProjectInfoFileTargetTests.cs
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/TargetsTests/WriteProjectInfoFileTargetTests.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -44,8 +44,8 @@ public void WriteProjectInfo_AnalysisFileList_NoFiles()
// The content file list should not be created if there are no files
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var projectFilePath = CreateProjectFile(null, null, rootOutputFolder);
@@ -64,7 +64,7 @@ public void WriteProjectInfo_AnalysisFileList_HasFiles()
// The analysis file list should be created with the expected files
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -114,7 +114,7 @@ public void WriteProjectInfo_AnalysisFileList_AutoGenFilesIgnored()
// The content file list should not include items with true metadata
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -169,7 +169,7 @@ public void WriteProjectInfo_AnalysisFileList_FilesTypes_Defaults()
// Check that all default item types are included for analysis
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -220,7 +220,7 @@ public void WriteProjectInfo_AnalysisFileList_FilesTypes_PageAndApplicationDefin
// Check that all default item types are included for analysis
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -265,7 +265,7 @@ public void WriteProjectInfo_AnalysisFileList_FilesTypes_PageAndApplicationDefin
public void WriteProjectInfo_AnalysisFileList_FilesTypes_OnlySpecified()
{
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -305,7 +305,7 @@ public void WriteProjectInfo_AnalysisFileList_FilesTypes_OnlySpecified()
public void WriteProjectInfo_AnalysisFileList_FilesTypes_SpecifiedPlusDefaults()
{
// Arrange
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
// Note: the included/excluded files don't actually have to exist
string projectXml = $@"
@@ -353,8 +353,8 @@ public void WriteProjectInfo_IsNotTestAndNotExcluded()
// correctly set for "normal" projects
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var analysisConfig = new AnalysisConfig
{
LocalSettings = new AnalysisProperties
@@ -382,8 +382,8 @@ public void WriteProjectInfo_IsTestAndIsExcluded()
// both values should be set to true.
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var analysisConfig = new AnalysisConfig
{
LocalSettings = new AnalysisProperties
@@ -412,8 +412,8 @@ public void WriteProjectInfo_IsTestAndIsExcluded()
public void WriteProjectInfo_ProjectWithCodePage()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var analysisConfig = new AnalysisConfig
{
LocalSettings = new AnalysisProperties
@@ -441,8 +441,8 @@ public void WriteProjectInfo_ProjectWithCodePage()
public void WriteProjectInfo_ProjectWithNoCodePage()
{
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
string projectXml = $@"
@@ -464,8 +464,8 @@ public void WriteProjectInfo_AnalysisSettings()
{
// Check analysis settings are correctly passed from the targets to the task
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
string projectXml = $@"
@@ -513,8 +513,8 @@ public void WriteProjectInfo_BareProject()
// that don't import the standard targets or set the expected properties
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ var rootInputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Inputs");
+ var rootOutputFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext, "Outputs");
var sqTargetFile = TestUtils.EnsureAnalysisTargetsExists(TestContext);
var projectFilePath = Path.Combine(rootInputFolder, "project.txt");
@@ -562,8 +562,8 @@ public void WriteProjectInfo_UnrecognisedLanguage()
// Checks the WriteProjectInfo target handles projects with unrecognized languages
// Arrange
- var rootInputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Inputs");
- var rootOutputFolder = TestUtils.CreateTestSpecificFolder(TestContext, "Outputs");
+ 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");
@@ -636,7 +636,7 @@ private ProjectInfo ExecuteWriteProjectInfo(string projectFilePath, string rootO
private string CreateProjectFile(AnalysisConfig analysisConfig, string testSpecificProjectXml, string sonarQubeOutputPath)
{
- var projectDirectory = TestUtils.CreateTestSpecificFolder(TestContext);
+ var projectDirectory = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
if (analysisConfig != null)
{
diff --git a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/app.config b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/app.config
index 9cea7a3fb..321dca40b 100644
--- a/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/app.config
+++ b/Tests/SonarScanner.MSBuild.Tasks.IntegrationTests/app.config
@@ -1,4 +1,4 @@
-
+
- msbuild-sonarqube-runner
- [Deprecated] SonarQube Scanner for MSBuild
- 4.3.0
+ sonarscanner-msbuild-net50
+ 1.0.0
+ SonarScanner for MSBuild .Net 5.0SonarSource,MicrosoftSonarSource
- The SonarScanner for MSBuild allows easy analysis of any .NET project with SonarCloud/SonarQube.
- The SonarScanner for MSBuild allows easy analysis of any .NET project with SonarCloud/SonarQube.http://redirect.sonarsource.com/doc/msbuild-sq-runner.htmlhttps://github.com/SonarSource/sonar-scanner-msbuildhttps://github.com/SonarSource/sonar-scanner-msbuild/tree/master/nuspec/chocolatey
- sonarqube sonarcloud msbuild scanner sonarsource sonar sonar-scanner sonarscanner
- SonarSource SA and Microsoft Corporation
+ https://cdn.rawgit.com/SonarSource/sonar-scanner-msbuild/cdd1f588/icon.pnghttps://github.com/SonarSource/sonar-scanner-msbuild/blob/master/LICENSE.txt
- false
-
-This package was deprecated and split into 2 packages. One for .net core usage (id: sonarscanner-msbuild-netcoreapp2.0) and one for classic .net usage (id: sonarscanner-msbuild-net46).
- https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.htmlhttps://community.sonarsource.com/https://github.com/SonarSource/sonar-scanner-msbuild/issues
-
-
-
+ false
+ The SonarScanner for MSBuild allows easy analysis of any .NET project with SonarCloud/SonarQube.
+ The SonarScanner for MSBuild allows easy analysis of any .NET project with SonarCloud/SonarQube.
+ sonarqube sonarcloud msbuild scanner sonarsource sonar sonar-scanner sonarscanner
+ SonarSource SA and Microsoft Corporation
+
+All release notes for SonarScanner MSBuild .Net Core can be found on the GitHub site - https://github.com/SonarSource/sonar-scanner-msbuild/releases
+
-
+
+
+
diff --git a/nuspec/netcoreglobaltool/dotnet-sonarscanner.nuspec b/nuspec/netcoreglobaltool/dotnet-sonarscanner.nuspec
index dfd9e2085..cc62d4ceb 100644
--- a/nuspec/netcoreglobaltool/dotnet-sonarscanner.nuspec
+++ b/nuspec/netcoreglobaltool/dotnet-sonarscanner.nuspec
@@ -21,14 +21,17 @@ All release notes for SonarScanner .Net Core can be found on the GitHub site - h
-
+
+
-
-
+
+
+
-
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9b9335c62..bb0f9369d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,15 +4,15 @@
org.sonarsource.parentparent
- 53
+ 54org.sonarsource.scanner.msbuildsonar-scanner-msbuild
- 4.11-SNAPSHOT
+ 5.0-SNAPSHOTpom
- SonarQube.Scanner.MSBuild
+ SonarScanner.MSBuildhttp://redirect.sonarsource.com/doc/msbuild-sq-runner.html2016
@@ -45,7 +45,7 @@
truesonar-scanner-msbuild
- ${project.groupId}:${project.artifactId}:zip:net46,${project.groupId}:${project.artifactId}:zip:netcoreapp2.0,${project.groupId}:${project.artifactId}:zip:netcoreapp3.0
+ ${project.groupId}:${project.artifactId}:zip:net46,${project.groupId}:${project.artifactId}:zip:netcoreapp2.0,${project.groupId}:${project.artifactId}:zip:netcoreapp3.0,${project.groupId}:${project.artifactId}:zip:net5.0
@@ -72,6 +72,16 @@
dotnetScannerZipPathzipnetcoreapp2.0
+
+
+ dotnet3ScannerZipPath
+ zip
+ netcoreapp3.0
+
+
+ dotnet5ScannerZipPath
+ zip
+ net5.0dotnetScannerGlobalToolPath
@@ -92,6 +102,11 @@
nupkgnetcoreapp3.0
+
+ dotnet5ScannerChocoPath
+ nupkg
+ net5.0
+
diff --git a/scripts/build-utils.ps1 b/scripts/build-utils.ps1
new file mode 100644
index 000000000..9925202ca
--- /dev/null
+++ b/scripts/build-utils.ps1
@@ -0,0 +1,155 @@
+. (Join-Path $PSScriptRoot "utils.ps1")
+
+function Get-NuGetPath {
+ return Get-ExecutablePath -name "nuget.exe" -envVar "NUGET_PATH"
+}
+
+function Get-VsWherePath {
+ return Get-ExecutablePath -name "vswhere.exe" -envVar "VSWHERE_PATH"
+}
+
+function Get-MsBuildPath() {
+
+ Write-Debug "Trying to find 'msbuild.exe' using 'MSBUILD_PATH' environment variable"
+ $msbuildEnv = "MSBUILD_PATH"
+ $msbuildPath = [environment]::GetEnvironmentVariable($msbuildEnv, "Process")
+
+ if (!$msbuildPath) {
+ Write-Debug "Environment variable not found"
+ Write-Debug "Trying to find path using 'vswhere.exe'"
+
+ # Sets the path to MSBuild 15 into an the MSBUILD_PATH environment variable
+ # All subsequent builds after this command will use MSBuild 15!
+ # Test if vswhere.exe is in your path. Download from: https://github.com/Microsoft/vswhere/releases
+ $path = "C:\\Program Files (x86)\Microsoft Visual Studio\2019\Community"
+ if ($path) {
+ $msbuildPath = Join-Path $path "MSBuild\Current\Bin\MSBuild.exe"
+ [environment]::SetEnvironmentVariable($msbuildEnv, $msbuildPath)
+ }
+ }
+
+ if (Test-Path $msbuildPath) {
+ Write-Debug "Found 'msbuild.exe' at '${msbuildPath}'"
+ return $msbuildPath
+ }
+
+ throw "'msbuild.exe' located at '${msbuildPath}' doesn't exist"
+}
+
+function Get-VsTestPath {
+ return Get-ExecutablePath -name "VSTest.Console.exe" -envVar "VSTEST_PATH"
+}
+
+function Get-CodeCoveragePath {
+ $vstest_exe = Get-VsTestPath
+ $codeCoverageDirectory = Join-Path (Get-ChildItem $vstest_exe).Directory "..\..\..\..\.."
+ return Get-ExecutablePath -name "CodeCoverage.exe" -directory $codeCoverageDirectory -envVar "CODE_COVERAGE_PATH"
+}
+
+# NuGet
+function Restore-Packages (
+ [Parameter(Mandatory = $true, Position = 0)][ValidateSet("14.0", "15.0")][string]$msbuildVersion,
+ [Parameter(Mandatory = $true, Position = 1)][string]$solutionPath) {
+
+ $solutionName = Split-Path $solutionPath -Leaf
+ Write-Header "Restoring NuGet packages for ${solutionName}"
+
+ $msbuildBinDir = Split-Path -Parent (Get-MsBuildPath $msbuildVersion)
+
+ # see https://github.com/Microsoft/vsts-tasks/issues/3762
+ # it seems for mixed .net standard and .net framework, we need both dotnet restore and nuget restore...
+ if (Test-Debug) {
+ Exec { & (Get-NuGetPath) restore $solutionPath -MSBuildPath $msbuildBinDir -Verbosity detailed `
+ } -errorMessage "ERROR: Restoring NuGet packages FAILED."
+ Exec { & dotnet restore $solutionPath `
+ } -
+ }
+ else {
+ Exec { & (Get-NuGetPath) restore $solutionPath -MSBuildPath $msbuildBinDir `
+ } -errorMessage "ERROR: Restoring NuGet packages with nuget FAILED."
+ Exec { & dotnet restore $solutionPath `
+ } -errorMessage "ERROR: Restoring NuGet packages with dotnet FAILED."
+ }
+}
+
+# Build
+function Invoke-MSBuild (
+ [Parameter(Mandatory = $true, Position = 0)][string]$solutionPath,
+ [parameter(ValueFromRemainingArguments = $true)][array]$remainingArgs) {
+
+ $solutionName = Split-Path $solutionPath -leaf
+ Write-Header "Building solution ${solutionName}"
+
+ if (Test-Debug) {
+ $remainingArgs += "/v:detailed"
+ }
+ else {
+ $remainingArgs += "/v:quiet"
+ }
+
+ $msbuildExe = Get-MsBuildPath
+ Exec { & $msbuildExe $solutionPath $remainingArgs `
+ } -errorMessage "ERROR: Build FAILED."
+}
+
+# Tests
+function Clear-TestResults() {
+ If (Test-Path TestResults){
+ Remove-Item TestResults -Recurse
+ }
+}
+
+function Clear-ExtraFiles() {
+ # Clean up extra test results
+ Get-ChildItem -path "TestResults" -Recurse -Include *.trx `
+ | Where-Object { $_ -Match ".+\\.+\.trx" } `
+ | Remove-Item
+ Get-ChildItem -path "TestResults" -Recurse -Include *.coverage `
+ | Where-Object { $_ -NotMatch "([a-f0-9]+[-])+[a-f0-9]+\\" } `
+ | Remove-Item
+}
+
+function Invoke-UnitTests([string]$binPath, [bool]$failsIfNotTest) {
+ Write-Header "Running unit tests"
+
+ Clear-TestResults
+
+ Write-Debug "Running unit tests for"
+ $testFiles = @()
+ $testDirs = @()
+ Get-ChildItem ".\tests" -Recurse -Include "*Tests.dll" `
+ | Where-Object { $_.DirectoryName -Match "bin" } `
+ | ForEach-Object {
+ $currentFile = $_
+ Write-Debug " - ${currentFile}"
+ $testFiles += $currentFile
+ $testDirs += $currentFile.Directory
+ }
+ $testDirs = $testDirs | Select-Object -Uniq
+
+ & (Get-VsTestPath) /Enablecodecoverage /Parallel /Logger:trx $testFiles
+ Test-ExitCode "ERROR: Unit Tests execution FAILED."
+
+ Clear-ExtraFiles
+}
+
+# Coverage
+function Invoke-CodeCoverage() {
+ Write-Header "Creating coverage report"
+
+ $codeCoverageExe = Get-CodeCoveragePath
+
+ Write-Host "Generating code coverage reports for"
+ Get-ChildItem "TestResults" -Recurse -Include "*.coverage" | ForEach-Object {
+ Write-Host " -" $_.FullName
+
+ $filePathWithNewExtension = $_.FullName + "xml"
+ if (Test-Path $filePathWithNewExtension) {
+ Write-Debug "Coveragexml report already exists, removing it"
+ Remove-Item -Force $filePathWithNewExtension
+ }
+
+ Exec { & $codeCoverageExe analyze /output:$filePathWithNewExtension $_.FullName `
+ } -errorMessage "ERROR: Code coverage reports generation FAILED."
+ }
+}
\ No newline at end of file
diff --git a/scripts/ci-build.ps1 b/scripts/ci-build.ps1
new file mode 100644
index 000000000..b63186506
--- /dev/null
+++ b/scripts/ci-build.ps1
@@ -0,0 +1,53 @@
+Set-StrictMode -version 2.0
+$ErrorActionPreference = "Stop"
+
+function Build-TFSProcessor() {
+ Write-Host "Building TFSProcessor"
+ Invoke-MSBuild "SonarScanner.MSBuild.TFS.sln" "/t:Restore"
+ Invoke-MSBuild "SonarScanner.MSBuild.TFS.sln" "/t:Rebuild" "/p:Configuration=Release"
+ Write-Host "TFSProcessor build has completed."
+}
+
+function Build-Scanner() {
+ Write-Host "Building SonarScanner for MSBuild"
+ Invoke-MSBuild "SonarScanner.MSBuild.sln" "/t:Restore"
+ Invoke-MSBuild "SonarScanner.MSBuild.sln" "/t:Rebuild" "/p:Configuration=Release"
+ Write-Host "Build for SonarScanner has completed."
+}
+
+function CleanAndRecreate-BuildDirectories([string]$tfm) {
+ if (Test-Path("$fullBuildOutputDir\sonarscanner-msbuild-$tfm")) {
+ Remove-Item "$fullBuildOutputDir\sonarscanner-msbuild-$tfm\*" -Recurse -Force
+ }
+}
+
+try {
+ Write-Host $PSScriptRoot
+
+ . (Join-Path $PSScriptRoot "build-utils.ps1")
+ . (Join-Path $PSScriptRoot "package-artifacts.ps1")
+ . (Join-Path $PSScriptRoot "variables.ps1")
+
+ CleanAndRecreate-BuildDirectories "net46"
+ CleanAndRecreate-BuildDirectories "netcoreapp2.0"
+ CleanAndRecreate-BuildDirectories "netcoreapp3.0"
+ CleanAndRecreate-BuildDirectories "net5.0"
+ Download-ScannerCli
+
+ Build-TFSProcessor
+ Build-Scanner
+
+ Package-Net46Scanner
+ Package-NetScanner "netcoreapp3.0"
+ Package-NetScanner "netcoreapp2.0"
+ Package-NetScanner "net5.0"
+
+ Write-Host -ForegroundColor Green "SUCCESS: CI job was successful!"
+ exit 0
+}
+catch {
+ Write-Host -ForegroundColor Red $_
+ Write-Host $_.Exception
+ Write-Host $_.ScriptStackTrace
+ exit 1
+}
\ No newline at end of file
diff --git a/scripts/package-artifacts.ps1 b/scripts/package-artifacts.ps1
new file mode 100644
index 000000000..9811ffdd8
--- /dev/null
+++ b/scripts/package-artifacts.ps1
@@ -0,0 +1,55 @@
+function Package-Net46Scanner(){
+ if (!(Test-Path -path "$fullBuildOutputDir\sonarscanner-msbuild-net46")) {New-Item "$fullBuildOutputDir\sonarscanner-msbuild-net46" -Type Directory}
+ if (!(Test-Path -path "$fullBuildOutputDir\sonarscanner-msbuild-net46\Targets")) {New-Item "$fullBuildOutputDir\sonarscanner-msbuild-net46\Targets" -Type Directory}
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\Microsoft.VisualStudio.Setup.Configuration.Interop.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\Newtonsoft.Json.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\SonarScanner.MSBuild.Common.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\SonarScanner.MSBuild.Shim.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\SonarScanner.MSBuild.TFS.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\SonarScanner.MSBuild.TFSProcessor.exe" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\SonarScanner.MSBuild.TFSProcessor.exe.config" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\System.Runtime.InteropServices.RuntimeInformation.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.TFS.Classic\bin\Release\net46\System.ValueTuple.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.Tasks\Targets\*" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46\Targets" -Recurse
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\net46\*" -Exclude "*.pdb" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46" -Recurse
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.Tasks\bin\Release\net46\SonarScanner.MSBuild.Tasks.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-net46"
+ [System.IO.Compression.ZipFile]::ExtractToDirectory("$scannerCliDownloadDir\$scannerCliArtifact", "$fullBuildOutputDir\sonarscanner-msbuild-net46")
+ Compress-Archive -Path $fullBuildOutputDir\sonarscanner-msbuild-net46\* -DestinationPath $fullBuildOutputDir\sonarscanner-msbuild-net46.zip -Force
+}
+
+function Package-NetScanner([string]$tfm)
+{
+ if (!(Test-Path -path "$fullBuildOutputDir\sonarscanner-msbuild-$tfm")) {New-Item "$fullBuildOutputDir\sonarscanner-msbuild-$tfm" -Type Directory}
+ if (!(Test-Path -path "$fullBuildOutputDir\sonarscanner-msbuild-$tfm\Targets")) {New-Item "$fullBuildOutputDir\sonarscanner-msbuild-$tfm\Targets" -Type Directory}
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.Tasks\Targets\*" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm\Targets" -Recurse
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarQube.Analysis.xml" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.Common.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.PostProcessor.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.PreProcessor.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.runtimeconfig.json" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\$tfm\SonarScanner.MSBuild.Shim.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild\bin\Release\netcoreapp3.0\Newtonsoft.Json.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ Copy-Item -Path "$PSScriptRoot\..\src\SonarScanner.MSBuild.Tasks\bin\Release\netstandard2.0\SonarScanner.MSBuild.Tasks.dll" -Destination "$fullBuildOutputDir\sonarscanner-msbuild-$tfm"
+ [System.IO.Compression.ZipFile]::ExtractToDirectory("$scannerCliDownloadDir\$scannerCliArtifact", "$fullBuildOutputDir\sonarscanner-msbuild-$tfm")
+ Compress-Archive -Path $fullBuildOutputDir\sonarscanner-msbuild-$tfm\* -DestinationPath $fullBuildOutputDir\sonarscanner-msbuild-$tfm.zip -Force
+}
+function Download-ScannerCli() {
+ $artifactoryUrlEnv = "ARTIFACTORY_URL"
+
+ $artifactoryUrl = [environment]::GetEnvironmentVariable($artifactoryUrlEnv, "Process")
+ if (!$artifactoryUrl) {
+ Write-Host "Could not find ARTIFACTORY_URL variable, defaulting to repox URL.";
+ $artifactoryUrl = "https://repox.jfrog.io/repox";
+ }
+
+ $scannerCliUrl = $artifactoryUrl + "/sonarsource-public-releases/org/sonarsource/scanner/cli/sonar-scanner-cli/$scannerCliVersion/$scannerCliArtifact";
+
+ if (!(Test-Path -LiteralPath $scannerCliDownloadDir)) {
+ New-Item -Path $scannerCliDownloadDir -ItemType Directory -ErrorAction Stop -Force
+ }
+
+ if (!(Test-Path -LiteralPath $scannerCliDownloadDir\$scannerCliArtifact)) {
+ Invoke-WebRequest -Uri $scannerCliUrl -OutFile $scannerCliDownloadDir\$scannerCliArtifact
+ }
+}
\ No newline at end of file
diff --git a/scripts/sign.ps1 b/scripts/sign.ps1
new file mode 100644
index 000000000..3184f683d
--- /dev/null
+++ b/scripts/sign.ps1
@@ -0,0 +1,31 @@
+Write-Host "Signing .NET 5.0 assemblies"
+Get-ChildItem "build\sonarscanner-msbuild-net5.0\Sonar*.dll" |
+Foreach-Object {
+ & $env:SIGNTOOL_PATH sign /fd SHA256 /f $env:PFX_PATH /p $env:PFX_PASSWORD /tr http://timestamp.digicert.com?alg=sha256 $_.FullName
+}
+Write-Host "[Completed] Signing .NET 5.0 assemblies"
+
+Write-Host "Signing .NET 4.6 assemblies"
+Get-ChildItem "build\sonarscanner-msbuild-net46\Sonar*.dll" |
+Foreach-Object {
+ & $env:SIGNTOOL_PATH sign /fd SHA256 /f $env:PFX_PATH /p $env:PFX_PASSWORD /tr http://timestamp.digicert.com?alg=sha256 $_.FullName
+}
+Get-ChildItem "build\sonarscanner-msbuild-net46\Sonar*.exe" |
+Foreach-Object {
+ & $env:SIGNTOOL_PATH sign /fd SHA256 /f $env:PFX_PATH /p $env:PFX_PASSWORD /tr http://timestamp.digicert.com?alg=sha256 $_.FullName
+}
+Write-Host "[Completed]Signing .NET 4.6 assemblies"
+
+Write-Host "Signing .NET Core 2 assemblies"
+Get-ChildItem "build\sonarscanner-msbuild-netcoreapp2.0\Sonar*.dll" |
+Foreach-Object {
+ & $env:SIGNTOOL_PATH sign /fd SHA256 /f $env:PFX_PATH /p $env:PFX_PASSWORD /tr http://timestamp.digicert.com?alg=sha256 $_.FullName
+}
+Write-Host "[Completed] Signing .NET Core 2 assemblies"
+
+Write-Host "Signing .NET Core 3 assemblies"
+Get-ChildItem "build\sonarscanner-msbuild-netcoreapp3.0\Sonar*.dll" |
+Foreach-Object {
+ & $env:SIGNTOOL_PATH sign /fd SHA256 /f $env:PFX_PATH /p $env:PFX_PASSWORD /tr http://timestamp.digicert.com?alg=sha256 $_.FullName
+}
+Write-Host "[Completed] Signing .NET Core 3 assemblies"
\ No newline at end of file
diff --git a/scripts/utils.ps1 b/scripts/utils.ps1
new file mode 100644
index 000000000..bdfcfbbc2
--- /dev/null
+++ b/scripts/utils.ps1
@@ -0,0 +1,109 @@
+Add-Type -AssemblyName "System.IO.Compression.FileSystem"
+
+# Original: http://jameskovacs.com/2010/02/25/the-exec-problem
+function Exec ([scriptblock]$command, [string]$errorMessage = "ERROR: Command '${command}' FAILED.") {
+ Write-Debug "Invoking command:${command}"
+
+ $output = ""
+ & $command | Tee-Object -Variable output
+ if ((-not $?) -or ($lastexitcode -ne 0)) {
+ throw $errorMessage
+ }
+
+ return $output
+}
+
+function Test-ExitCode([string]$errorMessage = "ERROR: Command FAILED.") {
+ if ((-not $?) -or ($lastexitcode -ne 0)) {
+ throw $errorMessage
+ }
+}
+
+# Sets the current folder and executes the given script.
+# When the script finishes sets the original current folder.
+function Invoke-InLocation([string]$path, [scriptblock]$command) {
+ try {
+ Write-Debug "Changing current directory to: '${path}'"
+ Push-Location $path
+
+ & $command
+ }
+ finally {
+ Write-Debug "Changing current directory back to previous one"
+ Pop-Location
+ }
+}
+
+function ConvertTo-UnixLineEndings([string]$fileName) {
+ Get-ChildItem $fileName | ForEach-Object {
+ $currentFile = $_
+ Write-Debug "Changing line ending for '${currentFile}'"
+ $content = [IO.File]::ReadAllText($currentFile) -Replace "`r`n?", "`n"
+ $utf8 = New-Object System.Text.UTF8Encoding $false
+ [IO.File]::WriteAllText($currentFile, $content, $utf8)
+ }
+}
+
+function Write-Header([string]$text) {
+ Write-Host
+ Write-Host "================================================"
+ Write-Host $text
+ Write-Host "================================================"
+}
+
+function Get-ExecutablePath([string]$name, [string]$directory, [string]$envVar) {
+ Write-Debug "Trying to find '${name}' using '${envVar}' environment variable"
+ $path = [environment]::GetEnvironmentVariable($envVar, "Process")
+
+ try {
+ if (!$path) {
+ Write-Debug "Environment variable not found"
+
+ if (!$directory) {
+ Write-Debug "Trying to find path using 'where.exe'"
+ $path = Exec { & where.exe $name } | Select-Object -First 1
+ }
+ else {
+ Write-Debug "Trying to find path using 'where.exe' in '${directory}'"
+ $path = Exec { & where.exe /R $directory $name } | Select-Object -First 1
+ }
+ }
+ }
+ catch {
+ throw "Failed to locate executable '${name}' on the path"
+ }
+
+ if (Test-Path $path) {
+ Write-Debug "Found '${name}' at '${path}'"
+ [environment]::SetEnvironmentVariable($envVar, $path)
+ return $path
+ }
+
+ throw "'${name}' located at '${path}' doesn't exist"
+}
+
+function Expand-ZIPFile($source, $destination) {
+ Write-Host "Unzipping '${source}' into '${destination}'"
+
+ if (Get-Command "Expand-Archive" -errorAction SilentlyContinue) {
+ # PS v5.0+
+ Write-Debug "Unzipping using 'Expand-Archive'"
+ Expand-Archive $source $destination -Force
+ }
+ else {
+ if (-Not (Test-Path $destination)) {
+ Write-Debug "Creating folder '${destination}'"
+ New-Item $destination -ItemType Directory
+ }
+
+ Write-Debug "Unzipping using 'Shell.Application'"
+ $application = New-Object -Com Shell.Application
+
+ $zip = $application.NameSpace($source)
+ $application.NameSpace($destination).CopyHere($zip.items(), 0x14)
+ }
+}
+
+function Test-Debug() {
+ return $DebugPreference -ne "SilentlyContinue"
+}
diff --git a/scripts/variables.ps1 b/scripts/variables.ps1
new file mode 100644
index 000000000..bb32f7a6d
--- /dev/null
+++ b/scripts/variables.ps1
@@ -0,0 +1,5 @@
+$fullBuildOutputDir = "$PSScriptRoot\..\build"
+$scannerCliVersion = "4.4.0.2170"
+$scannerCliAssemblyName = "sonar-scanner-cli-$ScannerCliVersion"
+$scannerCliArtifact = "$scannerCliAssemblyName.zip"
+$scannerCliDownloadDir = "$fullBuildOutputDir\temp"
\ No newline at end of file
diff --git a/scripts/version/Version.props b/scripts/version/Version.props
index 797166474..30ec88669 100644
--- a/scripts/version/Version.props
+++ b/scripts/version/Version.props
@@ -1,6 +1,6 @@
- 4.10.0
+ 5.0.00not-setnot-set
diff --git a/sonar-docs/analysis/scan/sonarscanner-for-msbuild.md b/sonar-docs/analysis/scan/sonarscanner-for-msbuild.md
index e8cd8521d..3df900fc8 100644
--- a/sonar-docs/analysis/scan/sonarscanner-for-msbuild.md
+++ b/sonar-docs/analysis/scan/sonarscanner-for-msbuild.md
@@ -3,14 +3,20 @@ title: SonarScanner for MSBuild
url: /analysis/scan/sonarscanner-for-msbuild/
---
+
+
+
+
+
[[info]]
-| **Download SonarScanner for MSBuild** - Compatible with SonarQube 6.7+ (LTS)
-| By [SonarSource](https://www.sonarsource.com/) – GNU LGPL 3 – [Issue Tracker](https://github.com/SonarSource/sonar-scanner-msbuild/issues) – [Source](https://github.com/SonarSource/sonar-scanner-msbuild)
+| **Download SonarScanner for MSBuild 5.0.0** - [Issue Tracker](https://github.com/SonarSource/sonar-scanner-msbuild/issues) – [Source](https://github.com/SonarSource/sonar-scanner-msbuild)
|
-| [.NET Framework 4.6+](https://github.com/SonarSource/sonar-scanner-msbuild/releases) |
-| [.NET Core 2.0+](https://github.com/SonarSource/sonar-scanner-msbuild/releases) |
+| [.NET Framework 4.6](https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.10.0.19059/sonar-scanner-msbuild-4.10.0.19059-net46.zip) |
+| [.NET Core 2.x](https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.10.0.19059/sonar-scanner-msbuild-4.10.0.19059-netcoreapp2.0.zip) |
+| [.NET Core 3.x](https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.10.0.19059/sonar-scanner-msbuild-4.10.0.19059-netcoreapp3.0.zip) |
+| [.NET 5.0](https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.10.0.19059/sonar-scanner-msbuild-4.10.0.19059-net5.0.zip) |
| [.NET Core Global Tool](https://www.nuget.org/packages/dotnet-sonarscanner)
-
+
The SonarScanner for MSBuild is the recommended way to launch an analysis for projects/solutions using MSBuild or dotnet command as a build tool. It is the result of a [collaboration between SonarSource and Microsoft](http://www.sonarqube.org/announcing-sonarqube-integration-with-msbuild-and-team-build/).
@@ -19,24 +25,35 @@ SonarScanner for MSBuild is distributed as a standalone command line executable,
It supports .Net Core multi-platform projects and it can be used on non-Windows platforms.
## Prerequisites
+
* At least the minimal version of Java supported by your SonarQube server
+
+
+* Java 11 or greater
+
* The SDK corresponding to your build system:
- * [.NET Framework v4.6+](https://www.microsoft.com/fr-fr/download/details.aspx?id=53344) - either [Build Tools for Visual Studio 2015 Update 3](https://go.microsoft.com/fwlink/?LinkId=615458) or the [Build Tools for Visual Studio 2017](https://www.visualstudio.com/downloads/)
- * .NET Core 2.0 - [.NET Core SDK 2.0](https://www.microsoft.com/net/learn/get-started/) (for .NET Core version of the scanner)
- * .NET Core 2.1 and above - [NET Core SDK 2.1.3](https://www.microsoft.com/net/learn/get-started/) (for .NET Core version of the scanner or if you plan to use [.NET Core Global Tool](https://www.nuget.org/packages/dotnet-sonarscanner)
+ * [.NET Framework v4.6](https://www.microsoft.com/fr-fr/download/details.aspx?id=53344) - either [Build Tools for Visual Studio 2015 Update 3](https://go.microsoft.com/fwlink/?LinkId=615458) or the [Build Tools for Visual Studio 2017](https://www.visualstudio.com/downloads/)
+ * [.NET Core SDK 2.0 and above](https://www.microsoft.com/net/learn/get-started/) (for .NET Core version of the scanner or if you plan to use [.NET Core Global Tool](https://www.nuget.org/packages/dotnet-sonarscanner)
+[[info]]
+| The flavor used to compile the Scanner for MSBuild (either .NET Framework or .NET Core) is independant of the .NET version the
+| project you want to analyze has been built with. Concretely, you can analyze .NET Core code with the .NET Framework version of
+| the Scanner. It's only relevant depending on your OS, and on the versions of .NET SDKs that are installed on your build machine.
## Installation
-### SonarScanner for MSBuild for .NET Framework or .NET Core
+
+### SonarScanner for MSBuild for .NET Framework, .NET Core and .NET
+
* Expand the downloaded file into the directory of your choice. We'll refer to it as `$install_directory` in the next steps.
- * On Windows, you might need to unblock the ZIP file first (Right click on file > Properties > Unblock).
- * On Linux/OSX you may need to set execute permissions on the files in `$install_directory/sonar-scanner-(version)/bin`.
-
-* Uncomment, and update the global settings to point to your SonarQube server by editing `$install_directory/SonarQube.Analysis.xml`. Values set in this file will be applied to all analyses of all projects unless overwritten locally.
+ * On Windows, you might need to unblock the ZIP file first (Right click on file > Properties > Unblock).
+ * On Linux/OSX you may need to set execute permissions on the files in `$install_directory/sonar-scanner-(version)/bin`.
+
+* Uncomment, and update the global settings to point to your SonarQube serverSonarCloud by editing `$install_directory/SonarQube.Analysis.xml`. Values set in this file will be applied to all analyses of all projects unless overwritten locally.
Consider setting file system permissions to restrict access to this file.:
-```
+
+```xml
- http://localhost:9000
+ http://localhost:9000https://sonarcloud.io[my-user-token]
```
@@ -44,49 +61,60 @@ Consider setting file system permissions to restrict access to this file.:
* Add `$install_directory` to your PATH environment variable.
### Installation of the SonarScanner for MSBuild .NET Core Global Tool
+
+```bash
+dotnet tool install --global dotnet-sonarscanner --version x.x.x
```
-dotnet tool install --global dotnet-sonarscanner
-```
-.NET Core Global Tool is available from .NETCore 2.1+ and 3.0 (starting from version 4.8.0)
-### On Linux/OSX, if your SonarQube server is secured:
+The _--version_ argument is optional. If it is omitted the latest version will be installed. Full list of releases is available on the [NuGet page](https://www.nuget.org/packages/dotnet-sonarscanner)
+
+.NET Core Global Tool is available from .NET Core 2.1+
+
+### On Linux/OSX, if your SonarQube server is secured
1. Copy the server's CA certs to `/usr/local/share/ca-certificates`
2. Run `sudo update-ca-certificates`
+
## Use
+
+[[info]]
+| You can invoke the Scanner using arguments with both dash (-) or forward-slash (/) separators.
+| Example : SonarScanner.MSBuild.exe begin /k:"project-key" or SonarScanner.MSBuild.exe begin -k:"project-key" will work.
+
There are two versions of the SonarScanner for MSBuild.
-The first version is based on the “classic” .NET Framework. To use it, execute the following commands from the root folder of your project:
+The first version is based on the "classic" .NET Framework. To use it, execute the following commands from the root folder of your project:
+
```
SonarScanner.MSBuild.exe begin /k:"project-key" /o:"" /d:sonar.login=""
MSBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login=""
```
-Note: On Mac OS or Linux, you can also use `mono `.
+Note: On Mac OS or Linux, you can also use `mono `.
The second version is based on .NET Core which has a very similar usage:
-```
+
+```bash
dotnet begin /k:"project-key" /o:"" /d:sonar.login=""
dotnet build
dotnet end /d:sonar.login=""
```
+
The .NET Core version can also be used as a .NET Core Global Tool.
After installing the Scanner as a global tool as described above it can be invoked as follows:
-```
+
+```bash
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"project-key" /o:"" /d:sonar.login=""
dotnet build
dotnet sonarscanner end /d:sonar.login=""
```
-Same as above, if you are targeting a SonarCloud project, you will have to add both the organization and a login for authentication.
-
Notes:
-* The .NET Core version of the scanner does not support TFS XAML builds. Apart from that, the two versions of scanner have the same capabilities and command line arguments.
-* Single .NET Core project files (csproj or vbproj) could be built and successfully analyzed only if a `unique guid` element is added in the csproj or vbproj XML. The `` element is not required if you build a solution (sln) containing that project.
+* The .NET Core version of the scanner does not support TFS XAML builds and automatic finding/conversion of Code Coverage files. Apart from that, the two versions of scanner have the same capabilities and command line arguments.
## Analysis steps
### Begin
@@ -96,29 +124,29 @@ Command Line Parameters:
Parameter|Description
---|---
-`/k:`|[required] Specifies the key of the analyzed project in SonarQube
-`/n:`|[optional] Specifies the name of the analyzed project in SonarQube. Adding this argument will overwrite the project name in SonarQube if it already exists.
+`/k:`|[required] Specifies the key of the analyzed project in {instance}
+`/n:`|[optional] Specifies the name of the analyzed project in {instance}. Adding this argument will overwrite the project name in {instance} if it already exists.
`/v:`|[recommended] Specifies the version of your project.
`/o:`|[required] Specifies the name of the target organization in SonarCloud.
-`/d:sonar.login= or `| [optional] Specifies the username or access token to authenticate with to SonarQube. If this argument is added to the begin step, it must also be added on the end step.
-`/d:sonar.password=`|[optional] Specifies the password for the SonarQube username in the `sonar.login` argument. This argument is not needed if you use authentication token. If this argument is added to the begin step, it must also be added on the end step.
+`/d:sonar.login= or `| [optional] Specifies the username or access token to authenticate with to {instance}. If this argument is added to the begin step, it must also be added on the end step.
+`/d:sonar.password=`|[optional] Specifies the password for the {instance} username in the `sonar.login` argument. This argument is not needed if you use authentication token. If this argument is added to the begin step, it must also be added on the end step.
`/d:sonar.verbose=true`|[optional] Sets the logging verbosity to detailed. Add this argument before sending logs for troubleshooting.
-`/d:=`|[optional] Specifies an additional SonarQube [analysis parameter](/analysis/analysis-parameters/), you can add this argument multiple times.
+`/d:=`|[optional] Specifies an additional {instance} [analysis parameter](/analysis/analysis-parameters/), you can add this argument multiple times.
For detailed information about all available parameters, see [Analysis Parameters](/analysis/analysis-parameters/).
[[warning]]
|  The "begin" step will modify your build like this:
-| * the active `CodeAnalysisRuleSet` will be updated to match the SonarQube quality profile
+| * the active `CodeAnalysisRuleSet` will be updated to match the {instance} quality profile
| * `WarningsAsErrors` will be turned off
|
-| If your build process cannot tolerate these changes we recommend creating a second build job for SonarQube analysis.
+| If your build process cannot tolerate these changes we recommend creating a second build job for {instance} analysis.
### Build
Between the `begin` and `end` steps, you need to build your project, execute tests and generate code coverage data. This part is specific to your needs and it is not detailed here.
### End
-The end step is executed when you add the "end" command line argument. It cleans the MSBuild hooks, collects the analysis data generated by the build, the test results, the code coverage and then uploads everything to SonarQube.
+The end step is executed when you add the "end" command line argument. It cleans the MSBuild hooks, collects the analysis data generated by the build, the test results, the code coverage and then uploads everything to {instance}
There are only two additional arguments that are allowed for the end step:
@@ -128,14 +156,29 @@ Parameter|Description
`/d:sonar.password=`|[optional] This argument is required if it was added to the begin step and you are not using an authentication token.
### Known Limitations
+
* MSBuild versions older than 14 are not supported.
-* Web Application projects are supported. Legacy Web Site projects are not.
+* Web Application projects are supported. Legacy Web Site projects are not.
* Projects targeting multiple frameworks and using preprocessor directives could have slightly inaccurate metrics (lines of code, complexity, etc.) because the metrics are calculated only from the first of the built targets.
+## Code Coverage
+
+In a Azure DevOps / TFS environment, test files are automatically retrieved following this search
+* Search for .trx files in any TestResults folder located under the $Build.SourcesDirectory path
+* If not found, then a fallback search is made against $Agent.TempDirectory
+
+Once trx files have been found, their `.coverage` counterpart are searched as well and the scanner tries to convert them to `.coveragexml` files that will be uploaded to {instance}.
+CodeCoverage.exe tool is used for that, and the scanner also needs to find a path to that tool, following this search path
+* Search for the presence of `VsTestToolsInstallerInstalledToolLocation` environment variable, set by the VsTestToolsPlatformInstaller task or by the user
+* If not found, search for either the presence of that tool in well-known installation path, or via the registry.
+
+As stated above, this will work only with the .NET 4.6 flavor of the Scanner.
## Excluding projects from analysis
+
Some project types, such as [Microsoft Fakes](https://msdn.microsoft.com/en-us/library/hh549175.aspx), are automatically excluded from analysis. To manually exclude a different type of project from the analysis, place the following in its .xxproj file.
-```
+
+```xml
@@ -144,6 +187,7 @@ Some project types, such as [Microsoft Fakes](https://msdn.microsoft.com/en-us/l
```
## Advanced topics
+
**Analyzing MSBuild 12 projects with MSBuild 14**
The Sonar Scanner for MSBuild requires your project to be built with MSBuild 14.0. We recommend installing Visual Studio 2015 update 3 or later on the analysis machine in order to benefit from the integration and features provided with the Visual Studio ecosystem (VSTest, MSTest unit tests, etc.).
@@ -152,27 +196,16 @@ Projects targeting older versions of the .NET Framework can be built using MSBui
* [How to: Target a Version of the .NET Framework](https://msdn.microsoft.com/en-us/library/bb398202.aspx)
* [MSBuild Target Framework and Target Platform](https://msdn.microsoft.com/en-us/library/hh264221.aspx)
-If you do not want to switch your production build to MSBuild 14.0, you can set up a separate build dedicated to the SonarQube analysis.
-
-**Detection of Test Projects**
-SonarQube analyzes test projects differently from non-test projects, so it is important to correctly classify test projects.
+If you do not want to switch your production build to MSBuild 14.0, you can set up a separate build dedicated to the {instance} analysis.
-By default, the SonarQube Scanner for MSBuild will detect as test project:
+**Detection of test projects**
-. MSTest unit test projects, thanks to the presence of a well-known project type GUID in .csproj file of such projects.
-1. Projects with names ending in "Test" or "Tests". This behavior can be changed by providing the parameter `sonar.msbuild.testProjectPattern` to the begin step (regex follows .NET Regular Expression in a case-sensitive way with the default value `.*Tests?\.(cs|vb)proj$`). This regex is applied against the fullname of the `.csproj` or `.vbproj` which is why it's recommended to keep at the end of your custom regex `\.(cs|vb)proj$`.
-To manually classify a project as a test project, mark it with `true`:
-```
-
-
-
- true
-
-```
+You can read a full description on that subject on our wiki [here](https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects).
**Per-project analysis parameters**
Some analysis parameters can be set for a single MSBuild project by adding them to its .csproj file.
-```
+
+```xml
@@ -190,19 +223,25 @@ Concurrent analyses (i.e. parallel analysis of two solutions on the same build m
* For MSBuild, the path is `\\Microsoft.Common.targets\ImportBefore` where is:
* For v14, default path is: `C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.Targets\ImportBefore`
* For v15, default path is: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Microsoft.Common.targets\ImportBefore` (for VS Community Edition)
- * For v16, default path is: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Microsoft.Common.targets` (for VS Community Edition)
+ * For v16, default path is: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Microsoft.Common.targets` (for VS Enterprise Edition)
* For dotnet, the path is `\15.0\Microsoft.Common.targets\ImportBefore` where `` can be found using the `dotnet --info` and looking for the Base Path property.
The performance impact of this global installation for projects that aren't analyzed is negligible as this target is only a bootstrapper and will bail out nearly instantaneously when the `.sonarqube` folder is not found under the folder being built.
**Using SonarScanner for MSBuild with a Proxy**
On build machines that connect to the Internet through a proxy server you might experience difficulties connecting to {instance}. To instruct the Java VM to use the system proxy settings, you need to set the following environment variable before running the SonarScanner for MSBuild:
-```
+
+```bash
SONAR_SCANNER_OPTS = "-Djava.net.useSystemProxies=true"
```
+
To instruct the Java VM to use specific proxy settings or when there is no system-wide configuration use the following value:
-```
+
+```bash
SONAR_SCANNER_OPTS = "-Dhttp.proxyHost=yourProxyHost -Dhttp.proxyPort=yourProxyPort"
```
-Where _yourProxyHost_ and _yourProxyPort_ are the hostname and the port of your proxy server. There are additional proxy settings for https, authentication and exclusions that could be passed to the Java VM. For more information see the following article: https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
+Where _yourProxyHost_ and _yourProxyPort_ are the hostname and the port of your proxy server. There are additional proxy settings for https, authentication and exclusions that could be passed to the Java VM. For more information see the following article: https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html.
+
+Since version 5.0 of the scanner, HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY will be automatically recognized and use to make call against {instance}. The Scanner for MSBuild makes HTTP calls, independant from the settings above concerning the Java VM, to fetch the Quality Profile and other useful settings for the "end" step.
+Where _yourProxyHost_ and _yourProxyPort_ are the hostname and the port of your proxy server. There are additional proxy settings for https, authentication and exclusions that could be passed to the Java VM. For more information see the following article: https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
diff --git a/src/DotnetVersions.props b/src/DotnetVersions.props
index ad45f57cc..86243583d 100644
--- a/src/DotnetVersions.props
+++ b/src/DotnetVersions.props
@@ -3,9 +3,9 @@
netstandard2.0
- netcoreapp2.0;netcoreapp3.0
- netcoreapp2.1;netcoreapp3.0
+ netcoreapp2.0;netcoreapp3.0net46
+ net5.0
\ No newline at end of file
diff --git a/src/Packaging/Packaging.csproj b/src/Packaging/Packaging.csproj
deleted file mode 100644
index f5dedfd57..000000000
--- a/src/Packaging/Packaging.csproj
+++ /dev/null
@@ -1,284 +0,0 @@
-
-
-
- $(ScannerNetFxVersion);$(ScannerNetCoreAppVersion);$(ScannerNetCoreGlobalToolVersion)
-
- bin\$(Configuration)\
-
-
-
- True
-
-
-
- $(TargetFramework)
-
-
- $(ScannerNetStandardVersion)
-
-
-
-
-
- 4.4.0.2170
- sonar-scanner-cli-$(ScannerCliVersion).zip
- $(MSBuildThisFileDirectory)..
- $(SourcesRoot)\..\DeploymentArtifacts\BuildAgentPayload\
- $(BuildAgentPayloadDir)$(Configuration)\
- $(WorkDestinationRootDir)\$(TargetFramework)
- $(WorkDestinationRootDir)\sonarscanner-msbuild-$(TargetFramework).zip
- $(SourcesRoot)\..\nuspec\netcoreglobaltool
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(ARTIFACTORY_URL)
- https://repox.jfrog.io/repox
- $(MavenUrlRoot)/sonarsource-public-releases/org/sonarsource/scanner/cli/sonar-scanner-cli/$(ScannerCliVersion)/$(ScannerCliArtifact)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/SonarQube.Bootstrapper/SonarQube.Bootstrapper.csproj b/src/SonarQube.Bootstrapper/SonarQube.Bootstrapper.csproj
deleted file mode 100644
index e1f1c0c78..000000000
--- a/src/SonarQube.Bootstrapper/SonarQube.Bootstrapper.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- $(ScannerNetFxVersion)
- SonarQube.Scanner.MSBuild
- true
- Exe
-
-
-
-
-
diff --git a/src/SonarQube.Old.Bootstrapper/SonarQube.Old.Bootstrapper.csproj b/src/SonarQube.Old.Bootstrapper/SonarQube.Old.Bootstrapper.csproj
deleted file mode 100644
index 1fb06112f..000000000
--- a/src/SonarQube.Old.Bootstrapper/SonarQube.Old.Bootstrapper.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- $(ScannerNetFxVersion)
- MSBuild.SonarQube.Runner
- true
- Exe
-
-
-
-
-
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfig.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfig.cs
index e26584baf..acf04cb36 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfig.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfig.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -58,7 +58,7 @@ public class AnalysisConfig
///
public bool HasBeginStepCommandLineCredentials { get; set; }
- #region SonarQube project properties
+ #region Sonar project properties
public string SonarQubeHostUrl { get; set; }
@@ -93,7 +93,7 @@ public class AnalysisConfig
///
public List AnalyzersSettings { get; set; }
- #endregion SonarQube project properties
+ #endregion Sonar project properties
#region Serialization
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfigExtensions.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfigExtensions.cs
index 4e14f63a3..a5a91e6e6 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfigExtensions.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalysisConfigExtensions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerPlugin.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerPlugin.cs
index f1b2fb9e9..c346a7d58 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerPlugin.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerPlugin.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerSettings.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerSettings.cs
index 88baca04c..8d6ae114f 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/AnalyzerSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/ConfigSetting.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/ConfigSetting.cs
index a649f6242..76025abfc 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/ConfigSetting.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/ConfigSetting.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Include.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Include.cs
index 5a025a133..631cb2e08 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Include.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Include.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rule.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rule.cs
index f941832b1..65475a1ac 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rule.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rule.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/RuleSet.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/RuleSet.cs
index 2def90a6c..2d99b2fc4 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/RuleSet.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/RuleSet.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rules.cs b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rules.cs
index b30a2ad57..33d26b7d9 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rules.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisConfig/Rules.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisException.cs b/src/SonarScanner.MSBuild.Common/AnalysisException.cs
index ab81ea3bd..3378739d1 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisException.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisException.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/AggregatePropertiesProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/AggregatePropertiesProvider.cs
index 1c07f3ecc..2e4dd6add 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/AggregatePropertiesProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/AggregatePropertiesProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/AnalysisProperties.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/AnalysisProperties.cs
index 93e1bb3f7..67be05568 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/AnalysisProperties.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/AnalysisProperties.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/CmdLineArgPropertyProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/CmdLineArgPropertyProvider.cs
index 9e2751e20..b4821ad15 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/CmdLineArgPropertyProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/CmdLineArgPropertyProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/EmptyPropertyProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/EmptyPropertyProvider.cs
index 389877d16..6ab7fc059 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/EmptyPropertyProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/EmptyPropertyProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/EnvScannerPropertiesProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/EnvScannerPropertiesProvider.cs
index adb5acfe6..bfc3872a1 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/EnvScannerPropertiesProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/EnvScannerPropertiesProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/FilePropertyProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/FilePropertyProvider.cs
index efcf23a95..fa0323b69 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/FilePropertyProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/FilePropertyProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/ListSettingsProvider.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/ListSettingsProvider.cs
index 65f6cca37..4d3c1980b 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/ListSettingsProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/ListSettingsProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/AnalysisProperties/Property.cs b/src/SonarScanner.MSBuild.Common/AnalysisProperties/Property.cs
index 9a781e007..5e6cca063 100644
--- a/src/SonarScanner.MSBuild.Common/AnalysisProperties/Property.cs
+++ b/src/SonarScanner.MSBuild.Common/AnalysisProperties/Property.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentDescriptor.cs b/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentDescriptor.cs
index e09e3d712..2b0c46769 100644
--- a/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentDescriptor.cs
+++ b/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentDescriptor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentInstance.cs b/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentInstance.cs
index 347777878..c52cce108 100644
--- a/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentInstance.cs
+++ b/src/SonarScanner.MSBuild.Common/CommandLine/ArgumentInstance.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineFlagPrefix.cs b/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineFlagPrefix.cs
index 4b857d98c..b3482475e 100644
--- a/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineFlagPrefix.cs
+++ b/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineFlagPrefix.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineParser.cs b/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineParser.cs
index eabf0b960..85368d877 100644
--- a/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineParser.cs
+++ b/src/SonarScanner.MSBuild.Common/CommandLine/CommandLineParser.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ConsoleColorScope.cs b/src/SonarScanner.MSBuild.Common/ConsoleColorScope.cs
index 9186eb0ce..6839c2991 100644
--- a/src/SonarScanner.MSBuild.Common/ConsoleColorScope.cs
+++ b/src/SonarScanner.MSBuild.Common/ConsoleColorScope.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ConsoleLogger.cs b/src/SonarScanner.MSBuild.Common/ConsoleLogger.cs
index 32682c659..38fddcc65 100644
--- a/src/SonarScanner.MSBuild.Common/ConsoleLogger.cs
+++ b/src/SonarScanner.MSBuild.Common/ConsoleLogger.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ConsoleOutputWriter.cs b/src/SonarScanner.MSBuild.Common/ConsoleOutputWriter.cs
index b6f3fe95a..697ee7f64 100644
--- a/src/SonarScanner.MSBuild.Common/ConsoleOutputWriter.cs
+++ b/src/SonarScanner.MSBuild.Common/ConsoleOutputWriter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/EncodingProviderWrapper.cs b/src/SonarScanner.MSBuild.Common/EncodingProviderWrapper.cs
index 044542daf..d56b86244 100644
--- a/src/SonarScanner.MSBuild.Common/EncodingProviderWrapper.cs
+++ b/src/SonarScanner.MSBuild.Common/EncodingProviderWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/FileConstants.cs b/src/SonarScanner.MSBuild.Common/FileConstants.cs
index 73ace7074..03403b2de 100644
--- a/src/SonarScanner.MSBuild.Common/FileConstants.cs
+++ b/src/SonarScanner.MSBuild.Common/FileConstants.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/FileInfoEqualityComparer.cs b/src/SonarScanner.MSBuild.Common/FileInfoEqualityComparer.cs
index 152d28591..e8b21aa46 100644
--- a/src/SonarScanner.MSBuild.Common/FileInfoEqualityComparer.cs
+++ b/src/SonarScanner.MSBuild.Common/FileInfoEqualityComparer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/IO/DirectoryWrapper.cs b/src/SonarScanner.MSBuild.Common/IO/DirectoryWrapper.cs
index 7db824b2d..cca2bf113 100644
--- a/src/SonarScanner.MSBuild.Common/IO/DirectoryWrapper.cs
+++ b/src/SonarScanner.MSBuild.Common/IO/DirectoryWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/IO/FileWrapper.cs b/src/SonarScanner.MSBuild.Common/IO/FileWrapper.cs
index 56742f9e0..c88c7acc9 100644
--- a/src/SonarScanner.MSBuild.Common/IO/FileWrapper.cs
+++ b/src/SonarScanner.MSBuild.Common/IO/FileWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/IO/IDirectoryWrapper.cs b/src/SonarScanner.MSBuild.Common/IO/IDirectoryWrapper.cs
index e8827316a..796d74f36 100644
--- a/src/SonarScanner.MSBuild.Common/IO/IDirectoryWrapper.cs
+++ b/src/SonarScanner.MSBuild.Common/IO/IDirectoryWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/IO/IFileWrapper.cs b/src/SonarScanner.MSBuild.Common/IO/IFileWrapper.cs
index 229cce026..c3e1ea1ae 100644
--- a/src/SonarScanner.MSBuild.Common/IO/IFileWrapper.cs
+++ b/src/SonarScanner.MSBuild.Common/IO/IFileWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/IAnalysisPropertyProvider.cs b/src/SonarScanner.MSBuild.Common/Interfaces/IAnalysisPropertyProvider.cs
index 9c7d3cb62..47fc85ded 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/IAnalysisPropertyProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/IAnalysisPropertyProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/IEncodingProvider.cs b/src/SonarScanner.MSBuild.Common/Interfaces/IEncodingProvider.cs
index 23dd749fb..c839f1c2f 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/IEncodingProvider.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/IEncodingProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/ILogger.cs b/src/SonarScanner.MSBuild.Common/Interfaces/ILogger.cs
index cc1ca9133..db9c43503 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/ILogger.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/ILogger.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/IMsBuildPathsSettings.cs b/src/SonarScanner.MSBuild.Common/Interfaces/IMsBuildPathsSettings.cs
index c3c7ad582..2be86bc0c 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/IMsBuildPathsSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/IMsBuildPathsSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/IOutputWriter.cs b/src/SonarScanner.MSBuild.Common/Interfaces/IOutputWriter.cs
index 147a63c1c..a51289485 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/IOutputWriter.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/IOutputWriter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Interfaces/IProcessRunner.cs b/src/SonarScanner.MSBuild.Common/Interfaces/IProcessRunner.cs
index da390c498..16d6fb6cd 100644
--- a/src/SonarScanner.MSBuild.Common/Interfaces/IProcessRunner.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/IProcessRunner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ITeamBuildSettings.cs b/src/SonarScanner.MSBuild.Common/Interfaces/ITeamBuildSettings.cs
similarity index 90%
rename from src/SonarScanner.MSBuild.TFS/Interfaces/ITeamBuildSettings.cs
rename to src/SonarScanner.MSBuild.Common/Interfaces/ITeamBuildSettings.cs
index b1c95a173..ae1615da1 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ITeamBuildSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/Interfaces/ITeamBuildSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,7 +18,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-namespace SonarScanner.MSBuild.TFS.Interfaces
+using SonarScanner.MSBuild.Common.TFS;
+
+namespace SonarScanner.MSBuild.Common.Interfaces
{
public interface ITeamBuildSettings
{
diff --git a/src/SonarScanner.MSBuild.Common/MsBuildPathSettings.cs b/src/SonarScanner.MSBuild.Common/MsBuildPathSettings.cs
index 0a11d1348..d1d44bfc1 100644
--- a/src/SonarScanner.MSBuild.Common/MsBuildPathSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/MsBuildPathSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/PlatformHelper.cs b/src/SonarScanner.MSBuild.Common/PlatformHelper.cs
index d27979ea5..dfeb4c109 100644
--- a/src/SonarScanner.MSBuild.Common/PlatformHelper.cs
+++ b/src/SonarScanner.MSBuild.Common/PlatformHelper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProcessRunner.cs b/src/SonarScanner.MSBuild.Common/ProcessRunner.cs
index cd82a425d..51d1813a1 100644
--- a/src/SonarScanner.MSBuild.Common/ProcessRunner.cs
+++ b/src/SonarScanner.MSBuild.Common/ProcessRunner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProcessRunnerArguments.cs b/src/SonarScanner.MSBuild.Common/ProcessRunnerArguments.cs
index 2bc01b4a3..cd7084d41 100644
--- a/src/SonarScanner.MSBuild.Common/ProcessRunnerArguments.cs
+++ b/src/SonarScanner.MSBuild.Common/ProcessRunnerArguments.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisResult.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisResult.cs
index b55e0aae7..cb71d155d 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisResult.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisResult.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisType.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisType.cs
index 107faeda6..c8b611bf1 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisType.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/AnalysisType.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfo.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfo.cs
index 193f8b442..e0018dceb 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfo.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoExtensions.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoExtensions.cs
index 4684ba10a..83d1ce91e 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoExtensions.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoExtensions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectInfoValidity.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoValidity.cs
similarity index 93%
rename from src/SonarScanner.MSBuild.Shim/ProjectInfoValidity.cs
rename to src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoValidity.cs
index 0c64f6c70..2863fdfe4 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectInfoValidity.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectInfoValidity.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-namespace SonarScanner.MSBuild.Shim
+namespace SonarScanner.MSBuild.Common
{
///
/// Enumeration listing processing status codes that indicate whether a project
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectLanguages.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectLanguages.cs
index 1ae6f81cd..36c457793 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectLanguages.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectLanguages.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectType.cs b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectType.cs
index fd74b8794..3cc457ee7 100644
--- a/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectType.cs
+++ b/src/SonarScanner.MSBuild.Common/ProjectInfo/ProjectType.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.Common/Properties/AssemblyInfo.cs
index e406fa849..c26c08fbb 100644
--- a/src/SonarScanner.MSBuild.Common/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.Common/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Resources.Designer.cs b/src/SonarScanner.MSBuild.Common/Resources.Designer.cs
index 26fffd250..653dad624 100644
--- a/src/SonarScanner.MSBuild.Common/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.Common/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.Common {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -134,7 +134,7 @@ internal static string ERROR_CmdLine_MissingRequiredArgument {
}
///
- /// Looks up a localized string similar to Please use the parameter prefix '/o:' to define the organization of the SonarQube project instead of injecting this organization with the help of the 'sonar.organization' property..
+ /// Looks up a localized string similar to Please use the parameter prefix '/o:' to define the organization of the project instead of injecting this organization with the help of the 'sonar.organization' property..
///
internal static string ERROR_CmdLine_MustUseOrganization {
get {
@@ -143,7 +143,7 @@ internal static string ERROR_CmdLine_MustUseOrganization {
}
///
- /// Looks up a localized string similar to Please use the parameter prefix '/k:' to define the key of the SonarQube project instead of injecting this key with the help of the 'sonar.projectKey' property..
+ /// Looks up a localized string similar to Please use the parameter prefix '/k:' to define the key of the project instead of injecting this key with the help of the 'sonar.projectKey' property..
///
internal static string ERROR_CmdLine_MustUseProjectKey {
get {
@@ -152,7 +152,7 @@ internal static string ERROR_CmdLine_MustUseProjectKey {
}
///
- /// Looks up a localized string similar to Please use the parameter prefix '/n:' to define the name of the SonarQube project instead of injecting this name with the help of the 'sonar.projectName' property..
+ /// Looks up a localized string similar to Please use the parameter prefix '/n:' to define the name of the project instead of injecting this name with the help of the 'sonar.projectName' property..
///
internal static string ERROR_CmdLine_MustUseProjectName {
get {
@@ -161,7 +161,7 @@ internal static string ERROR_CmdLine_MustUseProjectName {
}
///
- /// Looks up a localized string similar to Please use the parameter prefix '/v:' to define the version of the SonarQube project instead of injecting this version with the help of the 'sonar.projectVersion' property..
+ /// Looks up a localized string similar to Please use the parameter prefix '/v:' to define the version of the project instead of injecting this version with the help of the 'sonar.projectVersion' property..
///
internal static string ERROR_CmdLine_MustUseProjectVersion {
get {
@@ -233,7 +233,7 @@ internal static string ERROR_ProcessRunner_ExeNotFound {
}
///
- /// Looks up a localized string similar to Unable to find the SonarQube analysis settings file '{0}'. Please fix the path to this settings file..
+ /// Looks up a localized string similar to Unable to find the analysis settings file '{0}'. Please fix the path to this settings file..
///
internal static string ERROR_Properties_GlobalPropertiesFileDoesNotExist {
get {
@@ -242,7 +242,7 @@ internal static string ERROR_Properties_GlobalPropertiesFileDoesNotExist {
}
///
- /// Looks up a localized string similar to Unable to read the SonarQube analysis settings file '{0}'. Please fix the content of this file..
+ /// Looks up a localized string similar to Unable to read the analysis settings file '{0}'. Please fix the content of this file..
///
internal static string ERROR_Properties_InvalidPropertiesFile {
get {
diff --git a/src/SonarScanner.MSBuild.Common/Resources.resx b/src/SonarScanner.MSBuild.Common/Resources.resx
index 89af31ffc..b520fb618 100644
--- a/src/SonarScanner.MSBuild.Common/Resources.resx
+++ b/src/SonarScanner.MSBuild.Common/Resources.resx
@@ -182,10 +182,10 @@
Loading analysis properties from {0}
- Unable to find the SonarQube analysis settings file '{0}'. Please fix the path to this settings file.
+ Unable to find the analysis settings file '{0}'. Please fix the path to this settings file.
- Unable to read the SonarQube analysis settings file '{0}'. Please fix the content of this file.
+ Unable to read the analysis settings file '{0}'. Please fix the content of this file./d:[key]=[value]
@@ -200,13 +200,13 @@
The format of the analysis property {0} is invalid
- Please use the parameter prefix '/k:' to define the key of the SonarQube project instead of injecting this key with the help of the 'sonar.projectKey' property.
+ Please use the parameter prefix '/k:' to define the key of the project instead of injecting this key with the help of the 'sonar.projectKey' property.
- Please use the parameter prefix '/n:' to define the name of the SonarQube project instead of injecting this name with the help of the 'sonar.projectName' property.
+ Please use the parameter prefix '/n:' to define the name of the project instead of injecting this name with the help of the 'sonar.projectName' property.
- Please use the parameter prefix '/v:' to define the version of the SonarQube project instead of injecting this version with the help of the 'sonar.projectVersion' property.
+ Please use the parameter prefix '/v:' to define the version of the project instead of injecting this version with the help of the 'sonar.projectVersion' property.Descriptor ids must be unique
@@ -258,6 +258,6 @@
At least one property name is missing. Please check that the settings file is valid.
- Please use the parameter prefix '/o:' to define the organization of the SonarQube project instead of injecting this organization with the help of the 'sonar.organization' property.
+ Please use the parameter prefix '/o:' to define the organization of the project instead of injecting this organization with the help of the 'sonar.organization' property.
\ No newline at end of file
diff --git a/src/SonarScanner.MSBuild.Common/Serializer.cs b/src/SonarScanner.MSBuild.Common/Serializer.cs
index 43ceb82d7..27e2eaee7 100644
--- a/src/SonarScanner.MSBuild.Common/Serializer.cs
+++ b/src/SonarScanner.MSBuild.Common/Serializer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/SingleGlobalInstanceMutex.cs b/src/SonarScanner.MSBuild.Common/SingleGlobalInstanceMutex.cs
index ac2cd5cc2..eb0e1bfe5 100644
--- a/src/SonarScanner.MSBuild.Common/SingleGlobalInstanceMutex.cs
+++ b/src/SonarScanner.MSBuild.Common/SingleGlobalInstanceMutex.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -58,7 +58,7 @@ public void Dispose()
private static Mutex CreateMutex(string name)
{
-#if IS_NET_FRAMEWORK
+#if NET46
// Concurrent builds could be run under different user accounts, so we need to allow all users to wait on the mutex
var mutexSecurity = new MutexSecurity();
mutexSecurity.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
diff --git a/src/SonarQube.Bootstrapper/Program.cs b/src/SonarScanner.MSBuild.Common/SonarProduct.cs
similarity index 71%
rename from src/SonarQube.Bootstrapper/Program.cs
rename to src/SonarScanner.MSBuild.Common/SonarProduct.cs
index 7750c78b0..785207912 100644
--- a/src/SonarQube.Bootstrapper/Program.cs
+++ b/src/SonarScanner.MSBuild.Common/SonarProduct.cs
@@ -18,11 +18,18 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-namespace SonarQube.Scanner.MSBuild
+namespace SonarScanner.MSBuild.Common
{
- internal static class Program
+ public static class SonarProduct
{
- private static int Main(string[] args)
- => SonarScanner.MSBuild.Program.ExecuteFromLegacyEntryPoint(args);
+ public static string GetSonarProductToLog(string hostNameUrl)
+ {
+ if(hostNameUrl == null)
+ {
+ return "SonarQube";
+ }
+
+ return hostNameUrl.Contains("sonarcloud.io") ? "SonarCloud" : "SonarQube";
+ }
}
}
diff --git a/src/SonarScanner.MSBuild.Common/SonarProperties.cs b/src/SonarScanner.MSBuild.Common/SonarProperties.cs
index 6a5018e00..5f8dc324c 100644
--- a/src/SonarScanner.MSBuild.Common/SonarProperties.cs
+++ b/src/SonarScanner.MSBuild.Common/SonarProperties.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/SonarScanner.MSBuild.Common.csproj b/src/SonarScanner.MSBuild.Common/SonarScanner.MSBuild.Common.csproj
index e08959f46..bfaa5bffb 100644
--- a/src/SonarScanner.MSBuild.Common/SonarScanner.MSBuild.Common.csproj
+++ b/src/SonarScanner.MSBuild.Common/SonarScanner.MSBuild.Common.csproj
@@ -1,17 +1,11 @@
-
+$(ScannerNetStandardVersion);$(ScannerNetFxVersion)SonarScanner.MSBuild.Commonfalse
-
-
-
- $(DefineConstants);IS_NET_FRAMEWORK
-
-
-
+
diff --git a/src/SonarScanner.MSBuild.Common/StringExtensions.cs b/src/SonarScanner.MSBuild.Common/StringExtensions.cs
index 7cfa7b656..fcc6e32f9 100644
--- a/src/SonarScanner.MSBuild.Common/StringExtensions.cs
+++ b/src/SonarScanner.MSBuild.Common/StringExtensions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/BuildEnvironment.cs b/src/SonarScanner.MSBuild.Common/TFS/BuildEnvironment.cs
similarity index 92%
rename from src/SonarScanner.MSBuild.TFS/BuildEnvironment.cs
rename to src/SonarScanner.MSBuild.Common/TFS/BuildEnvironment.cs
index 69f4583c8..d5f68cfcd 100644
--- a/src/SonarScanner.MSBuild.TFS/BuildEnvironment.cs
+++ b/src/SonarScanner.MSBuild.Common/TFS/BuildEnvironment.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-namespace SonarScanner.MSBuild.TFS
+namespace SonarScanner.MSBuild.Common.TFS
{
///
/// Lists the recognized build environments
diff --git a/src/SonarScanner.MSBuild.TFS/TeamBuildAnalysisSettings.cs b/src/SonarScanner.MSBuild.Common/TFS/TeamBuildAnalysisSettings.cs
similarity index 76%
rename from src/SonarScanner.MSBuild.TFS/TeamBuildAnalysisSettings.cs
rename to src/SonarScanner.MSBuild.Common/TFS/TeamBuildAnalysisSettings.cs
index d89e3e009..24eaeb5d3 100644
--- a/src/SonarScanner.MSBuild.TFS/TeamBuildAnalysisSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/TFS/TeamBuildAnalysisSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using SonarScanner.MSBuild.Common;
-
-namespace SonarScanner.MSBuild.TFS
+namespace SonarScanner.MSBuild.Common
{
///
/// Helper class to provide strongly-typed extension methods to access TFS-specific analysis settings
@@ -29,6 +27,7 @@ public static class TeamBuildAnalysisSettings
{
internal const string TfsUriSettingId = "TfsUri";
internal const string BuildUriSettingId = "BuildUri";
+ internal const string VsCoverageConverterToolPathId = "VsCoverageConverterToolPath";
#region Public methods
@@ -52,6 +51,16 @@ public static void SetBuildUri(this AnalysisConfig config, string uri)
config.SetConfigValue(BuildUriSettingId, uri);
}
+ public static void SetVsCoverageConverterToolPath(this AnalysisConfig config, string path)
+ {
+ config.SetConfigValue(VsCoverageConverterToolPathId, path);
+ }
+
+ public static string GetVsCoverageConverterToolPath(this AnalysisConfig config)
+ {
+ return config.GetConfigValue(VsCoverageConverterToolPathId, null);
+ }
+
#endregion Public methods
}
}
diff --git a/src/SonarScanner.MSBuild.TFS/TeamBuildSettings.cs b/src/SonarScanner.MSBuild.Common/TFS/TeamBuildSettings.cs
similarity index 92%
rename from src/SonarScanner.MSBuild.TFS/TeamBuildSettings.cs
rename to src/SonarScanner.MSBuild.Common/TFS/TeamBuildSettings.cs
index efd8299fc..ff66e5809 100644
--- a/src/SonarScanner.MSBuild.TFS/TeamBuildSettings.cs
+++ b/src/SonarScanner.MSBuild.Common/TFS/TeamBuildSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,10 +20,10 @@
using System;
using System.IO;
-using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
+using SonarScanner.MSBuild.Common.Interfaces;
-namespace SonarScanner.MSBuild.TFS
+namespace SonarScanner.MSBuild.Common
{
///
/// Provides access to TeamBuild-specific settings and settings calculated
@@ -62,6 +62,10 @@ public static class EnvironmentVariables // was internal
public const string BuildUri_TFS2015 = "BUILD_BUILDURI";
public const string BuildDirectory_TFS2015 = "AGENT_BUILDDIRECTORY";
public const string SourcesDirectory_TFS2015 = "BUILD_SOURCESDIRECTORY";
+
+ //This env variable can be set by the VSTest platform installer tool available on AzDo : https://github.com/microsoft/azure-pipelines-tasks/blob/1538fd6fdb8efd93539b7fe65b00df900d963c1a/Tasks/VsTestPlatformToolInstallerV1/helpers.ts#L8
+ //This will be also used if the user want to set a custom location.
+ public const string VsTestTool_CustomInstall = "VsTestToolsInstallerInstalledToolLocation";
}
#region Public static methods
@@ -103,6 +107,7 @@ public static TeamBuildSettings GetSettingsFromEnvironment(ILogger logger)
TfsUri = Environment.GetEnvironmentVariable(EnvironmentVariables.TfsCollectionUri_TFS2015),
BuildDirectory = Environment.GetEnvironmentVariable(EnvironmentVariables.BuildDirectory_TFS2015),
SourcesDirectory = Environment.GetEnvironmentVariable(EnvironmentVariables.SourcesDirectory_TFS2015),
+ CoverageToolUserSuppliedPath = Environment.GetEnvironmentVariable(EnvironmentVariables.VsTestTool_CustomInstall)
};
break;
@@ -113,6 +118,7 @@ public static TeamBuildSettings GetSettingsFromEnvironment(ILogger logger)
{
BuildEnvironment = env,
// there's no reliable of way of finding the SourcesDirectory, except after the build
+ CoverageToolUserSuppliedPath = Environment.GetEnvironmentVariable(EnvironmentVariables.VsTestTool_CustomInstall)
};
break;
@@ -227,6 +233,12 @@ public string BuildDirectory
private set;
}
+ public string CoverageToolUserSuppliedPath
+ {
+ get;
+ private set;
+ }
+
#endregion Public properties
#region Public calculated properties
diff --git a/src/SonarScanner.MSBuild.Common/UniqueDirectory.cs b/src/SonarScanner.MSBuild.Common/UniqueDirectory.cs
index c53304f9b..26fc470d7 100644
--- a/src/SonarScanner.MSBuild.Common/UniqueDirectory.cs
+++ b/src/SonarScanner.MSBuild.Common/UniqueDirectory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Common/Utilities.cs b/src/SonarScanner.MSBuild.Common/Utilities.cs
index 7faf90f34..9b6c68986 100644
--- a/src/SonarScanner.MSBuild.Common/Utilities.cs
+++ b/src/SonarScanner.MSBuild.Common/Utilities.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -171,6 +171,7 @@ public static bool IsSecuredServerProperty(string s)
/// are handled by logging user friendly errors.
///
/// True if the exception was handled
+ //TODO: change this to reflect new Http Exceptions.
public static bool HandleHostUrlWebException(WebException ex, string hostUrl, ILogger logger)
{
var response = ex.Response as HttpWebResponse;
diff --git a/src/SonarScanner.MSBuild.Common/VerbosityCalculator.cs b/src/SonarScanner.MSBuild.Common/VerbosityCalculator.cs
index 541dac123..c1bf8cded 100644
--- a/src/SonarScanner.MSBuild.Common/VerbosityCalculator.cs
+++ b/src/SonarScanner.MSBuild.Common/VerbosityCalculator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PostProcessor/ArgumentProcessor.cs b/src/SonarScanner.MSBuild.PostProcessor/ArgumentProcessor.cs
index eef6dcd3e..3c247536e 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/ArgumentProcessor.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/ArgumentProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/IMSBuildPostProcessor.cs b/src/SonarScanner.MSBuild.PostProcessor/Interfaces/IMSBuildPostProcessor.cs
index eaeb985b2..e6e8e85fb 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/IMSBuildPostProcessor.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/Interfaces/IMSBuildPostProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
*/
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild.PostProcessor.Interfaces
{
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ITargetsUninstaller.cs b/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ITargetsUninstaller.cs
index 75edd2ca4..f504115cb 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ITargetsUninstaller.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ITargetsUninstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PostProcessor/MSBuildPostProcessor.cs b/src/SonarScanner.MSBuild.PostProcessor/MSBuildPostProcessor.cs
index 85b71f2cc..1753725f3 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/MSBuildPostProcessor.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/MSBuildPostProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,11 +20,14 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using System.Linq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
using SonarScanner.MSBuild.PostProcessor.Interfaces;
using SonarScanner.MSBuild.Shim;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.PostProcessor
{
@@ -32,20 +35,27 @@ public class MSBuildPostProcessor : IMSBuildPostProcessor
{
private const string scanAllFiles = "-Dsonar.scanAllFiles=true";
- private readonly ICoverageReportProcessor codeCoverageProcessor;
- private readonly ISummaryReportBuilder reportBuilder;
private readonly ISonarScanner sonarScanner;
private readonly ILogger logger;
private readonly ITargetsUninstaller targetUninstaller;
+ private readonly ISonarProjectPropertiesValidator sonarProjectPropertiesValidator;
+ private readonly ITfsProcessor tfsProcessor;
- public MSBuildPostProcessor(ICoverageReportProcessor codeCoverageProcessor, ISonarScanner scanner,
- ISummaryReportBuilder reportBuilder, ILogger logger, ITargetsUninstaller targetUninstaller)
+ private IPropertiesFileGenerator propertiesFileGenerator;
+
+ public MSBuildPostProcessor(ISonarScanner scanner,
+ ILogger logger, ITargetsUninstaller targetUninstaller, ITfsProcessor tfsProcessor, ISonarProjectPropertiesValidator sonarProjectPropertiesValidator)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
- this.codeCoverageProcessor = codeCoverageProcessor ?? throw new ArgumentNullException(nameof(codeCoverageProcessor));
sonarScanner = scanner ?? throw new ArgumentNullException(nameof(scanner));
- this.reportBuilder = reportBuilder ?? throw new ArgumentNullException(nameof(reportBuilder));
this.targetUninstaller = targetUninstaller ?? throw new ArgumentNullException(nameof(targetUninstaller));
+ this.sonarProjectPropertiesValidator = sonarProjectPropertiesValidator ?? throw new ArgumentNullException(nameof(sonarProjectPropertiesValidator));
+ this.tfsProcessor = tfsProcessor ?? throw new ArgumentNullException(nameof(tfsProcessor));
+ }
+
+ public void /* for testing purposes */ SetPropertiesFileGenerator(IPropertiesFileGenerator propertiesFileGenerator)
+ {
+ this.propertiesFileGenerator = propertiesFileGenerator;
}
public bool Execute(string[] args, AnalysisConfig config, ITeamBuildSettings settings)
@@ -85,24 +95,57 @@ public bool Execute(string[] args, AnalysisConfig config, ITeamBuildSettings set
return false;
}
- // if initialization fails a warning will have been logged at the source of the failure
- var initialised = codeCoverageProcessor.Initialise(config, settings);
+ var propertyResult = GenerateAndValidatePropertiesFile(config);
- if (initialised && !codeCoverageProcessor.ProcessCoverageReports())
+ if (propertyResult.FullPropertiesFilePath != null)
{
- // if processing fails, stop the workflow
- return false;
+#if NET46
+ ProcessCoverageReport(config, Path.Combine(config.SonarConfigDir, FileConstants.ConfigFileName), propertyResult.FullPropertiesFilePath);
+#endif
+ bool result = false;
+ if (propertyResult.RanToCompletion)
+ {
+ result = InvokeSonarScanner(provider, config, propertyResult.FullPropertiesFilePath);
+ }
+#if NET46
+ if (settings.BuildEnvironment == BuildEnvironment.LegacyTeamBuild)
+ {
+ ProcessSummaryReportBuilder(config, result, Path.Combine(config.SonarConfigDir, FileConstants.ConfigFileName), propertyResult.FullPropertiesFilePath);
+ }
+#endif
+ return result;
+ }
+
+ return false;
+ }
+
+ private ProjectInfoAnalysisResult GenerateAndValidatePropertiesFile(AnalysisConfig config)
+ {
+ if (this.propertiesFileGenerator == null)
+ {
+ this.propertiesFileGenerator = new PropertiesFileGenerator(config, logger);
+ }
+
+ var result = this.propertiesFileGenerator.GenerateFile();
+
+ if (this.sonarProjectPropertiesValidator.AreExistingSonarPropertiesFilesPresent(config.SonarScannerWorkingDirectory, result.Projects, out var invalidFolders))
+ {
+ logger.LogError(Resources.ERR_ConflictingSonarProjectProperties, string.Join(", ", invalidFolders));
+ result.RanToCompletion = false;
+ }
+ else
+ {
+ ProjectInfoReportBuilder.WriteSummaryReport(config, result, logger);
+ result.RanToCompletion = true;
}
- var result = InvokeSonarScanner(provider, config);
- reportBuilder.GenerateReports(settings, config, result);
- return result.RanToCompletion;
+ return result;
}
private void LogStartupSettings(AnalysisConfig config, ITeamBuildSettings settings)
{
var configFileName = config == null ? string.Empty : config.FileName;
- logger.LogDebug(Resources.MSG_LoadingConfig, configFileName);
+ logger.LogDebug(Resources.MSG_LoadingConfig, configFileName, config != null ? SonarProduct.GetSonarProductToLog(config.SonarQubeHostUrl) : "Sonar");
switch (settings.BuildEnvironment)
{
@@ -179,12 +222,37 @@ private bool CheckCredentialsInCommandLineArgs(AnalysisConfig config, IAnalysisP
return true;
}
- private ProjectInfoAnalysisResult InvokeSonarScanner(IAnalysisPropertyProvider cmdLineArgs, AnalysisConfig config)
+ private void ProcessSummaryReportBuilder(AnalysisConfig config, bool ranToCompletion, String sonarAnalysisConfigFilePath, string propertiesFilePath)
+ {
+ IList args = new List();
+ args.Add("SummaryReportBuilder");
+ args.Add(sonarAnalysisConfigFilePath);
+ args.Add(propertiesFilePath);
+ args.Add(ranToCompletion.ToString());
+
+ logger.IncludeTimestamp = false;
+ this.tfsProcessor.Execute(config, args, propertiesFilePath);
+ logger.IncludeTimestamp = true;
+ }
+
+ private void ProcessCoverageReport(AnalysisConfig config, String sonarAnalysisConfigFilePath, String propertiesFilePath)
+ {
+ IList args = new List();
+ args.Add("ConvertCoverage");
+ args.Add(sonarAnalysisConfigFilePath);
+ args.Add(propertiesFilePath);
+
+ logger.IncludeTimestamp = false;
+ this.tfsProcessor.Execute(config, args, propertiesFilePath);
+ logger.IncludeTimestamp = true;
+ }
+
+ private bool InvokeSonarScanner(IAnalysisPropertyProvider cmdLineArgs, AnalysisConfig config, String propertiesFilePath)
{
var args = GetSonarScannerArgs(cmdLineArgs);
logger.IncludeTimestamp = false;
- var result = sonarScanner.Execute(config, args);
+ var result = sonarScanner.Execute(config, args, propertiesFilePath);
logger.IncludeTimestamp = true;
return result;
}
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.PostProcessor/Properties/AssemblyInfo.cs
index 36811d98e..8f3d07af0 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs b/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs
index 97bd9999a..abb0dadc1 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.PostProcessor {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -69,6 +69,15 @@ internal static string AssemblyDescription {
}
}
+ ///
+ /// Looks up a localized string similar to sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: {0}.
+ ///
+ internal static string ERR_ConflictingSonarProjectProperties {
+ get {
+ return ResourceManager.GetString("ERR_ConflictingSonarProjectProperties", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Inconsistent build environment settings: the build Uri in the analysis config file does not match the build uri from the environment variable.
///Build Uri from environment: {0}
@@ -92,7 +101,7 @@ internal static string ERROR_CmdLine_DisallowedArgument {
}
///
- /// Looks up a localized string similar to SonarQube analysis could not be completed because the analysis configuration file could not be found.
+ /// Looks up a localized string similar to The analysis could not be completed because the analysis configuration file could not be found.
///Expected location: {0}.
///
internal static string ERROR_ConfigFileNotFound {
@@ -111,7 +120,7 @@ internal static string ERROR_CredentialsNotSpecified {
}
///
- /// Looks up a localized string similar to Loading the SonarQube analysis config from {0}.
+ /// Looks up a localized string similar to Loading the {1} analysis config from {0}.
///
internal static string MSG_LoadingConfig {
get {
@@ -146,24 +155,6 @@ internal static string MSG_UninstallTargets_Uninstalling {
}
}
- ///
- /// Looks up a localized string similar to Analysis failed for SonarQube project {0}.
- ///
- internal static string Report_AnalysisFailed {
- get {
- return ResourceManager.GetString("Report_AnalysisFailed", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Analysis succeeded for SonarQube project {0} [(Analysis results)] ({1}).
- ///
- internal static string Report_AnalysisSucceeded {
- get {
- return ResourceManager.GetString("Report_AnalysisSucceeded", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Creating a summary markdown file....
///
@@ -173,15 +164,6 @@ internal static string Report_CreatingSummaryMarkdown {
}
}
- ///
- /// Looks up a localized string similar to Invalid projects: {0}, skipped projects: {1}, excluded projects: {2}.
- ///
- internal static string Report_InvalidSkippedAndExcludedMessage {
- get {
- return ResourceManager.GetString("Report_InvalidSkippedAndExcludedMessage", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Analysis failed for SonarQube project {0}.
///
@@ -218,33 +200,6 @@ internal static string Report_MdSummaryProductAndTestMessage {
}
}
- ///
- /// Looks up a localized string similar to Product projects: {0}, test projects: {1}.
- ///
- internal static string Report_ProductAndTestMessage {
- get {
- return ResourceManager.GetString("Report_ProductAndTestMessage", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to "{0}", version {2}.
- ///
- internal static string Report_SonarQubeProjectDescription {
- get {
- return ResourceManager.GetString("Report_SonarQubeProjectDescription", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Updating the TeamBuild summary....
- ///
- internal static string Report_UpdatingTeamBuildSummary {
- get {
- return ResourceManager.GetString("Report_UpdatingTeamBuildSummary", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Analysis base directory: {0}
///Build directory: {1}
@@ -294,14 +249,5 @@ internal static string WARN_CannotProcessCoverage {
return ResourceManager.GetString("WARN_CannotProcessCoverage", resourceCulture);
}
}
-
- ///
- /// Looks up a localized string similar to ** WARNING: Support for XAML builds is deprecated since version 4.1 and will be removed in version 5.0 of the Scanner for MSBuild **.
- ///
- internal static string WARN_XamlBuildDeprecated {
- get {
- return ResourceManager.GetString("WARN_XamlBuildDeprecated", resourceCulture);
- }
- }
}
}
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Resources.resx b/src/SonarScanner.MSBuild.PostProcessor/Resources.resx
index a0d7be3d5..4b12d1bfe 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Resources.resx
+++ b/src/SonarScanner.MSBuild.PostProcessor/Resources.resx
@@ -131,14 +131,17 @@ Please delete the analysis config file and try the build again.This setting is not valid in the "end" phase in this version of the C# plugin: {0}
- SonarQube analysis could not be completed because the analysis configuration file could not be found.
+ The analysis could not be completed because the analysis configuration file could not be found.
Expected location: {0}Credentials must be passed in both begin and end steps or not at all
+
+ sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: {0}
+
- Loading the SonarQube analysis config from {0}
+ Loading the {1} analysis config from {0}Could not delete {0} from {1}
@@ -149,18 +152,9 @@ Expected location: {0}
Uninstalling target: {0}\{1}
-
- Analysis failed for SonarQube project {0}
-
-
- Analysis succeeded for SonarQube project {0} [(Analysis results)] ({1})
-
Creating a summary markdown file...
-
- Invalid projects: {0}, skipped projects: {1}, excluded projects: {2}
-
Analysis failed for SonarQube project {0}
@@ -173,15 +167,6 @@ Expected location: {0}
- Product projects: {0}, test projects: {1}
-
- Product projects: {0}, test projects: {1}
-
-
- "{0}", version {2}
-
-
- Updating the TeamBuild summary...
-
Legacy TeamBuild environment detected
@@ -202,7 +187,4 @@ Config file: {5}
Cannot process the code coverage information. Look at the previous warnings for details.
-
- ** WARNING: Support for XAML builds is deprecated since version 4.1 and will be removed in version 5.0 of the Scanner for MSBuild **
-
\ No newline at end of file
diff --git a/src/SonarScanner.MSBuild.PostProcessor/SonarScanner.MSBuild.PostProcessor.csproj b/src/SonarScanner.MSBuild.PostProcessor/SonarScanner.MSBuild.PostProcessor.csproj
index 0b2281865..1c68f0d4e 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/SonarScanner.MSBuild.PostProcessor.csproj
+++ b/src/SonarScanner.MSBuild.PostProcessor/SonarScanner.MSBuild.PostProcessor.csproj
@@ -5,7 +5,6 @@
-
diff --git a/src/SonarScanner.MSBuild.PostProcessor/TargetsUninstaller.cs b/src/SonarScanner.MSBuild.PostProcessor/TargetsUninstaller.cs
index 221f16cf2..0fa207a8e 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/TargetsUninstaller.cs
+++ b/src/SonarScanner.MSBuild.PostProcessor/TargetsUninstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/AnalysisConfigGenerator.cs b/src/SonarScanner.MSBuild.PreProcessor/AnalysisConfigGenerator.cs
index 9f96c74f4..8e8eff4a2 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/AnalysisConfigGenerator.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/AnalysisConfigGenerator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild.PreProcessor
{
@@ -70,11 +69,12 @@ public static AnalysisConfig GenerateFile(ProcessedArgs localSettings,
SonarProjectVersion = localSettings.ProjectVersion,
SonarQubeHostUrl = localSettings.SonarQubeUrl,
HasBeginStepCommandLineCredentials = localSettings.CmdLineProperties.HasProperty(SonarProperties.SonarUserName),
- SonarQubeVersion = sonarQubeServer.GetServerVersion().ToString()
+ SonarQubeVersion = sonarQubeServer.GetServerVersion().Result.ToString()
};
config.SetBuildUri(buildSettings.BuildUri);
config.SetTfsUri(buildSettings.TfsUri);
+ config.SetVsCoverageConverterToolPath(buildSettings.CoverageToolUserSuppliedPath);
config.SonarConfigDir = buildSettings.SonarConfigDirectory;
config.SonarOutputDir = buildSettings.SonarOutputDirectory;
diff --git a/src/SonarScanner.MSBuild.PreProcessor/ArgumentProcessor.cs b/src/SonarScanner.MSBuild.PreProcessor/ArgumentProcessor.cs
index 32f495921..96952a272 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/ArgumentProcessor.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/ArgumentProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -143,7 +143,8 @@ public static ProcessedArgs TryProcessArgs(string[] commandLineArgs, ILogger log
installLoaderTargets,
cmdLineProperties,
globalFileProperties,
- scannerEnvProperties);
+ scannerEnvProperties,
+ logger);
if (!AreParsedArgumentsValid(processed, logger))
{
@@ -179,6 +180,11 @@ private static bool AreParsedArgumentsValid(ProcessedArgs args, ILogger logger)
areValid = false;
}
+ if (!args.IsOrganizationValid)
+ {
+ areValid = false;
+ }
+
return areValid;
}
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerInstaller.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerInstaller.cs
index f35f82de1..3676c0ead 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerInstaller.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerInstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerProvider.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerProvider.cs
index bfc8c4dbd..0530983d8 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerProvider.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IAnalyzerProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,7 +20,6 @@
using System.Collections.Generic;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
namespace SonarScanner.MSBuild.PreProcessor
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IDownloader.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IDownloader.cs
index 7ede203d3..a554d14ae 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IDownloader.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IDownloader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@
*/
using System;
+using System.Threading.Tasks;
namespace SonarScanner.MSBuild.PreProcessor
{
@@ -32,7 +33,7 @@ public interface IDownloader : IDisposable
///
/// False if the url does not exist, true if the contents were downloaded successfully.
/// Exceptions are thrown for other web failures.
- bool TryDownloadIfExists(string url, out string contents);
+ Task> TryDownloadIfExists(string url, bool logPermissionDenied = false);
///
/// Attempts to download the specified file
@@ -40,8 +41,10 @@ public interface IDownloader : IDisposable
/// The file to which the downloaded data should be saved
/// False if the url does not exist, true if the data was downloaded successfully.
/// Exceptions are thrown for other web failures.
- bool TryDownloadFileIfExists(string url, string targetFilePath);
+ Task TryDownloadFileIfExists(string url, string targetFilePath, bool logPermissionDenied = false);
- string Download(string url);
+ Task Download(string url, bool logPermissionDenied = false);
+
+ Task IsLicenseValid(string url);
}
}
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IPreprocessorObjectFactory.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IPreprocessorObjectFactory.cs
index ebe06a469..5dd8f5b22 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IPreprocessorObjectFactory.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/IPreprocessorObjectFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ISonarQubeServer.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ISonarQubeServer.cs
index 2ace299b3..bbfbfcf48 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ISonarQubeServer.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ISonarQubeServer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.Threading.Tasks;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
namespace SonarScanner.MSBuild.PreProcessor
@@ -29,24 +30,24 @@ namespace SonarScanner.MSBuild.PreProcessor
///
public interface ISonarQubeServer
{
- IList GetInactiveRules(string qprofile, string language);
+ Task> GetInactiveRules(string qprofile, string language);
- IList GetActiveRules(string qprofile);
+ Task> GetActiveRules(string qprofile);
///
/// Get all keys of all available languages
///
- IEnumerable GetAllLanguages();
+ Task> GetAllLanguages();
///
/// Get all the properties of a project
///
- IDictionary GetProperties(string projectKey, string projectBranch);
+ Task> GetProperties(string projectKey, string projectBranch);
///
/// Get the name of the quality profile (of the given language) to be used by the given project key
///
- bool TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language, out string qualityProfileKey);
+ Task> TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language);
///
/// Attempts to download a file embedded in the "static" folder in a plugin jar
@@ -54,8 +55,10 @@ public interface ISonarQubeServer
/// The key of the plugin containing the file
/// The name of the file to download
/// The directory to which the file should be downloaded
- bool TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory);
+ Task TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory);
- Version GetServerVersion();
+ Task GetServerVersion();
+
+ Task IsServerLicenseValid();
}
}
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITargetsInstaller.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITargetsInstaller.cs
index ab0e645d1..9606492d3 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITargetsInstaller.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITargetsInstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITeamBuildPreProcessor.cs b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITeamBuildPreProcessor.cs
index 4d55b6972..15995742c 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITeamBuildPreProcessor.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Interfaces/ITeamBuildPreProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,10 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+using System.Threading.Tasks;
+
namespace SonarScanner.MSBuild.PreProcessor
{
public interface ITeamBuildPreProcessor
{
- bool Execute(string[] args);
+ Task Execute(string[] args);
}
-}
\ No newline at end of file
+}
diff --git a/src/SonarScanner.MSBuild.PreProcessor/PreprocessorObjectFactory.cs b/src/SonarScanner.MSBuild.PreProcessor/PreprocessorObjectFactory.cs
index 46eaaeaa1..03b42ccc0 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/PreprocessorObjectFactory.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/PreprocessorObjectFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs b/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs
index bab1ffddf..5888e1261 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/ProcessedArgs.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -35,7 +35,7 @@ public class ProcessedArgs
public ProcessedArgs(string key, string name, string version, string organization, bool installLoaderTargets,
IAnalysisPropertyProvider cmdLineProperties, IAnalysisPropertyProvider globalFileProperties,
- IAnalysisPropertyProvider scannerEnvProperties)
+ IAnalysisPropertyProvider scannerEnvProperties, ILogger logger)
{
if (string.IsNullOrWhiteSpace(key))
{
@@ -46,12 +46,22 @@ public ProcessedArgs(string key, string name, string version, string organizatio
ProjectName = name;
ProjectVersion = version;
Organization = organization;
-
+
CmdLineProperties = cmdLineProperties ?? throw new ArgumentNullException(nameof(cmdLineProperties));
this.globalFileProperties = globalFileProperties ?? throw new ArgumentNullException(nameof(globalFileProperties));
ScannerEnvProperties = scannerEnvProperties ?? throw new ArgumentNullException(nameof(scannerEnvProperties));
InstallLoaderTargets = installLoaderTargets;
+ if (Organization == null && this.globalFileProperties.TryGetValue(SonarProperties.Organization, out var filePropertiesOrganization))
+ {
+ logger.LogError(Resources.ERROR_Organization_Provided_In_SonarQubeAnalysis_file);
+ IsOrganizationValid = false;
+ }
+ else
+ {
+ IsOrganizationValid = true;
+ }
+
AggregateProperties = new AggregatePropertiesProvider(cmdLineProperties, globalFileProperties, ScannerEnvProperties);
if (!AggregateProperties.TryGetValue(SonarProperties.HostUrl, out this.sonarQubeUrl))
{
@@ -59,6 +69,8 @@ public ProcessedArgs(string key, string name, string version, string organizatio
}
}
+ public bool IsOrganizationValid { get; set; }
+
public string ProjectKey { get; }
public string ProjectName { get; }
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.PreProcessor/Properties/AssemblyInfo.cs
index 04d16948d..b0969e9af 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Resources.Designer.cs b/src/SonarScanner.MSBuild.PreProcessor/Resources.Designer.cs
index 20f0cd826..afe0592f6 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.PreProcessor {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -88,7 +88,7 @@ internal static string CmdLine_ArgDescription_Organization {
}
///
- /// Looks up a localized string similar to /key:[SonarQube project key].
+ /// Looks up a localized string similar to /key:[SonarQube/SonarCloud project key].
///
internal static string CmdLine_ArgDescription_ProjectKey {
get {
@@ -97,7 +97,7 @@ internal static string CmdLine_ArgDescription_ProjectKey {
}
///
- /// Looks up a localized string similar to /name:[SonarQube project name] - required for SonarQube < 6.1.
+ /// Looks up a localized string similar to /name:[SonarQube/SonarCloud project name] - required for SonarQube < 6.1.
///
internal static string CmdLine_ArgDescription_ProjectName {
get {
@@ -106,7 +106,7 @@ internal static string CmdLine_ArgDescription_ProjectName {
}
///
- /// Looks up a localized string similar to /version:[SonarQube project version] - required for SonarQube < 6.1.
+ /// Looks up a localized string similar to /version:[SonarQube/SonarCloud project version] - required for SonarQube < 6.1.
///
internal static string CmdLine_ArgDescription_ProjectVersion {
get {
@@ -115,7 +115,16 @@ internal static string CmdLine_ArgDescription_ProjectVersion {
}
///
- /// Looks up a localized string similar to SonarQube pre-processing cannot be performed - required settings are missing.
+ /// Looks up a localized string similar to Your SonarQube instance seems to have an invalid license. Please check it. Server url : {0}.
+ ///
+ internal static string ERR_UnlicensedServer {
+ get {
+ return ResourceManager.GetString("ERR_UnlicensedServer", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to SonarScanner pre-processing cannot be performed - required settings are missing.
///
internal static string ERROR_CannotPerformProcessing {
get {
@@ -143,10 +152,7 @@ internal static string ERROR_DuplicateCheckId {
///
/// Looks up a localized string similar to Expecting at least the following command line argument:
- ///- SonarQube project key
- ///When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
- ///- SonarQube project name
- ///- SonarQube project version
+ ///- SonarQube/SonarCloud project key
///The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
///Use '/?' or '/h' to see the help message..
///
@@ -174,6 +180,15 @@ internal static string ERROR_MissingSetting {
}
}
+ ///
+ /// Looks up a localized string similar to sonar.organization parameter has been detected in the provided SonarQube.Analysis.xml config file. Please pass it in the command line instead, using /o: flag..
+ ///
+ internal static string ERROR_Organization_Provided_In_SonarQubeAnalysis_file {
+ get {
+ return ResourceManager.GetString("ERROR_Organization_Provided_In_SonarQubeAnalysis_file", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Internal error: cannot create an analyzer provider without a SonarQube server instance.
///
@@ -183,6 +198,24 @@ internal static string FACTORY_InternalError_MissingServer {
}
}
+ ///
+ /// Looks up a localized string similar to SonarQube Community Edition detected, license is valid..
+ ///
+ internal static string MSG_CE_Detected_LicenseValid {
+ get {
+ return ResourceManager.GetString("MSG_CE_Detected_LicenseValid", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Checking validity of server license.
+ ///
+ internal static string MSG_CheckingLicenseValidity {
+ get {
+ return ResourceManager.GetString("MSG_CheckingLicenseValidity", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Creating config and output folders....
///
@@ -273,6 +306,15 @@ internal static string MSG_FetchingQualityProfile {
}
}
+ ///
+ /// Looks up a localized string similar to To analyze private projects make sure the scanner user has 'Browse' permission..
+ ///
+ internal static string MSG_Forbidden_BrowsePermission {
+ get {
+ return ResourceManager.GetString("MSG_Forbidden_BrowsePermission", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Generating rulesets....
///
@@ -336,6 +378,15 @@ internal static string MSG_NotCopyingTargets {
}
}
+ ///
+ /// Looks up a localized string similar to SonarCloud detected, skipping license check..
+ ///
+ internal static string MSG_SonarCloudDetected_SkipLicenseCheck {
+ get {
+ return ResourceManager.GetString("MSG_SonarCloudDetected_SkipLicenseCheck", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Updating build integration targets....
///
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Resources.resx b/src/SonarScanner.MSBuild.PreProcessor/Resources.resx
index ef3f386dc..c0f3abb09 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Resources.resx
+++ b/src/SonarScanner.MSBuild.PreProcessor/Resources.resx
@@ -127,16 +127,16 @@
/organization:[Organization to which the project belongs]
- /key:[SonarQube project key]
+ /key:[SonarQube/SonarCloud project key]
- /name:[SonarQube project name] - required for SonarQube < 6.1
+ /name:[SonarQube/SonarCloud project name] - required for SonarQube < 6.1
- /version:[SonarQube project version] - required for SonarQube < 6.1
+ /version:[SonarQube/SonarCloud project version] - required for SonarQube < 6.1
- SonarQube pre-processing cannot be performed - required settings are missing
+ SonarScanner pre-processing cannot be performed - required settings are missingInvalid value for /install: {0}. Valid values are "true" or "false".
@@ -146,10 +146,7 @@
Expecting at least the following command line argument:
-- SonarQube project key
-When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
-- SonarQube project name
-- SonarQube project version
+- SonarQube/SonarCloud project key
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
@@ -159,9 +156,21 @@ Use '/?' or '/h' to see the help message.
Missing analysis setting: {0}
+
+ sonar.organization parameter has been detected in the provided SonarQube.Analysis.xml config file. Please pass it in the command line instead, using /o: flag.
+
+
+ Your SonarQube instance seems to have an invalid license. Please check it. Server url : {0}
+
Internal error: cannot create an analyzer provider without a SonarQube server instance
+
+ SonarQube Community Edition detected, license is valid.
+
+
+ Checking validity of server license
+
Creating config and output folders...
@@ -192,6 +201,9 @@ Use '/?' or '/h' to see the help message.
Fetching quality profile for project '{0}' from {1}...
+
+ To analyze private projects make sure the scanner user has 'Browse' permission.
+
Generating rulesets...
@@ -213,6 +225,9 @@ Use '/?' or '/h' to see the help message.
Skipping installing the ImportsBefore targets file
+
+ SonarCloud detected, skipping license check.
+
Updating build integration targets...
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/ActiveRule.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/ActiveRule.cs
index 3153846e8..6e4711ee2 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/ActiveRule.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/ActiveRule.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/EmbeddedAnalyzerInstaller.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/EmbeddedAnalyzerInstaller.cs
index 350055e0a..7870df532 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/EmbeddedAnalyzerInstaller.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/EmbeddedAnalyzerInstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -158,7 +158,7 @@ private bool FetchResourceFromServer(Plugin plugin, string targetDir)
Directory.CreateDirectory(targetDir);
- var success = this.server.TryDownloadEmbeddedFile(plugin.Key, plugin.StaticResourceName, targetDir);
+ var success = this.server.TryDownloadEmbeddedFile(plugin.Key, plugin.StaticResourceName, targetDir).Result;
if (success)
{
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/Model/Plugin.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/Model/Plugin.cs
index 635505478..a780b89c0 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/Model/Plugin.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/Model/Plugin.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/PluginResourceCache.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/PluginResourceCache.cs
index 85fa36a42..817b5968e 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/PluginResourceCache.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/PluginResourceCache.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
index d2cc40fd9..cc927677e 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynAnalyzerProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -25,7 +25,6 @@
using System.Linq;
using SonarScanner.MSBuild.Common;
using SonarScanner.MSBuild.PreProcessor.Roslyn.Model;
-using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild.PreProcessor.Roslyn
{
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynRuleSetGenerator.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynRuleSetGenerator.cs
index 1a0eebdcc..f9b9127de 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynRuleSetGenerator.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynRuleSetGenerator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynSonarLint.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynSonarLint.cs
index a70875c7b..7d42204c0 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynSonarLint.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RoslynSonarLint.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RuleAction.cs b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RuleAction.cs
index ffe890dbb..aeb9a0cf4 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RuleAction.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/Roslyn/RuleAction.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/RulesetWriter.cs b/src/SonarScanner.MSBuild.PreProcessor/RulesetWriter.cs
index 4627519b3..99a7fcf59 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/RulesetWriter.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/RulesetWriter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PreProcessor/SonarScanner.MSBuild.PreProcessor.csproj b/src/SonarScanner.MSBuild.PreProcessor/SonarScanner.MSBuild.PreProcessor.csproj
index 9b7c2f6be..b04e00325 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/SonarScanner.MSBuild.PreProcessor.csproj
+++ b/src/SonarScanner.MSBuild.PreProcessor/SonarScanner.MSBuild.PreProcessor.csproj
@@ -11,10 +11,10 @@
-
-
+
+
diff --git a/src/SonarScanner.MSBuild.PreProcessor/SonarWebService.cs b/src/SonarScanner.MSBuild.PreProcessor/SonarWebService.cs
index 288d2e0aa..ad3af928e 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/SonarWebService.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/SonarWebService.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SonarScanner.MSBuild.Common;
@@ -52,22 +53,25 @@ public SonarWebService(IDownloader downloader, string server, ILogger logger)
#region ISonarQubeServer interface
- public bool TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language, out string qualityProfileKey)
+ public async Task> TryGetQualityProfile(string projectKey, string projectBranch, string organization, string language)
{
var projectId = GetProjectIdentifier(projectKey, projectBranch);
- var ws = AddOrganization(GetUrl("/api/qualityprofiles/search?projectKey={0}", projectId), organization);
+ var ws = await AddOrganization(GetUrl("/api/qualityprofiles/search?project={0}", projectId), organization);
this.logger.LogDebug(Resources.MSG_FetchingQualityProfile, projectId, ws);
- qualityProfileKey = DoLogExceptions(() =>
+ var qualityProfileKey = await DoLogExceptions(async () =>
{
- if (!this.downloader.TryDownloadIfExists(ws, out var contents))
+ var result = await this.downloader.TryDownloadIfExists(ws);
+ string contents = result.Item2;
+ if (!result.Item1)
{
- ws = AddOrganization(GetUrl("/api/qualityprofiles/search?defaults=true"), organization);
+ ws = await AddOrganization(GetUrl("/api/qualityprofiles/search?defaults=true"), organization);
this.logger.LogDebug(Resources.MSG_FetchingQualityProfile, projectId, ws);
- contents = this.downloader.Download(ws);
+ contents = await this.downloader.Download(ws);
}
+
var json = JObject.Parse(contents);
var profiles = json["profiles"].Children();
@@ -80,7 +84,7 @@ public bool TryGetQualityProfile(string projectKey, string projectBranch, string
return profile["key"].ToString();
}, ws);
- return qualityProfileKey != null;
+ return new Tuple(qualityProfileKey != null, qualityProfileKey);
}
///
@@ -90,7 +94,7 @@ public bool TryGetQualityProfile(string projectKey, string projectBranch, string
/// Quality profile key.
/// Rule Language.
/// Non-activated rule keys, including repo. Example: csharpsquid:S1100
- public IList GetInactiveRules(string qprofile, string language)
+ public async Task> GetInactiveRules(string qprofile, string language)
{
var fetched = 0;
var page = 1;
@@ -102,9 +106,9 @@ public IList GetInactiveRules(string qprofile, string language)
var ws = GetUrl("/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params&ps=500&activation=false&qprofile={0}&p={1}&languages={2}", qprofile, page.ToString(), language);
this.logger.LogDebug(Resources.MSG_FetchingInactiveRules, qprofile, language, ws);
- ruleList.AddRange(DoLogExceptions(() =>
+ ruleList.AddRange(await DoLogExceptions(async () =>
{
- var contents = this.downloader.Download(ws);
+ var contents = await this.downloader.Download(ws);
var json = JObject.Parse(contents);
total = json["total"].ToObject();
fetched += json["ps"].ToObject();
@@ -124,7 +128,7 @@ public IList GetInactiveRules(string qprofile, string language)
///
/// Quality profile id.
/// List of active rules
- public IList GetActiveRules(string qprofile)
+ public async Task> GetActiveRules(string qprofile)
{
var fetched = 0;
var page = 1;
@@ -136,9 +140,9 @@ public IList GetActiveRules(string qprofile)
var ws = GetUrl("/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile={0}&p={1}", qprofile, page.ToString());
this.logger.LogDebug(Resources.MSG_FetchingActiveRules, qprofile, ws);
- activeRuleList.AddRange(DoLogExceptions(() =>
+ activeRuleList.AddRange(await DoLogExceptions(async () =>
{
- var contents = this.downloader.Download(ws);
+ var contents = await this.downloader.Download(ws);
var json = JObject.Parse(contents);
total = json["total"].ToObject();
fetched += json["ps"].ToObject();
@@ -149,35 +153,7 @@ public IList GetActiveRules(string qprofile)
return rules.Select(r =>
{
- var activeRulesForRuleKey = actives.Value(r["key"].ToString());
-
- if (activeRulesForRuleKey == null ||
- activeRulesForRuleKey.Count != 1)
- {
- // Because of the parameters we use we expect to have only actives rules. So rules and actives
- // should both contain the same number of elements (i.e. the same rules).
- throw new JsonException($"Malformed json response, \"actives\" field should contain rule '{r["key"].ToString()}'");
- }
-
- var activeRule = new SonarRule(r["repo"].ToString(), ParseRuleKey(r["key"].ToString()), true);
- if (r["internalKey"] != null)
- {
- activeRule.InternalKey = r["internalKey"].ToString();
- }
- if (r["templateKey"] != null)
- {
- activeRule.TemplateKey = r["templateKey"].ToString();
- }
-
- var activeRuleParams = activeRulesForRuleKey[0]["params"].Children();
- activeRule.Parameters = activeRuleParams.ToDictionary(pair => pair["key"].ToString(), pair => pair["value"].ToString());
-
- if (activeRule.Parameters.ContainsKey("CheckId"))
- {
- activeRule.RuleKey = activeRule.Parameters["CheckId"];
- }
-
- return activeRule;
+ return FilterRule(r, actives);
});
}, ws));
} while (fetched < total);
@@ -185,6 +161,65 @@ public IList GetActiveRules(string qprofile)
return activeRuleList;
}
+ private async Task IsSonarCloud()
+ {
+ var version = await GetServerVersion();
+ if (version.CompareTo(new Version(8, 0)) < 0 || version.CompareTo(new Version(8, 1)) >= 0)
+ return false;
+ else
+ {
+ return this.serverUrl.Contains("sonarcloud.io") || version != new Version(8, 0, 0, 29455); //this is the build number of SQ 8.0
+ }
+ }
+
+ public async Task IsServerLicenseValid()
+ {
+ if (await IsSonarCloud())
+ {
+ this.logger.LogDebug(Resources.MSG_SonarCloudDetected_SkipLicenseCheck);
+ return true;
+ }
+ else
+ {
+ this.logger.LogDebug(Resources.MSG_CheckingLicenseValidity);
+ var ws = GetUrl("/api/editions/is_valid_license");
+ return await this.downloader.IsLicenseValid(ws);
+ }
+ }
+
+ private static SonarRule FilterRule(JObject r, JToken actives)
+ {
+ var activeRulesForRuleKey = actives.Value(r["key"].ToString());
+
+ if (activeRulesForRuleKey == null ||
+ activeRulesForRuleKey.Count != 1)
+ {
+ // Because of the parameters we use we expect to have only actives rules. So rules and actives
+ // should both contain the same number of elements (i.e. the same rules).
+ throw new JsonException($"Malformed json response, \"actives\" field should contain rule '{r["key"].ToString()}'");
+ }
+
+ var activeRule = new SonarRule(r["repo"].ToString(), ParseRuleKey(r["key"].ToString()), true);
+ if (r["internalKey"] != null)
+ {
+ activeRule.InternalKey = r["internalKey"].ToString();
+ }
+ if (r["templateKey"] != null)
+ {
+ activeRule.TemplateKey = r["templateKey"].ToString();
+ }
+
+ var activeRuleParams = activeRulesForRuleKey[0]["params"].Children();
+ activeRule.Parameters = activeRuleParams.ToDictionary(pair => pair["key"].ToString(), pair => pair["value"].ToString());
+
+ if (activeRule.Parameters.ContainsKey("CheckId"))
+ {
+ activeRule.RuleKey = activeRule.Parameters["CheckId"];
+ }
+
+ return activeRule;
+ }
+
///
/// Retrieves project properties from the server.
///
@@ -194,46 +229,47 @@ public IList GetActiveRules(string qprofile)
/// The SonarQube project branch to retrieve properties for (optional).
/// A dictionary of key-value property pairs.
///
- public IDictionary GetProperties(string projectKey, string projectBranch)
+ public async Task> GetProperties(string projectKey, string projectBranch)
{
if (string.IsNullOrWhiteSpace(projectKey))
{
throw new ArgumentNullException(nameof(projectKey));
}
+
var projectId = GetProjectIdentifier(projectKey, projectBranch);
- if (GetServerVersion().CompareTo(new Version(6, 3)) >= 0)
+ if (await IsSonarCloud() || (await GetServerVersion()).CompareTo(new Version(6, 3)) >= 0)
{
- return GetProperties63(projectId);
+ return await GetComponentProperties(projectId);
}
else
{
- return GetPropertiesOld(projectId);
+ return await GetComponentPropertiesLegacy(projectId);
}
}
- public Version GetServerVersion()
+ public async Task GetServerVersion()
{
if (this.serverVersion == null)
{
- DownloadServerVersion();
+ await DownloadServerVersion();
}
return this.serverVersion;
}
- public IEnumerable GetAllLanguages()
+ public async Task> GetAllLanguages()
{
var ws = GetUrl("/api/languages/list");
- return DoLogExceptions(() =>
+ return await DoLogExceptions(async () =>
{
- var contents = this.downloader.Download(ws);
+ var contents = await this.downloader.Download(ws);
var langArray = JObject.Parse(contents).Value("languages");
return langArray.Select(obj => obj["key"].ToString());
}, ws);
}
- public bool TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory)
+ public async Task TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, string targetDirectory)
{
if (string.IsNullOrWhiteSpace(pluginKey))
{
@@ -250,12 +286,12 @@ public bool TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, s
var url = GetUrl("/static/{0}/{1}", pluginKey, embeddedFileName);
- return DoLogExceptions(() =>
+ return await DoLogExceptions(async () =>
{
var targetFilePath = Path.Combine(targetDirectory, embeddedFileName);
this.logger.LogDebug(Resources.MSG_DownloadingZip, embeddedFileName, url, targetDirectory);
- return this.downloader.TryDownloadFileIfExists(url, targetFilePath);
+ return await this.downloader.TryDownloadFileIfExists(url, targetFilePath);
}, url);
}
@@ -263,13 +299,13 @@ public bool TryDownloadEmbeddedFile(string pluginKey, string embeddedFileName, s
#region Private methods
- private string AddOrganization(string encodedUrl, string organization)
+ private async Task AddOrganization(string encodedUrl, string organization)
{
if (string.IsNullOrEmpty(organization))
{
return encodedUrl;
}
- var version = GetServerVersion();
+ var version = await GetServerVersion();
if (version.CompareTo(new Version(6, 3)) >= 0)
{
return EscapeQuery(encodedUrl + "&organization={0}", organization);
@@ -278,62 +314,61 @@ private string AddOrganization(string encodedUrl, string organization)
return encodedUrl;
}
- private T DoLogExceptions(Func op, string url, Action onError = null)
+ private async Task DoLogExceptions(Func> op, string url)
{
try
{
- return op();
+ return await op();
}
catch (Exception e)
{
- onError?.Invoke(e);
-
this.logger.LogError("Failed to request and parse '{0}': {1}", url, e.Message);
throw;
}
}
- private void DownloadServerVersion()
+ private async Task DownloadServerVersion()
{
var ws = GetUrl("api/server/version");
- this.serverVersion = DoLogExceptions(() =>
+ this.serverVersion = await DoLogExceptions(async () =>
{
- var contents = this.downloader.Download(ws);
+ var contents = await this.downloader.Download(ws);
var separator = contents.IndexOf('-');
return separator >= 0 ? new Version(contents.Substring(0, separator)) : new Version(contents);
}, ws);
}
- private IDictionary GetPropertiesOld(string projectId)
+ private async Task> GetComponentPropertiesLegacy(string projectId)
{
var ws = GetUrl("/api/properties?resource={0}", projectId);
this.logger.LogDebug(Resources.MSG_FetchingProjectProperties, projectId, ws);
- var result = DoLogExceptions(() =>
+ var result = await DoLogExceptions(async () =>
{
- var contents = this.downloader.Download(ws);
+ var contents = await this.downloader.Download(ws, true);
var properties = JArray.Parse(contents);
return properties.ToDictionary(p => p["key"].ToString(), p => p["value"].ToString());
- }, ws, LogPermissionRequired);
+ }, ws);
return CheckTestProjectPattern(result);
}
- private IDictionary GetProperties63(string projectId)
+ private async Task> GetComponentProperties(string projectId)
{
var ws = GetUrl("/api/settings/values?component={0}", projectId);
this.logger.LogDebug(Resources.MSG_FetchingProjectProperties, projectId, ws);
- var contents = string.Empty;
- var projectFound = DoLogExceptions(() => this.downloader.TryDownloadIfExists(ws, out contents), ws, LogPermissionRequired);
+ var projectFound = await DoLogExceptions(async() => await this.downloader.TryDownloadIfExists(ws, true), ws);
+
+ var contents = projectFound?.Item2;
- if (!projectFound)
+ if (projectFound != null && !projectFound.Item1)
{
ws = GetUrl("/api/settings/values");
this.logger.LogDebug("No settings for project {0}. Getting global settings: {1}", projectId, ws);
- contents = DoLogExceptions(() => this.downloader.Download(ws), ws);
+ contents = await DoLogExceptions(async() => await this.downloader.Download(ws), ws);
}
- return DoLogExceptions(() => ParseSettingsResponse(contents), ws);
+ return await DoLogExceptions(async() => ParseSettingsResponse(contents), ws);
}
private Dictionary ParseSettingsResponse(string contents)
@@ -442,16 +477,6 @@ private string EscapeQuery(string format, params string[] args)
return string.Format(System.Globalization.CultureInfo.InvariantCulture, format, args.Select(a => WebUtility.UrlEncode(a)).ToArray());
}
- private void LogPermissionRequired(Exception e)
- {
- if (e is WebException exception &&
- exception.Response is HttpWebResponse response &&
- response.StatusCode == HttpStatusCode.Forbidden)
- {
- this.logger.LogWarning("To analyze private projects make sure the scanner user has 'Browse' permission.");
- }
- }
-
#endregion Private methods
#region IDisposable Support
diff --git a/src/SonarScanner.MSBuild.PreProcessor/TargetsInstaller.cs b/src/SonarScanner.MSBuild.PreProcessor/TargetsInstaller.cs
index 0a6b83f24..41e60cd11 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/TargetsInstaller.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/TargetsInstaller.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@ namespace SonarScanner.MSBuild.PreProcessor
///
public class TargetsInstaller : ITargetsInstaller
{
- private static readonly string AssemblyLocation = Path.GetDirectoryName(typeof(TeamBuildPreProcessor).Assembly.Location);
+ private static readonly string AssemblyLocation = Path.GetDirectoryName(typeof(ArgumentProcessor).Assembly.Location);
///
/// Controls the default value for installing the loader targets.
diff --git a/src/SonarScanner.MSBuild.PreProcessor/TeamBuildPreProcessor.cs b/src/SonarScanner.MSBuild.PreProcessor/TeamBuildPreProcessor.cs
index 66b2a4afc..b838ee2b0 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/TeamBuildPreProcessor.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/TeamBuildPreProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -24,8 +24,8 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Threading.Tasks;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild.PreProcessor
{
@@ -77,7 +77,7 @@ public PluginDefinition(string language, string pluginKey)
#region Public methods
- public bool Execute(string[] args)
+ public async Task Execute(string[] args)
{
this.logger.SuspendOutput();
var processedArgs = ArgumentProcessor.TryProcessArgs(args, this.logger);
@@ -90,11 +90,11 @@ public bool Execute(string[] args)
}
else
{
- return DoExecute(processedArgs);
+ return await DoExecute(processedArgs);
}
}
- private bool DoExecute(ProcessedArgs localSettings)
+ private async Task DoExecute(ProcessedArgs localSettings)
{
Debug.Assert(localSettings != null, "Not expecting the process arguments to be null");
@@ -122,14 +122,20 @@ private bool DoExecute(ProcessedArgs localSettings)
}
var server = this.factory.CreateSonarQubeServer(localSettings);
- if (!FetchArgumentsAndRulesets(server, localSettings, teamBuildSettings, out var serverSettings, out var analyzersSettings))
+ if (!await server.IsServerLicenseValid())
{
+ this.logger.LogError(Resources.ERR_UnlicensedServer, localSettings.SonarQubeUrl);
return false;
}
- Debug.Assert(analyzersSettings != null, "Not expecting the analyzers settings to be null");
+ var argumentsAndRuleSets = await FetchArgumentsAndRulesets(server, localSettings, teamBuildSettings);
+ if (!argumentsAndRuleSets.IsSuccess)
+ {
+ return false;
+ }
+ Debug.Assert(argumentsAndRuleSets.AnalyzersSettings != null, "Not expecting the analyzers settings to be null");
// analyzerSettings can be empty
- AnalysisConfigGenerator.GenerateFile(localSettings, teamBuildSettings, serverSettings, analyzersSettings, server, this.logger);
+ AnalysisConfigGenerator.GenerateFile(localSettings, teamBuildSettings, argumentsAndRuleSets.ServerSettings, argumentsAndRuleSets.AnalyzersSettings, server, this.logger);
return true;
}
@@ -152,10 +158,9 @@ private void InstallLoaderTargets(ProcessedArgs args)
}
}
- private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, out IDictionary serverSettings, out List analyzersSettings)
+ private async Task FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings)
{
- serverSettings = null;
- analyzersSettings = new List();
+ ArgumentsAndRuleSets argumentsAndRuleSets = new ArgumentsAndRuleSets();
try
{
@@ -165,10 +170,10 @@ private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs ar
args.TryGetSetting(SonarProperties.ProjectBranch, out var projectBranch);
// Fetch the SonarQube project properties
- serverSettings = server.GetProperties(args.ProjectKey, projectBranch);
+ argumentsAndRuleSets.ServerSettings = await server.GetProperties(args.ProjectKey, projectBranch);
// Fetch installed plugins
- var availableLanguages = server.GetAllLanguages();
+ var availableLanguages = await server.GetAllLanguages();
foreach (var plugin in plugins)
{
@@ -177,22 +182,24 @@ private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs ar
continue;
}
+ var qualityProfile = await server.TryGetQualityProfile(args.ProjectKey, projectBranch, args.Organization, plugin.Language);
+
// Fetch project quality profile
- if (!server.TryGetQualityProfile(args.ProjectKey, projectBranch, args.Organization, plugin.Language, out var qualityProfile))
+ if (!qualityProfile.Item1)
{
this.logger.LogDebug(Resources.RAP_NoQualityProfile, plugin.Language, args.ProjectKey);
continue;
}
// Fetch rules (active and not active)
- var activeRules = server.GetActiveRules(qualityProfile);
+ var activeRules = await server.GetActiveRules(qualityProfile.Item2);
if (!activeRules.Any())
{
this.logger.LogDebug(Resources.RAP_NoActiveRules, plugin.Language);
}
- var inactiveRules = server.GetInactiveRules(qualityProfile, plugin.Language);
+ var inactiveRules = await server.GetInactiveRules(qualityProfile.Item2, plugin.Language);
// Generate Roslyn analyzers settings and rulesets
var analyzerProvider = this.factory.CreateRoslynAnalyzerProvider();
@@ -202,13 +209,13 @@ private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs ar
// Use the aggregate of local and server properties when generating the analyzer configuration
// See bug 699: https://github.com/SonarSource/sonar-scanner-msbuild/issues/699
- var serverProperties = new ListPropertiesProvider(serverSettings);
+ var serverProperties = new ListPropertiesProvider(argumentsAndRuleSets.ServerSettings);
var allProperties = new AggregatePropertiesProvider(args.AggregateProperties, serverProperties);
var analyzer = analyzerProvider.SetupAnalyzer(settings, allProperties, activeRules, inactiveRules, plugin.Language);
if (analyzer != null)
{
- analyzersSettings.Add(analyzer);
+ argumentsAndRuleSets.AnalyzersSettings.Add(analyzer);
}
}
}
@@ -216,7 +223,8 @@ private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs ar
{
if (Utilities.HandleHostUrlWebException(ex, args.SonarQubeUrl, this.logger))
{
- return false;
+ argumentsAndRuleSets.IsSuccess = false;
+ return argumentsAndRuleSets;
}
throw;
@@ -226,9 +234,24 @@ private bool FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs ar
Utilities.SafeDispose(server);
}
- return true;
+ argumentsAndRuleSets.IsSuccess = true;
+ return argumentsAndRuleSets;
}
#endregion Private methods
+
+ public class ArgumentsAndRuleSets
+ {
+ public ArgumentsAndRuleSets()
+ {
+ AnalyzersSettings = new List();
+ }
+
+ public bool IsSuccess { get; set; }
+
+ public IDictionary ServerSettings { get; set; }
+
+ public List AnalyzersSettings { get; set; }
+ }
}
}
diff --git a/src/SonarScanner.MSBuild.PreProcessor/WebClientDownloader.cs b/src/SonarScanner.MSBuild.PreProcessor/WebClientDownloader.cs
index 09bf579bb..19cb156df 100644
--- a/src/SonarScanner.MSBuild.PreProcessor/WebClientDownloader.cs
+++ b/src/SonarScanner.MSBuild.PreProcessor/WebClientDownloader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,9 +19,14 @@
*/
using System;
+using System.IO;
using System.Linq;
using System.Net;
+using System.Net.Http;
using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using SonarScanner.MSBuild.Common;
namespace SonarScanner.MSBuild.PreProcessor
@@ -29,41 +34,24 @@ namespace SonarScanner.MSBuild.PreProcessor
public class WebClientDownloader : IDownloader
{
private readonly ILogger logger;
- private readonly PersistentUserAgentWebClient client;
-
- // WebClient resets certain headers after each request: Accept, Connection, Content-Type, Expect, Referer, User-Agent.
- // This class keeps the User Agent across requests.
- // See https://github.com/SonarSource/sonar-scanner-msbuild/issues/459
- private class PersistentUserAgentWebClient : WebClient
- {
- public string UserAgent { get; private set; }
-
- public PersistentUserAgentWebClient(string userAgent)
- {
- UserAgent = userAgent;
- }
-
- protected override WebRequest GetWebRequest(Uri address)
- {
- var request = base.GetWebRequest(address) as HttpWebRequest;
- request.UserAgent = UserAgent;
- return request;
- }
- }
+ private readonly HttpClient client;
public WebClientDownloader(string userName, string password, ILogger logger)
{
- this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
-
- // SONARMSBRU-169 Support TLS versions 1.0, 1.1 and 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
+ this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
if (password == null)
{
password = "";
}
- this.client = new PersistentUserAgentWebClient($"ScannerMSBuild/{Utilities.ScannerVersion}");
+ if (this.client == null)
+ {
+ this.client = new HttpClient();
+ this.client.DefaultRequestHeaders.Add(HttpRequestHeader.UserAgent.ToString(), $"ScannerMSBuild/{Utilities.ScannerVersion}");
+ }
if (userName != null)
{
@@ -78,38 +66,133 @@ public WebClientDownloader(string userName, string password, ILogger logger)
var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:{1}", userName, password);
credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials));
- this.client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
+ this.client.DefaultRequestHeaders.Add(HttpRequestHeader.Authorization.ToString(), "Basic " + credentials);
}
}
public string GetHeader(HttpRequestHeader header)
{
- return header == HttpRequestHeader.UserAgent
- ? this.client.UserAgent
- : this.client.Headers[header];
+ if (this.client.DefaultRequestHeaders.Contains(header.ToString()))
+ {
+ return string.Join(";", this.client.DefaultRequestHeaders.GetValues(header.ToString()));
+ }
+
+ return null;
}
#region IDownloaderMethods
+ public async Task IsLicenseValid(string url)
+ {
+ this.logger.LogDebug(Resources.MSG_Downloading, url);
+ var response = await this.client.GetAsync(url);
+
+ var content = await response.Content.ReadAsStringAsync();
+
+ if (response.StatusCode == HttpStatusCode.NotFound)
+ {
+ var json = JObject.Parse(content);
+
+ if (json["errors"] != null)
+ {
+ return false;
+ }
+
+ this.logger.LogDebug(Resources.MSG_CE_Detected_LicenseValid);
+ return true; //High probability that this is a SQ CE edition.
+ }
+ else
+ {
+ try
+ {
+ var responseContent = await response.Content.ReadAsStringAsync();
+ var json = JObject.Parse(responseContent);
+
+ return json["isValidLicense"].ToObject();
+ }
+ catch
+ {
+ this.logger.LogWarning("Failed to fetch license status from server.");
+ return false;
+ }
+ }
+ }
- public bool TryDownloadIfExists(string url, out string contents)
+ public async Task> TryDownloadIfExists(string url, bool logPermissionDenied = false)
{
this.logger.LogDebug(Resources.MSG_Downloading, url);
- string data = null;
- var success = DoIgnoringMissingUrls(() => data = this.client.DownloadString(url));
- contents = data;
- return success;
+ var response = await this.client.GetAsync(url);
+
+ if (response.IsSuccessStatusCode)
+ {
+ return new Tuple(true, await response.Content.ReadAsStringAsync());
+ }
+
+ switch (response.StatusCode)
+ {
+ case HttpStatusCode.NotFound:
+ return new Tuple(false, null);
+ case HttpStatusCode.Forbidden:
+ if (logPermissionDenied)
+ this.logger.LogWarning(Resources.MSG_Forbidden_BrowsePermission);
+ response.EnsureSuccessStatusCode();
+ break;
+ default:
+ response.EnsureSuccessStatusCode();
+ break;
+ }
+
+ return new Tuple(false, null);
}
- public bool TryDownloadFileIfExists(string url, string targetFilePath)
+ public async Task TryDownloadFileIfExists(string url, string targetFilePath, bool logPermissionDenied = false)
{
this.logger.LogDebug(Resources.MSG_DownloadingFile, url, targetFilePath);
- return DoIgnoringMissingUrls(() => this.client.DownloadFile(url, targetFilePath));
+ var response = await this.client.GetAsync(url);
+
+ if (response.IsSuccessStatusCode)
+ {
+ using (var contentStream = await response.Content.ReadAsStreamAsync())
+ using (var fileStream = new FileStream(targetFilePath, FileMode.Create, FileAccess.Write))
+ {
+ await contentStream.CopyToAsync(fileStream);
+ return true;
+ }
+ }
+
+ switch (response.StatusCode)
+ {
+ case HttpStatusCode.NotFound:
+ return false;
+ case HttpStatusCode.Forbidden:
+ if (logPermissionDenied)
+ this.logger.LogWarning(Resources.MSG_Forbidden_BrowsePermission);
+ response.EnsureSuccessStatusCode();
+ break;
+ default:
+ response.EnsureSuccessStatusCode();
+ break;
+ }
+
+ return false;
}
- public string Download(string url)
+ public async Task Download(string url, bool logPermissionDenied = false)
{
this.logger.LogDebug(Resources.MSG_Downloading, url);
- return this.client.DownloadString(url);
+ var response = await this.client.GetAsync(url);
+
+ if (response.IsSuccessStatusCode)
+ {
+ return await response.Content.ReadAsStringAsync();
+ }
+
+ if (logPermissionDenied && response.StatusCode == HttpStatusCode.Forbidden)
+ {
+ this.logger.LogWarning(Resources.MSG_Forbidden_BrowsePermission);
+ response.EnsureSuccessStatusCode();
+ }
+
+ return null;
}
#endregion IDownloaderMethods
@@ -121,28 +204,6 @@ private static bool IsAscii(string s)
return !s.Any(c => c > sbyte.MaxValue);
}
- ///
- /// Performs the specified web operation
- ///
- /// True if the operation completed successfully, false if the url could not be found.
- /// Other web failures will be thrown as exceptions.
- private static bool DoIgnoringMissingUrls(Action op)
- {
- try
- {
- op();
- return true;
- }
- catch (WebException e)
- {
- if (e.Response is HttpWebResponse response && response.StatusCode == HttpStatusCode.NotFound)
- {
- return false;
- }
- throw;
- }
- }
-
#endregion Private methods
#region IDisposable implementation
diff --git a/src/SonarScanner.MSBuild.Shim/AnalysisConfigExtensions.cs b/src/SonarScanner.MSBuild.Shim/AnalysisConfigExtensions.cs
index 5eaaa6984..0e7cd7510 100644
--- a/src/SonarScanner.MSBuild.Shim/AnalysisConfigExtensions.cs
+++ b/src/SonarScanner.MSBuild.Shim/AnalysisConfigExtensions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/Interfaces/IPropertiesFileGenerator.cs b/src/SonarScanner.MSBuild.Shim/Interfaces/IPropertiesFileGenerator.cs
new file mode 100644
index 000000000..fb54d0735
--- /dev/null
+++ b/src/SonarScanner.MSBuild.Shim/Interfaces/IPropertiesFileGenerator.cs
@@ -0,0 +1,33 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System.IO;
+using System.Collections.Generic;
+
+namespace SonarScanner.MSBuild.Shim.Interfaces
+{
+ public interface IPropertiesFileGenerator
+ {
+ ProjectInfoAnalysisResult GenerateFile();
+ bool TryWriteProperties(PropertiesWriter writer, out IEnumerable allProjects);
+ DirectoryInfo ComputeRootProjectBaseDir(IEnumerable projectPaths);
+
+ }
+}
diff --git a/src/SonarScanner.MSBuild.Shim/IRoslynV1SarifFixer.cs b/src/SonarScanner.MSBuild.Shim/Interfaces/IRoslynV1SarifFixer.cs
similarity index 91%
rename from src/SonarScanner.MSBuild.Shim/IRoslynV1SarifFixer.cs
rename to src/SonarScanner.MSBuild.Shim/Interfaces/IRoslynV1SarifFixer.cs
index c64c4fa30..5a3033ba9 100644
--- a/src/SonarScanner.MSBuild.Shim/IRoslynV1SarifFixer.cs
+++ b/src/SonarScanner.MSBuild.Shim/Interfaces/IRoslynV1SarifFixer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using SonarScanner.MSBuild.Common;
-
-namespace SonarScanner.MSBuild.Shim
+namespace SonarScanner.MSBuild.Shim.Interfaces
{
public interface IRoslynV1SarifFixer
{
diff --git a/src/SonarQube.Old.Bootstrapper/Program.cs b/src/SonarScanner.MSBuild.Shim/Interfaces/ISonarProjectPropertiesValidator.cs
similarity index 71%
rename from src/SonarQube.Old.Bootstrapper/Program.cs
rename to src/SonarScanner.MSBuild.Shim/Interfaces/ISonarProjectPropertiesValidator.cs
index c0d3357ad..78bc01189 100644
--- a/src/SonarQube.Old.Bootstrapper/Program.cs
+++ b/src/SonarScanner.MSBuild.Shim/Interfaces/ISonarProjectPropertiesValidator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,11 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-namespace MSBuild.SonarQube.Runner
+using System.Collections.Generic;
+
+namespace SonarScanner.MSBuild.Shim.Interfaces
{
- internal static class Program
+ public interface ISonarProjectPropertiesValidator
{
- private static int Main(string[] args)
- => SonarScanner.MSBuild.Program.ExecuteFromLegacyEntryPoint(args);
+ bool AreExistingSonarPropertiesFilesPresent(string sonarScannerCwd, ICollection projects, out IEnumerable invalidFolders);
}
}
diff --git a/src/SonarScanner.MSBuild.Shim/ISonarScanner.cs b/src/SonarScanner.MSBuild.Shim/Interfaces/ISonarScanner.cs
similarity index 74%
rename from src/SonarScanner.MSBuild.Shim/ISonarScanner.cs
rename to src/SonarScanner.MSBuild.Shim/Interfaces/ISonarScanner.cs
index 4064b4d7a..e91c9b2ed 100644
--- a/src/SonarScanner.MSBuild.Shim/ISonarScanner.cs
+++ b/src/SonarScanner.MSBuild.Shim/Interfaces/ISonarScanner.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -21,15 +21,14 @@
using System.Collections.Generic;
using SonarScanner.MSBuild.Common;
-namespace SonarScanner.MSBuild.Shim
+namespace SonarScanner.MSBuild.Shim.Interfaces
{
///
/// Encapsulate the interaction with the sonar-scanner
///
- /// Accepts the ProjectInfo.xml files as input, generates a sonar-scanner.properties
- /// file from them, then executes the Java sonar-scanner
+ /// Accepts the ProjectInfo.xml files as input then executes the Java sonar-scanner
public interface ISonarScanner
{
- ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable userCmdLineArguments);
+ bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, string propertiesFilePath);
}
}
diff --git a/src/SonarScanner.MSBuild/NullCoverageReportConverter.cs b/src/SonarScanner.MSBuild.Shim/Interfaces/ITfsProcessor.cs
similarity index 73%
rename from src/SonarScanner.MSBuild/NullCoverageReportConverter.cs
rename to src/SonarScanner.MSBuild.Shim/Interfaces/ITfsProcessor.cs
index a96ca62c6..087ba7d85 100644
--- a/src/SonarScanner.MSBuild/NullCoverageReportConverter.cs
+++ b/src/SonarScanner.MSBuild.Shim/Interfaces/ITfsProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,16 +19,13 @@
*/
using System;
+using System.Collections.Generic;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-namespace SonarScanner.MSBuild
+namespace SonarScanner.MSBuild.Shim.Interfaces
{
- public class NullCoverageReportConverter : ICoverageReportConverter
+ public interface ITfsProcessor
{
- public bool ConvertToXml(string inputFilePath, string outputFilePath)
- => false;
-
- public bool Initialize() => true;
+ bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, String fullPropertiesFilePath);
}
}
diff --git a/src/SonarScanner.MSBuild.Shim/PathHelper.cs b/src/SonarScanner.MSBuild.Shim/PathHelper.cs
index c5497cc8f..5a1b908cf 100644
--- a/src/SonarScanner.MSBuild.Shim/PathHelper.cs
+++ b/src/SonarScanner.MSBuild.Shim/PathHelper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectData.cs b/src/SonarScanner.MSBuild.Shim/ProjectData.cs
index 71c21b4cc..ef4d27aff 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectData.cs
+++ b/src/SonarScanner.MSBuild.Shim/ProjectData.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectInfoAnalysisResult.cs b/src/SonarScanner.MSBuild.Shim/ProjectInfoAnalysisResult.cs
index a42dbf698..fe88e5c3e 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectInfoAnalysisResult.cs
+++ b/src/SonarScanner.MSBuild.Shim/ProjectInfoAnalysisResult.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectInfoExtensions.cs b/src/SonarScanner.MSBuild.Shim/ProjectInfoExtensions.cs
index a4801b724..4f76aa987 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectInfoExtensions.cs
+++ b/src/SonarScanner.MSBuild.Shim/ProjectInfoExtensions.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectInfoReportBuilder.cs b/src/SonarScanner.MSBuild.Shim/ProjectInfoReportBuilder.cs
index b41ae5128..42137ac06 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectInfoReportBuilder.cs
+++ b/src/SonarScanner.MSBuild.Shim/ProjectInfoReportBuilder.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -31,7 +31,7 @@ namespace SonarScanner.MSBuild.Shim
/// Outputs a report summarizing the project info files that were found.
/// This is not used by SonarQube: it is only for debugging purposes.
///
- internal class ProjectInfoReportBuilder
+ public class ProjectInfoReportBuilder
{
internal const string ReportFileName = "ProjectInfo.log";
diff --git a/src/SonarScanner.MSBuild.Shim/ProjectLoader.cs b/src/SonarScanner.MSBuild.Shim/ProjectLoader.cs
index 010cc6d99..830f4c3da 100644
--- a/src/SonarScanner.MSBuild.Shim/ProjectLoader.cs
+++ b/src/SonarScanner.MSBuild.Shim/ProjectLoader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.Shim/Properties/AssemblyInfo.cs
index ffdc30f11..2183a55af 100644
--- a/src/SonarScanner.MSBuild.Shim/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.Shim/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/Properties/InternalsVisibleTo.cs b/src/SonarScanner.MSBuild.Shim/Properties/InternalsVisibleTo.cs
index 6ef9335b1..b5a379af6 100644
--- a/src/SonarScanner.MSBuild.Shim/Properties/InternalsVisibleTo.cs
+++ b/src/SonarScanner.MSBuild.Shim/Properties/InternalsVisibleTo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/PropertiesFileGenerator.cs b/src/SonarScanner.MSBuild.Shim/PropertiesFileGenerator.cs
index f3ebd16e7..78a806aad 100644
--- a/src/SonarScanner.MSBuild.Shim/PropertiesFileGenerator.cs
+++ b/src/SonarScanner.MSBuild.Shim/PropertiesFileGenerator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -26,19 +26,19 @@
using System.Text;
using SonarScanner.MSBuild.Common;
using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.Shim
{
- public class PropertiesFileGenerator
+ public class PropertiesFileGenerator : IPropertiesFileGenerator
{
private const string ProjectPropertiesFileName = "sonar-project.properties";
- public const string ReportFileCsharpPropertyKey = "sonar.cs.roslyn.reportFilePath";
public const string ReportFilesCsharpPropertyKey = "sonar.cs.roslyn.reportFilePaths";
- public const string ReportFileVbnetPropertyKey = "sonar.vbnet.roslyn.reportFilePath";
public const string ReportFilesVbnetPropertyKey = "sonar.vbnet.roslyn.reportFilePaths";
// This delimiter needs to be the same as the one used in the Integration.targets
- private const char RoslynReportPathsDelimiter = '|';
+ internal const char RoslynReportPathsDelimiter = '|';
+ internal const char AnalyzerOutputPathsDelimiter = ',';
private readonly AnalysisConfig analysisConfig;
private readonly ILogger logger;
@@ -69,7 +69,7 @@ public PropertiesFileGenerator(AnalysisConfig analysisConfig, ILogger logger)
public ProjectInfoAnalysisResult GenerateFile()
{
var projectPropertiesPath = Path.Combine(analysisConfig.SonarOutputDir, ProjectPropertiesFileName);
- logger.LogDebug(Resources.MSG_GeneratingProjectProperties, projectPropertiesPath);
+ logger.LogDebug(Resources.MSG_GeneratingProjectProperties, projectPropertiesPath, SonarProduct.GetSonarProductToLog(analysisConfig.SonarQubeHostUrl));
var result = new ProjectInfoAnalysisResult();
@@ -86,6 +86,10 @@ public ProjectInfoAnalysisResult GenerateFile()
result.FullPropertiesFilePath = projectPropertiesPath;
}
+ else
+ {
+ logger.LogInfo(Resources.MSG_PropertiesGenerationFailed);
+ }
result.Projects.AddRange(projects);
@@ -98,7 +102,7 @@ public bool TryWriteProperties(PropertiesWriter writer, out IEnumerable();
return false;
}
@@ -125,7 +129,7 @@ public bool TryWriteProperties(PropertiesWriter writer, out IEnumerable p.Status == ProjectInfoValidity.NoFilesToAnalyze))
{
- logger.LogError(Resources.ERR_NoValidProjectInfoFiles);
+ logger.LogError(Resources.ERR_NoValidProjectInfoFiles, SonarProduct.GetSonarProductToLog(analysisConfig.SonarQubeHostUrl));
return false;
}
@@ -257,7 +261,7 @@ private void PostProcessProjectStatus(IEnumerable projects)
}
}
- return closestProjects.Items.Count == 1
+ return closestProjects.Items.Count >= 1
? closestProjects.Items[0]
: null;
}
@@ -314,8 +318,8 @@ private void PostProcessProjectStatus(IEnumerable projects)
{
projectData.Status = ProjectInfoValidity.Valid;
p.GetAllAnalysisFiles().ToList().ForEach(path => projectData.ReferencedFiles.Add(path));
- AddRoslynOutputFilePath(p, projectData);
- AddAnalyzerOutputFilePath(p, projectData);
+ AddRoslynOutputFilePaths(p, projectData);
+ AddAnalyzerOutputFilePaths(p, projectData);
}
}
@@ -328,29 +332,29 @@ private void PostProcessProjectStatus(IEnumerable projects)
}
private void LogDuplicateGuidWarning(Guid projectGuid, string projectPath) =>
- logger.LogWarning(Resources.WARN_DuplicateProjectGuid, projectGuid, projectPath);
+ logger.LogWarning(Resources.WARN_DuplicateProjectGuid, projectGuid, projectPath, SonarProduct.GetSonarProductToLog(analysisConfig.SonarQubeHostUrl));
- private void AddAnalyzerOutputFilePath(ProjectInfo project, ProjectData projectData)
+ private void AddAnalyzerOutputFilePaths(ProjectInfo project, ProjectData projectData)
{
- var property = project.AnalysisSettings.FirstOrDefault(p => p.Id.EndsWith(".analyzer.projectOutPath"));
+ var property = project.AnalysisSettings.FirstOrDefault(p => p.Id.EndsWith(".analyzer.projectOutPaths"));
if (property != null)
{
- projectData.AnalyzerOutPaths.Add(new FileInfo(property.Value));
+ foreach (var filePath in property.Value.Split(AnalyzerOutputPathsDelimiter))
+ {
+ projectData.AnalyzerOutPaths.Add(new FileInfo(filePath));
+ }
}
}
- private void AddRoslynOutputFilePath(ProjectInfo project, ProjectData projectData)
+ private void AddRoslynOutputFilePaths(ProjectInfo project, ProjectData projectData)
{
- var property = project.AnalysisSettings.FirstOrDefault(p => p.Id.EndsWith(".roslyn.reportFilePath"));
+ var property = project.AnalysisSettings.FirstOrDefault(p => p.Id.EndsWith(".roslyn.reportFilePaths"));
if (property != null)
{
- var reportFilePaths = property.Value.Split(RoslynReportPathsDelimiter);
- foreach (var reportFilePath in reportFilePaths)
+ foreach (var filePath in property.Value.Split(RoslynReportPathsDelimiter))
{
- projectData.RoslynReportFilePaths.Add(new FileInfo(reportFilePath));
+ projectData.RoslynReportFilePaths.Add(new FileInfo(filePath));
}
- // For compatibility with old SonarC#/VB.NET plugins we need to have only one path in this property
- property.Value = reportFilePaths.First();
}
}
@@ -367,8 +371,41 @@ private void FixSarifAndEncoding(IList projects, AnalysisProperties
private void TryFixSarifReport(ProjectInfo project)
{
- TryFixSarifReport(project, RoslynV1SarifFixer.CSharpLanguage, ReportFileCsharpPropertyKey);
- TryFixSarifReport(project, RoslynV1SarifFixer.VBNetLanguage, ReportFileVbnetPropertyKey);
+ TryFixSarifReport(project, RoslynV1SarifFixer.CSharpLanguage, ReportFilesCsharpPropertyKey);
+ TryFixSarifReport(project, RoslynV1SarifFixer.VBNetLanguage, ReportFilesVbnetPropertyKey);
+ }
+
+ ///
+ /// Loads SARIF reports from the given projects and attempts to fix
+ /// improper escaping from Roslyn V1 (VS 2015 RTM) where appropriate.
+ ///
+ private void TryFixSarifReport(ProjectInfo project, string language, string reportFilesPropertyKey)
+ {
+ var tryResult = project.TryGetAnalysisSetting(reportFilesPropertyKey, out Property reportPathsProperty);
+ if (tryResult)
+ {
+ var listOfPaths = new List();
+ project.AnalysisSettings.Remove(reportPathsProperty);
+ foreach (var reportPath in reportPathsProperty.Value.Split(RoslynReportPathsDelimiter))
+ {
+ var fixedPath = fixer.LoadAndFixFile(reportPath, language);
+
+ if (fixedPath != null)
+ {
+ listOfPaths.Add(fixedPath);
+ }
+ }
+
+ if (listOfPaths.Any())
+ {
+ var newReportPathProperty = new Property
+ {
+ Id = reportFilesPropertyKey,
+ Value = string.Join(RoslynReportPathsDelimiter.ToString(), listOfPaths)
+ };
+ project.AnalysisSettings.Add(newReportPathProperty);
+ }
+ }
}
///
@@ -388,63 +425,29 @@ public DirectoryInfo ComputeRootProjectBaseDir(IEnumerable projec
if (!string.IsNullOrWhiteSpace(projectBaseDir))
{
rootDirectory = new DirectoryInfo(projectBaseDir);
- logger.LogDebug("Using user supplied project base directory: '{0}'.", rootDirectory.FullName);
+ logger.LogDebug(Resources.MSG_UsingUserSuppliedProjectBaseDir, rootDirectory.FullName);
return rootDirectory;
}
if (!string.IsNullOrWhiteSpace(analysisConfig.SourcesDirectory))
{
rootDirectory = new DirectoryInfo(analysisConfig.SourcesDirectory);
- logger.LogDebug("Using TFS/VSTS sources directory as project base directory: '{0}'.", rootDirectory.FullName);
+ logger.LogDebug(Resources.MSG_UsingAzDoSourceDirectoryAsProjectBaseDir, rootDirectory.FullName);
return rootDirectory;
}
var commonRoot = PathHelper.GetCommonRoot(projectPaths);
if (commonRoot != null)
{
- logger.LogDebug("Using longest common projects root path as project base directory: '{0}'.", commonRoot.FullName);
+ logger.LogDebug(Resources.MSG_UsingLongestCommonRootProjectBaseDir, commonRoot.FullName);
return commonRoot;
}
rootDirectory = new DirectoryInfo(analysisConfig.SonarOutputDir);
- logger.LogDebug("Using fallback project base directory: '{0}'.", rootDirectory.FullName);
+ logger.LogWarning(Resources.WARN_UsingFallbackProjectBaseDir, rootDirectory.FullName);
return rootDirectory;
}
- ///
- /// Loads SARIF reports from the given projects and attempts to fix
- /// improper escaping from Roslyn V1 (VS 2015 RTM) where appropriate.
- ///
- private void TryFixSarifReport(ProjectInfo project, string language, string reportFilePropertyKey)
- {
- var tryResult = project.TryGetAnalysisSetting(reportFilePropertyKey, out Property reportPathProperty);
- if (tryResult)
- {
- foreach (var reportPath in reportPathProperty.Value.Split(RoslynReportPathsDelimiter))
- {
- var fixedPath = fixer.LoadAndFixFile(reportPath, language);
-
- if (!reportPath.Equals(fixedPath)) // only need to alter the property if there was no change
- {
- // remove the property ahead of changing it
- // if the new path is null, the file was unfixable and we should leave the property out
- project.AnalysisSettings.Remove(reportPathProperty);
-
- if (fixedPath != null)
- {
- // otherwise, set the property value (results in no change if the file was already valid)
- var newReportPathProperty = new Property
- {
- Id = reportFilePropertyKey,
- Value = fixedPath,
- };
- project.AnalysisSettings.Add(newReportPathProperty);
- }
- }
- }
- }
- }
-
private static string GetSourceEncoding(AnalysisProperties properties, IEncodingProvider encodingProvider)
{
try
diff --git a/src/SonarScanner.MSBuild.Shim/PropertiesWriter.cs b/src/SonarScanner.MSBuild.Shim/PropertiesWriter.cs
index 805bbaf7f..1ff1b97e2 100644
--- a/src/SonarScanner.MSBuild.Shim/PropertiesWriter.cs
+++ b/src/SonarScanner.MSBuild.Shim/PropertiesWriter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -192,11 +192,11 @@ public void WriteRoslynOutputPaths(ProjectData project)
string property = null;
if (ProjectLanguages.IsCSharpProject(project.Project.ProjectLanguage))
{
- property = "sonar.cs.roslyn.reportFilePaths";
+ property = PropertiesFileGenerator.ReportFilesCsharpPropertyKey;
}
else if (ProjectLanguages.IsVbProject(project.Project.ProjectLanguage))
{
- property = "sonar.vbnet.roslyn.reportFilePaths";
+ property = PropertiesFileGenerator.ReportFilesVbnetPropertyKey;
}
sb.AppendLine($"{project.Guid}.{property}=\\");
diff --git a/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs b/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs
index 01d9573ce..ab64af38b 100644
--- a/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.Shim/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.Shim {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -82,21 +82,12 @@ internal static string DEBUG_FileReferencedByProjects {
}
///
- /// Looks up a localized string similar to sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: {0}.
- ///
- internal static string ERR_ConflictingSonarProjectProperties {
- get {
- return ResourceManager.GetString("ERR_ConflictingSonarProjectProperties", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
+ /// Looks up a localized string similar to The SonarScanner for MSBuild integration failed: {0} was unable to collect the required information about your projects.
///Possible causes:
/// 1. The project has not been built - the project must be built in between the begin and end steps
/// 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
/// 3. The begin, build and end steps have not all been launched from the same folder
- /// 4. None of the analyzed projects have a valid Project [rest of string was truncated]";.
+ /// 4. None of the analyzed projects have a valid Projec [rest of string was truncated]";.
///
internal static string ERR_NoProjectInfoFilesFound {
get {
@@ -105,7 +96,7 @@ internal static string ERR_NoProjectInfoFilesFound {
}
///
- /// Looks up a localized string similar to No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details..
+ /// Looks up a localized string similar to No analysable projects were found. {0} analysis will not be performed. Check the build summary report for details..
///
internal static string ERR_NoValidProjectInfoFiles {
get {
@@ -123,7 +114,7 @@ internal static string ERR_ProjectBaseDirDoesNotExist {
}
///
- /// Looks up a localized string similar to The SonarQube Scanner did not complete successfully.
+ /// Looks up a localized string similar to The SonarScanner did not complete successfully.
///
internal static string ERR_SonarScannerExecutionFailed {
get {
@@ -132,34 +123,34 @@ internal static string ERR_SonarScannerExecutionFailed {
}
///
- /// Looks up a localized string similar to Generating SonarQube project properties file to {0}.
+ /// Looks up a localized string similar to The TFS Processor did not complete successfully.
///
- internal static string MSG_GeneratingProjectProperties {
+ internal static string ERR_TFSProcessorExecutionFailed {
get {
- return ResourceManager.GetString("MSG_GeneratingProjectProperties", resourceCulture);
+ return ResourceManager.GetString("ERR_TFSProcessorExecutionFailed", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Analysis property is already correctly set: {0}={1}.
+ /// Looks up a localized string similar to Generating {1} project properties file to {0}.
///
- internal static string MSG_MandatorySettingIsCorrectlySpecified {
+ internal static string MSG_GeneratingProjectProperties {
get {
- return ResourceManager.GetString("MSG_MandatorySettingIsCorrectlySpecified", resourceCulture);
+ return ResourceManager.GetString("MSG_GeneratingProjectProperties", resourceCulture);
}
}
///
- /// Looks up a localized string similar to The project does not contain any files that can analyzed by SonarQube. Project file: {0}.
+ /// Looks up a localized string similar to Analysis property is already correctly set: {0}={1}.
///
- internal static string MSG_NoFilesToAnalyze {
+ internal static string MSG_MandatorySettingIsCorrectlySpecified {
get {
- return ResourceManager.GetString("MSG_NoFilesToAnalyze", resourceCulture);
+ return ResourceManager.GetString("MSG_MandatorySettingIsCorrectlySpecified", resourceCulture);
}
}
///
- /// Looks up a localized string similar to The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: {0}.
+ /// Looks up a localized string similar to The exclude flag has been set so the project will not be analyzed. Project file: {0}.
///
internal static string MSG_ProjectIsExcluded {
get {
@@ -168,7 +159,7 @@ internal static string MSG_ProjectIsExcluded {
}
///
- /// Looks up a localized string similar to Generation of the sonar-properties file failed. Unable to complete SonarQube analysis..
+ /// Looks up a localized string similar to Generation of the sonar-properties file failed. Unable to complete the analysis..
///
internal static string MSG_PropertiesGenerationFailed {
get {
@@ -222,7 +213,7 @@ internal static string MSG_SettingAnalysisProperty {
}
///
- /// Looks up a localized string similar to Calling the SonarQube Scanner....
+ /// Looks up a localized string similar to Calling the SonarScanner CLI....
///
internal static string MSG_SonarScannerCalling {
get {
@@ -231,7 +222,7 @@ internal static string MSG_SonarScannerCalling {
}
///
- /// Looks up a localized string similar to The SonarQube Scanner has finished.
+ /// Looks up a localized string similar to The SonarScanner CLI has finished.
///
internal static string MSG_SonarScannerCompleted {
get {
@@ -248,6 +239,42 @@ internal static string MSG_SonarScannerHomeIsSet {
}
}
+ ///
+ /// Looks up a localized string similar to Calling the TFS Processor executable....
+ ///
+ internal static string MSG_TFSProcessorCalling {
+ get {
+ return ResourceManager.GetString("MSG_TFSProcessorCalling", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The TFS Processor has finished.
+ ///
+ internal static string MSG_TFSProcessorCompleted {
+ get {
+ return ResourceManager.GetString("MSG_TFSProcessorCompleted", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Using TFS/Azure DevOps sources directory as project base directory: '{0}'..
+ ///
+ internal static string MSG_UsingAzDoSourceDirectoryAsProjectBaseDir {
+ get {
+ return ResourceManager.GetString("MSG_UsingAzDoSourceDirectoryAsProjectBaseDir", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Using longest common projects root path as project base directory: '{0}'..
+ ///
+ internal static string MSG_UsingLongestCommonRootProjectBaseDir {
+ get {
+ return ResourceManager.GetString("MSG_UsingLongestCommonRootProjectBaseDir", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Using the supplied value for {0}. Value: {1}.
///
@@ -257,6 +284,15 @@ internal static string MSG_UsingSuppliedSonarScannerOptsValue {
}
}
+ ///
+ /// Looks up a localized string similar to Using user supplied project base directory: '{0}'.
+ ///
+ internal static string MSG_UsingUserSuppliedProjectBaseDir {
+ get {
+ return ResourceManager.GetString("MSG_UsingUserSuppliedProjectBaseDir", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Writing processing summary to {0}.
///
@@ -321,7 +357,7 @@ internal static string REPORT_TestProjectsTitle {
}
///
- /// Looks up a localized string similar to Duplicate ProjectGuid: "{0}". The project will not be analyzed by SonarQube. Project file: "{1}".
+ /// Looks up a localized string similar to Duplicate ProjectGuid: "{0}". The project will not be analyzed. Project file: "{1}".
///
internal static string WARN_DuplicateProjectGuid {
get {
@@ -358,7 +394,7 @@ internal static string WARN_FileIsOutsideProjectDirectory {
}
///
- /// Looks up a localized string similar to The following paths contain invalid characters for this version of SonarQube and will be excluded from this analysis: {0}.
+ /// Looks up a localized string similar to The following paths contain invalid characters and will be excluded from this analysis: {0}.
///
internal static string WARN_InvalidCharacterInPaths {
get {
@@ -367,7 +403,7 @@ internal static string WARN_InvalidCharacterInPaths {
}
///
- /// Looks up a localized string similar to The project has an invalid GUID "{0}". The project will not be analyzed by SonarQube. Project file: {1}.
+ /// Looks up a localized string similar to The project has an invalid GUID "{0}". The project will not be analyzed. Project file: {1}.
///
internal static string WARN_InvalidProjectGuid {
get {
@@ -401,5 +437,14 @@ internal static string WARN_SarifFixFail {
return ResourceManager.GetString("WARN_SarifFixFail", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Could not determine a suitable project base directory. Using the fallback {0} . Make sure that all dependencies of your project are available on your filesystem, as this fallback may lead to no result being show after the analysis..
+ ///
+ internal static string WARN_UsingFallbackProjectBaseDir {
+ get {
+ return ResourceManager.GetString("WARN_UsingFallbackProjectBaseDir", resourceCulture);
+ }
+ }
}
}
diff --git a/src/SonarScanner.MSBuild.Shim/Resources.resx b/src/SonarScanner.MSBuild.Shim/Resources.resx
index 83153312e..8f993a103 100644
--- a/src/SonarScanner.MSBuild.Shim/Resources.resx
+++ b/src/SonarScanner.MSBuild.Shim/Resources.resx
@@ -118,31 +118,28 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- Calling the SonarQube Scanner...
+ Calling the SonarScanner CLI...File '{0}' is not located under the root directory '{1}' and will not be analyzed.
- Generating SonarQube project properties file to {0}
-
-
- The project does not contain any files that can analyzed by SonarQube. Project file: {0}
+ Generating {1} project properties file to {0}
- The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: {0}
+ The exclude flag has been set so the project will not be analyzed. Project file: {0}
- Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
+ Generation of the sonar-properties file failed. Unable to complete the analysis.
- The SonarQube Scanner has finished
+ The SonarScanner CLI has finishedWriting processing summary to {0}
- The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
+ The SonarScanner for MSBuild integration failed: {0} was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
@@ -150,10 +147,10 @@ Possible causes:
4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
- No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
+ No analysable projects were found. {0} analysis will not be performed. Check the build summary report for details.
- The SonarQube Scanner did not complete successfully
+ The SonarScanner did not complete successfullyUsing the supplied value for {0}. Value: {1}
@@ -177,13 +174,13 @@ Possible causes:
Test projects
- Duplicate ProjectGuid: "{0}". The project will not be analyzed by SonarQube. Project file: "{1}"
+ Duplicate ProjectGuid: "{0}". The project will not be analyzed. Project file: "{1}"File '{0}' does not exist.
- The project has an invalid GUID "{0}". The project will not be analyzed by SonarQube. Project file: {1}
+ The project has an invalid GUID "{0}". The project will not be analyzed. Project file: {1}The SONAR_SCANNER_HOME environment variable is not required and will be ignored.
@@ -197,9 +194,6 @@ Possible causes:
Analysis property is already correctly set: {0}={1}
-
- sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: {0}
-
No Code Analysis ErrorLog file found at {0}.
@@ -229,7 +223,7 @@ Possible causes:
{0}
- The following paths contain invalid characters for this version of SonarQube and will be excluded from this analysis: {0}
+ The following paths contain invalid characters and will be excluded from this analysis: {0}Dumping content of sonar-project.properties
@@ -237,4 +231,25 @@ Possible causes:
{0}
------------------------------------------------------------------------
+
+ The TFS Processor did not complete successfully
+
+
+ Calling the TFS Processor executable...
+
+
+ The TFS Processor has finished
+
+
+ Using TFS/Azure DevOps sources directory as project base directory: '{0}'.
+
+
+ Using longest common projects root path as project base directory: '{0}'.
+
+
+ Using user supplied project base directory: '{0}'
+
+
+ Could not determine a suitable project base directory. Using the fallback {0} . Make sure that all dependencies of your project are available on your filesystem, as this fallback may lead to no result being show after the analysis.
+
\ No newline at end of file
diff --git a/src/SonarScanner.MSBuild.Shim/RoslynV1SarifFixer.cs b/src/SonarScanner.MSBuild.Shim/RoslynV1SarifFixer.cs
index 5a1536f8d..091d7779e 100644
--- a/src/SonarScanner.MSBuild.Shim/RoslynV1SarifFixer.cs
+++ b/src/SonarScanner.MSBuild.Shim/RoslynV1SarifFixer.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.Shim
{
diff --git a/src/SonarScanner.MSBuild.Shim/RuntimeInformationWrapper.cs b/src/SonarScanner.MSBuild.Shim/RuntimeInformationWrapper.cs
index 564475c95..d8479d07e 100644
--- a/src/SonarScanner.MSBuild.Shim/RuntimeInformationWrapper.cs
+++ b/src/SonarScanner.MSBuild.Shim/RuntimeInformationWrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Shim/SonarProjectPropertiesValidator.cs b/src/SonarScanner.MSBuild.Shim/SonarProjectPropertiesValidator.cs
index 4d1b71069..78620e054 100644
--- a/src/SonarScanner.MSBuild.Shim/SonarProjectPropertiesValidator.cs
+++ b/src/SonarScanner.MSBuild.Shim/SonarProjectPropertiesValidator.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,43 +18,34 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.Shim
{
- public static class SonarProjectPropertiesValidator
+ public class SonarProjectPropertiesValidator : ISonarProjectPropertiesValidator
{
///
/// Verifies that no sonar-project.properties conflicting with the generated one exists within the project
///
/// Solution folder to check
/// MSBuild projects to check, only valid ones will be verified
- /// Called when validation succeeded
- /// Called when validation fails, with the list of folders containing a sonar-project.properties file
- public static void Validate(string sonarScannerCwd, ICollection projects, Action onValid, Action> onInvalid)
+ public bool AreExistingSonarPropertiesFilesPresent(string sonarScannerCwd, ICollection projects, out IEnumerable invalidFolders)
{
- var invalidFolders = projects
+ invalidFolders = projects
.Where(p => p.Status == ProjectInfoValidity.Valid)
.Select(p => p.Project.GetDirectory().FullName)
.Union(new[] { sonarScannerCwd })
.Where(SonarProjectPropertiesExists)
.ToList();
- if (invalidFolders.Count > 0)
- {
- onInvalid(invalidFolders);
- }
- else
- {
- onValid();
- }
+ return invalidFolders.Any();
}
- private static bool SonarProjectPropertiesExists(string folder)
+ private bool SonarProjectPropertiesExists(string folder)
{
return File.Exists(Path.Combine(folder, "sonar-project.properties"));
}
diff --git a/src/SonarScanner.MSBuild.Shim/SonarScanner.MSBuild.Shim.csproj b/src/SonarScanner.MSBuild.Shim/SonarScanner.MSBuild.Shim.csproj
index b62d701c5..551489476 100644
--- a/src/SonarScanner.MSBuild.Shim/SonarScanner.MSBuild.Shim.csproj
+++ b/src/SonarScanner.MSBuild.Shim/SonarScanner.MSBuild.Shim.csproj
@@ -7,9 +7,9 @@
-
+
-
+
@@ -20,7 +20,7 @@
- ResXFileCodeGenerator
+ PublicResXFileCodeGeneratorResources.Designer.cs
diff --git a/src/SonarScanner.MSBuild.Shim/SonarScanner.Wrapper.cs b/src/SonarScanner.MSBuild.Shim/SonarScanner.Wrapper.cs
index d1fba0678..a5f392dc5 100644
--- a/src/SonarScanner.MSBuild.Shim/SonarScanner.Wrapper.cs
+++ b/src/SonarScanner.MSBuild.Shim/SonarScanner.Wrapper.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -24,6 +24,7 @@
using System.IO;
using System.Linq;
using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Shim.Interfaces;
namespace SonarScanner.MSBuild.Shim
{
@@ -60,7 +61,7 @@ public SonarScannerWrapper(ILogger logger)
#region ISonarScanner interface
- public ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable userCmdLineArguments)
+ public bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, String propertiesFilePath)
{
if (config == null)
{
@@ -71,26 +72,7 @@ public ProjectInfoAnalysisResult Execute(AnalysisConfig config, IEnumerable
- {
- ProjectInfoReportBuilder.WriteSummaryReport(config, result, logger);
-
- result.RanToCompletion = InternalExecute(config, userCmdLineArguments, logger, result.FullPropertiesFilePath);
- },
- onInvalid: (invalidFolders) =>
- {
- // LOG error message
- logger.LogError(Resources.ERR_ConflictingSonarProjectProperties, string.Join(", ", invalidFolders));
- });
-
- return result;
+ return InternalExecute(config, userCmdLineArguments, logger, propertiesFilePath);
}
#endregion ISonarScanner interface
diff --git a/src/SonarScanner.MSBuild.Shim/TFSProcessor.Wrapper.cs b/src/SonarScanner.MSBuild.Shim/TFSProcessor.Wrapper.cs
new file mode 100644
index 000000000..3c779f085
--- /dev/null
+++ b/src/SonarScanner.MSBuild.Shim/TFSProcessor.Wrapper.cs
@@ -0,0 +1,99 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Shim.Interfaces;
+
+namespace SonarScanner.MSBuild.Shim
+{
+ public class TfsProcessorWrapper : ITfsProcessor
+ {
+ private readonly ILogger logger;
+
+ public TfsProcessorWrapper(ILogger logger)
+ {
+ this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ }
+
+ public bool Execute(AnalysisConfig config, IEnumerable userCmdLineArguments, String fullPropertiesFilePath)
+ {
+ if (config == null)
+ {
+ throw new ArgumentNullException(nameof(config));
+ }
+
+ if (userCmdLineArguments == null)
+ {
+ throw new ArgumentNullException(nameof(userCmdLineArguments));
+ }
+
+ return InternalExecute(config, logger, userCmdLineArguments, fullPropertiesFilePath);
+ }
+
+ #region Private methods
+
+ private static bool InternalExecute(AnalysisConfig config, ILogger logger, IEnumerable userCmdLineArguments, String fullPropertiesFilePath)
+ {
+ var exeFileName = FindProcessorExe();
+ return ExecuteProcessorRunner(config, logger, exeFileName, userCmdLineArguments, fullPropertiesFilePath, new ProcessRunner(logger));
+ }
+
+ private static string FindProcessorExe()
+ {
+ var execFolder = Path.GetDirectoryName(typeof(TfsProcessorWrapper).Assembly.Location);
+ return Path.Combine(execFolder, "SonarScanner.MSBuild.TFSProcessor.exe");
+ }
+
+ public /* for test purposes */ static bool ExecuteProcessorRunner(AnalysisConfig config, ILogger logger, string exeFileName, IEnumerable userCmdLineArguments, string propertiesFileName, IProcessRunner runner)
+ {
+ Debug.Assert(File.Exists(exeFileName), "The specified exe file does not exist: " + exeFileName);
+ Debug.Assert(File.Exists(propertiesFileName), "The specified properties file does not exist: " + propertiesFileName);
+
+ logger.LogInfo(Resources.MSG_TFSProcessorCalling);
+
+ Debug.Assert(!string.IsNullOrWhiteSpace(config.SonarScannerWorkingDirectory), "The working dir should have been set in the analysis config");
+ Debug.Assert(Directory.Exists(config.SonarScannerWorkingDirectory), "The working dir should exist");
+
+ var converterArgs = new ProcessRunnerArguments(exeFileName, !PlatformHelper.IsWindows())
+ {
+ CmdLineArgs = userCmdLineArguments,
+ WorkingDirectory = config.SonarScannerWorkingDirectory,
+ };
+
+ var success = runner.Execute(converterArgs);
+
+ if (success)
+ {
+ logger.LogInfo(Resources.MSG_TFSProcessorCompleted);
+ }
+ else
+ {
+ logger.LogError(Resources.ERR_TFSProcessorExecutionFailed);
+ }
+ return success;
+ }
+
+ #endregion Private methods
+ }
+}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/BinaryToXmlCoverageReportConverter.cs b/src/SonarScanner.MSBuild.TFS.Classic/BinaryToXmlCoverageReportConverter.cs
index e9eaab839..f90abc2ec 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/BinaryToXmlCoverageReportConverter.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/BinaryToXmlCoverageReportConverter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -36,6 +36,7 @@ public class BinaryToXmlCoverageReportConverter : ICoverageReportConverter
private const int ConversionTimeoutInMs = 60000;
private readonly IVisualStudioSetupConfigurationFactory setupConfigurationFactory;
private readonly ILogger logger;
+ private readonly AnalysisConfig config;
///
/// Registry containing information about installed VS versions
@@ -60,15 +61,16 @@ public class BinaryToXmlCoverageReportConverter : ICoverageReportConverter
#region Public methods
- public BinaryToXmlCoverageReportConverter(ILogger logger)
- : this(new VisualStudioSetupConfigurationFactory(), logger)
+ public BinaryToXmlCoverageReportConverter(ILogger logger, AnalysisConfig config)
+ : this(new VisualStudioSetupConfigurationFactory(), logger, config)
{ }
public BinaryToXmlCoverageReportConverter(IVisualStudioSetupConfigurationFactory setupConfigurationFactory,
- ILogger logger)
+ ILogger logger, AnalysisConfig config)
{
this.setupConfigurationFactory = setupConfigurationFactory;
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ this.config = config ?? throw new ArgumentNullException(nameof(config));
}
#endregion Public methods
@@ -116,6 +118,13 @@ private string GetExeToolPath()
{
this.logger.LogDebug(Resources.CONV_DIAG_LocatingCodeCoverageTool);
+ var userSuppliedVsCoverageToolPath = this.config.GetVsCoverageConverterToolPath();
+ if (userSuppliedVsCoverageToolPath != null)
+ {
+ this.logger.LogDebug(Resources.CONV_DIAG_LocatingCodeCoverageToolUserSuppliedProperty);
+ return userSuppliedVsCoverageToolPath;
+ }
+
return GetExeToolPathFromSetupConfiguration()
?? GetExeToolPathFromRegistry();
}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/CommandLineArgs.cs b/src/SonarScanner.MSBuild.TFS.Classic/CommandLineArgs.cs
new file mode 100644
index 000000000..72b9822c2
--- /dev/null
+++ b/src/SonarScanner.MSBuild.TFS.Classic/CommandLineArgs.cs
@@ -0,0 +1,59 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using System.Linq;
+using SonarScanner.MSBuild.Common;
+
+namespace SonarScanner.MSBuild.TFS.Classic
+{
+ public class CommandLineArgs
+ {
+ private readonly ILogger logger;
+ public string SonarQubeAnalysisConfigPath { get; set; }
+
+ public string SonarProjectPropertiesPath { get; set; }
+
+ public Method ProcessToExecute { get; set; }
+ public bool RanToCompletion { get; set; }
+
+ public CommandLineArgs(ILogger logger)
+ {
+ this.logger = logger;
+ }
+
+ public bool ParseArguments(string[] args)
+ {
+ try
+ {
+ ProcessToExecute = (Method)Enum.Parse(typeof(Method), args[0], false);
+ SonarQubeAnalysisConfigPath = args[1];
+ SonarProjectPropertiesPath = args[2];
+ RanToCompletion = args.Count() > 3 && bool.Parse(args[3]);
+ return true;
+ }
+ catch
+ {
+ logger.LogError("Failed to parse or retrieve arguments for command line.");
+ return false;
+ }
+ }
+ }
+}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/IVisualStudioSetupConfigurationFactory.cs b/src/SonarScanner.MSBuild.TFS.Classic/IVisualStudioSetupConfigurationFactory.cs
index eac5932dc..d505cdd1d 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/IVisualStudioSetupConfigurationFactory.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/IVisualStudioSetupConfigurationFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarQube.Old.Bootstrapper/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.TFS.Classic/Method.cs
similarity index 79%
rename from src/SonarQube.Old.Bootstrapper/Properties/AssemblyInfo.cs
rename to src/SonarScanner.MSBuild.TFS.Classic/Method.cs
index d18d00d3f..c0e3a4b1d 100644
--- a/src/SonarQube.Old.Bootstrapper/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Method.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,8 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using System.Reflection;
-[assembly: AssemblyTitle("SonarQube.Old.Bootstrapper")]
-[assembly: AssemblyProduct("SonarQube.Old.Bootstrapper")]
-[assembly: AssemblyDescription("")]
+namespace SonarScanner.MSBuild.TFS.Classic
+{
+ public enum Method
+ {
+ ConvertCoverage,
+ SummaryReportBuilder
+ }
+}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/Program.cs b/src/SonarScanner.MSBuild.TFS.Classic/Program.cs
new file mode 100644
index 000000000..079de4d56
--- /dev/null
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Program.cs
@@ -0,0 +1,106 @@
+/*
+ * SonarScanner for MSBuild
+ * Copyright (C) 2016-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using System;
+using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.TFS.Classic.XamlBuild;
+
+namespace SonarScanner.MSBuild.TFS.Classic
+{
+ public static class Program
+ {
+ public static int Main(string[] args)
+ {
+ var logger = new ConsoleLogger(includeTimestamp: false);
+ return Execute(args, logger);
+ }
+
+ public static int Execute(string[] args, ILogger logger)
+ {
+ try
+ {
+ /* Expected Arguments :
+ * Method : 0
+ * SonarQubeAnalysisConfig.xml path : 1
+ * sonar-project.properties : 2
+ * ranToCompletion : 3
+ */
+ if (args.Length < 1)
+ {
+ logger.LogError("No argument found. Exiting...");
+ return 1;
+ }
+
+ CommandLineArgs commandLineArgs = new CommandLineArgs(logger);
+ if(!commandLineArgs.ParseArguments(args))
+ {
+ return 1;
+ }
+
+ var teamBuildSettings = TeamBuildSettings.GetSettingsFromEnvironment(logger);
+ AnalysisConfig config = AnalysisConfig.Load(commandLineArgs.SonarQubeAnalysisConfigPath);
+ var legacyTeamBuildFactory = new LegacyTeamBuildFactory(logger, config);
+
+ switch (commandLineArgs.ProcessToExecute)
+ {
+ case Method.ConvertCoverage:
+ ExecuteCoverageConverter(logger, config, legacyTeamBuildFactory, teamBuildSettings, commandLineArgs.SonarProjectPropertiesPath);
+ break;
+ case Method.SummaryReportBuilder:
+ ExecuteReportBuilder(logger, config, legacyTeamBuildFactory, teamBuildSettings, commandLineArgs.RanToCompletion, commandLineArgs.SonarProjectPropertiesPath);
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.LogError("An exception occured while executing the process : " + ex.Message);
+ logger.LogError(ex.StackTrace);
+ }
+
+ return 0;
+ }
+
+ private static void ExecuteReportBuilder(ILogger logger, AnalysisConfig config, ILegacyTeamBuildFactory teamBuildFactory, ITeamBuildSettings teamBuildSettings, bool ranToCompletion, string fullPropertiesFilePath)
+ {
+ var reportBuilder = new SummaryReportBuilder(teamBuildFactory, logger);
+ reportBuilder.GenerateReports(teamBuildSettings, config, ranToCompletion, fullPropertiesFilePath);
+ }
+
+ private static void ExecuteCoverageConverter(ILogger logger, AnalysisConfig config, ILegacyTeamBuildFactory teamBuildFactory, ITeamBuildSettings teamBuildSettings, string fullPropertiesFilePath)
+ {
+ var binaryConverter = new BinaryToXmlCoverageReportConverter(logger, config);
+ var coverageReportProcessor = new CoverageReportProcessor(teamBuildFactory, binaryConverter, logger);
+
+ if (coverageReportProcessor.Initialise(config, teamBuildSettings, fullPropertiesFilePath))
+ {
+ bool success = coverageReportProcessor.ProcessCoverageReports();
+ if (success)
+ {
+ logger.LogInfo("Coverage report conversion completed successfully.");
+ }
+ else
+ {
+ logger.LogWarning("Coverage report conversion has failed. Skipping...");
+ }
+ }
+ }
+ }
+}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.TFS.Classic/Properties/AssemblyInfo.cs
index 9b0459f7e..15fe3c0fd 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/Properties/InternalsVisibleTo.cs b/src/SonarScanner.MSBuild.TFS.Classic/Properties/InternalsVisibleTo.cs
index 5d56502ec..0793bc34f 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/Properties/InternalsVisibleTo.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Properties/InternalsVisibleTo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/Resources.Designer.cs b/src/SonarScanner.MSBuild.TFS.Classic/Resources.Designer.cs
index eb46f3062..dc61dd8bc 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.TFS.Classic {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -96,6 +96,15 @@ internal static string CONV_DIAG_LocatingCodeCoverageToolSetupConfiguration {
}
}
+ ///
+ /// Looks up a localized string similar to VsTestToolsInstallerInstalledToolLocation environment variable detected, taking this one as tool path for CodeCoverage.exe..
+ ///
+ internal static string CONV_DIAG_LocatingCodeCoverageToolUserSuppliedProperty {
+ get {
+ return ResourceManager.GetString("CONV_DIAG_LocatingCodeCoverageToolUserSuppliedProperty", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Multiple versions of VS are installed: {0}.
///
@@ -188,7 +197,7 @@ internal static string PROC_ERROR_FailedToDownloadReportReason {
}
///
- /// Looks up a localized string similar to More than one code coverage result file was created. Only one report can be uploaded to SonarQube. Please modify the build definition so either SonarQube analysis is disabled or only one platform/flavor is built.
+ /// Looks up a localized string similar to More than one code coverage result file was created. Only one report can be uploaded to SonarQube. Please modify the build definition so either {0} analysis is disabled or only one platform/flavor is built.
///
internal static string PROC_ERROR_MultipleCodeCoverageReportsFound {
get {
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/Resources.resx b/src/SonarScanner.MSBuild.TFS.Classic/Resources.resx
index ff6220788..167f8ab04 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/Resources.resx
+++ b/src/SonarScanner.MSBuild.TFS.Classic/Resources.resx
@@ -129,6 +129,9 @@
Attempting to locate the CodeCoverage.exe tool using setup configuration...
+
+ VsTestToolsInstallerInstalledToolLocation environment variable detected, taking this one as tool path for CodeCoverage.exe.
+
Multiple versions of VS are installed: {0}First parameter: a list of VS versions
@@ -162,7 +165,7 @@ Check that the downloaded code coverage file ({0}) is valid by opening it in Vis
"Failed to download the code coverage report from {0}. The HTTP status code was {1} and the reason \"{2}\""
- More than one code coverage result file was created. Only one report can be uploaded to SonarQube. Please modify the build definition so either SonarQube analysis is disabled or only one platform/flavor is built
+ More than one code coverage result file was created. Only one report can be uploaded to SonarQube. Please modify the build definition so either {0} analysis is disabled or only one platform/flavor is builtSonarQube Analysis Summary
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/SonarScanner.MSBuild.TFS.Classic.csproj b/src/SonarScanner.MSBuild.TFS.Classic/SonarScanner.MSBuild.TFS.Classic.csproj
index bd645d4e1..6f197c4a2 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/SonarScanner.MSBuild.TFS.Classic.csproj
+++ b/src/SonarScanner.MSBuild.TFS.Classic/SonarScanner.MSBuild.TFS.Classic.csproj
@@ -1,8 +1,10 @@
$(ScannerNetFxVersion)
- SonarScanner.MSBuild.TFS.Classic
+ SonarScanner.MSBuild.TFSProcessortrue
+ Exe
+ SonarScanner.MSBuild.TFS.Classic.Program
@@ -38,7 +40,7 @@
-
+
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/VisualStudioSetupConfigurationFactory.cs b/src/SonarScanner.MSBuild.TFS.Classic/VisualStudioSetupConfigurationFactory.cs
index 56af7ceb8..06a9799fa 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/VisualStudioSetupConfigurationFactory.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/VisualStudioSetupConfigurationFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportDownloader.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportDownloader.cs
index 9fa17906c..1810403d5 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportDownloader.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportDownloader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportUrlProvider.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportUrlProvider.cs
index 4be410ad7..9215ab0ad 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportUrlProvider.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/CoverageReportUrlProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/ICoverageReportDownloader.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/ICoverageReportDownloader.cs
index 56d8ad75f..e38db5762 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/ICoverageReportDownloader.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/ICoverageReportDownloader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyBuildSummaryLogger.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyBuildSummaryLogger.cs
index 38a4b0ecc..f02263784 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyBuildSummaryLogger.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyBuildSummaryLogger.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyTeamBuildFactory.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyTeamBuildFactory.cs
index 1e6c09f50..fc4aaf6e7 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyTeamBuildFactory.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/LegacyTeamBuildFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -26,16 +26,18 @@ namespace SonarScanner.MSBuild.TFS.Classic.XamlBuild
public class LegacyTeamBuildFactory : ILegacyTeamBuildFactory
{
private readonly ILogger logger;
+ private readonly AnalysisConfig config;
- public LegacyTeamBuildFactory(ILogger logger)
+ public LegacyTeamBuildFactory(ILogger logger, AnalysisConfig config)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
+ this.config = config ?? throw new ArgumentNullException(nameof(config));
}
public ILegacyBuildSummaryLogger BuildLegacyBuildSummaryLogger(string tfsUri, string buildUri)
=> new LegacyBuildSummaryLogger(tfsUri, buildUri);
public ICoverageReportProcessor BuildTfsLegacyCoverageReportProcessor()
- => new TfsLegacyCoverageReportProcessor(this.logger);
+ => new TfsLegacyCoverageReportProcessor(this.logger, this.config);
}
}
diff --git a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/TfsLegacyCoverageReportProcessor.cs b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/TfsLegacyCoverageReportProcessor.cs
index 43f7b141b..4481ec136 100644
--- a/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/TfsLegacyCoverageReportProcessor.cs
+++ b/src/SonarScanner.MSBuild.TFS.Classic/XamlBuild/TfsLegacyCoverageReportProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
using System.IO;
using System.Linq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild.TFS.Classic.XamlBuild
{
@@ -35,9 +35,9 @@ public class TfsLegacyCoverageReportProcessor : CoverageReportProcessorBase
private readonly ICoverageUrlProvider urlProvider;
private readonly ICoverageReportDownloader downloader;
- public TfsLegacyCoverageReportProcessor(ILogger logger)
+ public TfsLegacyCoverageReportProcessor(ILogger logger, AnalysisConfig config)
: this(new CoverageReportUrlProvider(logger), new CoverageReportDownloader(logger),
- new BinaryToXmlCoverageReportConverter(logger), logger)
+ new BinaryToXmlCoverageReportConverter(logger, config), logger)
{
}
diff --git a/src/SonarScanner.MSBuild.TFS/BuildVNextCoverageReportProcessor.cs b/src/SonarScanner.MSBuild.TFS/BuildVNextCoverageReportProcessor.cs
index 6513af4e4..910ca9603 100644
--- a/src/SonarScanner.MSBuild.TFS/BuildVNextCoverageReportProcessor.cs
+++ b/src/SonarScanner.MSBuild.TFS/BuildVNextCoverageReportProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
using System.Collections.Generic;
using System.Linq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild.TFS
{
diff --git a/src/SonarScanner.MSBuild.PostProcessor/CoverageReportProcessor.cs b/src/SonarScanner.MSBuild.TFS/CoverageReportProcessor.cs
similarity index 92%
rename from src/SonarScanner.MSBuild.PostProcessor/CoverageReportProcessor.cs
rename to src/SonarScanner.MSBuild.TFS/CoverageReportProcessor.cs
index fd64b5048..a50c20dcd 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/CoverageReportProcessor.cs
+++ b/src/SonarScanner.MSBuild.TFS/CoverageReportProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -21,10 +21,10 @@
using System;
using System.Diagnostics;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
-namespace SonarScanner.MSBuild.PostProcessor
+namespace SonarScanner.MSBuild.TFS
{
public class CoverageReportProcessor : ICoverageReportProcessor
{
@@ -45,7 +45,7 @@ public CoverageReportProcessor(ILegacyTeamBuildFactory legacyTeamBuildFactory,
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
- public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings)
+ public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings, string propertiesFilePath)
{
if (settings == null)
{
@@ -54,7 +54,7 @@ public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings)
TryCreateCoverageReportProcessor(settings);
- initialisedSuccesfully = (processor != null && processor.Initialise(config, settings));
+ initialisedSuccesfully = (processor != null && processor.Initialise(config, settings, propertiesFilePath));
return initialisedSuccesfully;
}
diff --git a/src/SonarScanner.MSBuild.TFS/CoverageReportProcessorBase.cs b/src/SonarScanner.MSBuild.TFS/CoverageReportProcessorBase.cs
index 8c48f0162..692a7500d 100644
--- a/src/SonarScanner.MSBuild.TFS/CoverageReportProcessorBase.cs
+++ b/src/SonarScanner.MSBuild.TFS/CoverageReportProcessorBase.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,11 +20,10 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild.TFS
{
@@ -35,6 +34,7 @@ public abstract class CoverageReportProcessorBase : ICoverageReportProcessor
private AnalysisConfig config;
private ITeamBuildSettings settings;
+ private string propertiesFilePath;
private bool succesfullyInitialised = false;
@@ -46,10 +46,11 @@ protected CoverageReportProcessorBase(ICoverageReportConverter converter, ILogge
this.converter = converter ?? throw new ArgumentNullException(nameof(converter));
}
- public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings)
+ public bool Initialise(AnalysisConfig config, ITeamBuildSettings settings, string propertiesFilePath)
{
this.config = config ?? throw new ArgumentNullException(nameof(config));
this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
+ this.propertiesFilePath = propertiesFilePath ?? throw new ArgumentNullException(nameof(propertiesFilePath));
this.succesfullyInitialised = this.converter.Initialize();
return this.succesfullyInitialised;
@@ -62,8 +63,6 @@ public bool ProcessCoverageReports()
throw new InvalidOperationException(Resources.EX_CoverageReportProcessorNotInitialised);
}
- Debug.Assert(this.config != null, "Expecting the config to not be null. Did you call Initialize() ?");
-
if (config.GetSettingOrDefault(SonarProperties.VsTestReportsPaths, true, null) != null)
{
Logger.LogInfo(Resources.TRX_DIAG_SkippingCoverageCheckPropertyProvided);
@@ -76,7 +75,10 @@ public bool ProcessCoverageReports()
if (TryGetTrxFiles(this.config, this.settings, out var trxPaths) &&
trxPaths.Any())
{
- this.config.LocalSettings.Add(new Property { Id = SonarProperties.VsTestReportsPaths, Value = string.Join(",", trxPaths) });
+ using (StreamWriter sw = File.AppendText(propertiesFilePath))
+ {
+ sw.WriteLine($"{SonarProperties.VsTestReportsPaths}={string.Join(",", trxPaths.Select(c => c.Replace(@"\", @"\\")))}");
+ }
}
}
@@ -87,8 +89,10 @@ public bool ProcessCoverageReports()
coverageReportPaths.Any() &&
config.GetSettingOrDefault(SonarProperties.VsCoverageXmlReportsPaths, true, null) == null)
{
- this.config.LocalSettings.Add(new Property { Id = SonarProperties.VsCoverageXmlReportsPaths, Value = string.Join(",", coverageReportPaths) });
-
+ using (StreamWriter sw = File.AppendText(propertiesFilePath))
+ {
+ sw.WriteLine($"{SonarProperties.VsCoverageXmlReportsPaths}={string.Join(",", coverageReportPaths.Select(c => c.Replace(@"\", @"\\")))}");
+ }
}
return success;
diff --git a/src/SonarScanner.MSBuild.TFS/IBuildVNextCoverageSearchFallback.cs b/src/SonarScanner.MSBuild.TFS/IBuildVNextCoverageSearchFallback.cs
index e151f25e4..fd58b95c6 100644
--- a/src/SonarScanner.MSBuild.TFS/IBuildVNextCoverageSearchFallback.cs
+++ b/src/SonarScanner.MSBuild.TFS/IBuildVNextCoverageSearchFallback.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportConverter.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportConverter.cs
index 7c8cf37c6..198b683b6 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportConverter.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportConverter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportProcessor.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportProcessor.cs
index 0e6ab3485..8385bfd16 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportProcessor.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageReportProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
*/
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild.TFS
{
@@ -29,7 +29,7 @@ public interface ICoverageReportProcessor
/// Initializes the converter
///
/// Operation success
- bool Initialise(AnalysisConfig config, ITeamBuildSettings settings);
+ bool Initialise(AnalysisConfig config, ITeamBuildSettings settings, string propertiesFilePath);
///
/// Locate, download and convert the code coverage report
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageUrlProvider.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageUrlProvider.cs
index d1ec0feec..13ec0b248 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageUrlProvider.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ICoverageUrlProvider.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyBuildSummaryLogger.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyBuildSummaryLogger.cs
index 1c2e8240b..d88551600 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyBuildSummaryLogger.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyBuildSummaryLogger.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyTeamBuildFactory.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyTeamBuildFactory.cs
index b1f798d07..8b912fd1c 100644
--- a/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyTeamBuildFactory.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ILegacyTeamBuildFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ISummaryReportBuilder.cs b/src/SonarScanner.MSBuild.TFS/Interfaces/ISummaryReportBuilder.cs
similarity index 84%
rename from src/SonarScanner.MSBuild.PostProcessor/Interfaces/ISummaryReportBuilder.cs
rename to src/SonarScanner.MSBuild.TFS/Interfaces/ISummaryReportBuilder.cs
index 1d5a498be..b1ac59d0d 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/Interfaces/ISummaryReportBuilder.cs
+++ b/src/SonarScanner.MSBuild.TFS/Interfaces/ISummaryReportBuilder.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,10 +19,9 @@
*/
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS.Interfaces;
-using SonarScanner.MSBuild.Shim;
+using SonarScanner.MSBuild.Common.Interfaces;
-namespace SonarScanner.MSBuild.PostProcessor
+namespace SonarScanner.MSBuild.TFS
{
///
/// Encapsulates summary report building functionality
@@ -30,6 +29,6 @@ namespace SonarScanner.MSBuild.PostProcessor
/// Interface added for testability
public interface ISummaryReportBuilder
{
- void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, ProjectInfoAnalysisResult result);
+ void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, bool ranToCompletion, string fullPropertiesFilePath);
}
}
diff --git a/src/SonarScanner.MSBuild.TFS/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.TFS/Properties/AssemblyInfo.cs
index c9b9ffc46..ebdb94d8b 100644
--- a/src/SonarScanner.MSBuild.TFS/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.TFS/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Properties/InternalsVisibleTo.cs b/src/SonarScanner.MSBuild.TFS/Properties/InternalsVisibleTo.cs
index 5d56502ec..0793bc34f 100644
--- a/src/SonarScanner.MSBuild.TFS/Properties/InternalsVisibleTo.cs
+++ b/src/SonarScanner.MSBuild.TFS/Properties/InternalsVisibleTo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.TFS/Resources.Designer.cs b/src/SonarScanner.MSBuild.TFS/Resources.Designer.cs
index eab7a79a5..1a54a1a29 100644
--- a/src/SonarScanner.MSBuild.TFS/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.TFS/Resources.Designer.cs
@@ -96,6 +96,60 @@ internal static string PROC_DIAG_FetchingCoverageReportInfoFromServer {
}
}
+ ///
+ /// Looks up a localized string similar to Analysis failed for SonarQube project {0}.
+ ///
+ internal static string Report_AnalysisFailed {
+ get {
+ return ResourceManager.GetString("Report_AnalysisFailed", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Analysis succeeded for SonarQube project {0} [(Analysis results)] ({1}).
+ ///
+ internal static string Report_AnalysisSucceeded {
+ get {
+ return ResourceManager.GetString("Report_AnalysisSucceeded", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Invalid projects: {0}, skipped projects: {1}, excluded projects: {2}.
+ ///
+ internal static string Report_InvalidSkippedAndExcludedMessage {
+ get {
+ return ResourceManager.GetString("Report_InvalidSkippedAndExcludedMessage", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Product projects: {0}, test projects: {1}.
+ ///
+ internal static string Report_ProductAndTestMessage {
+ get {
+ return ResourceManager.GetString("Report_ProductAndTestMessage", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to "{0}", version {2}.
+ ///
+ internal static string Report_SonarQubeProjectDescription {
+ get {
+ return ResourceManager.GetString("Report_SonarQubeProjectDescription", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Updating the TeamBuild summary....
+ ///
+ internal static string Report_UpdatingTeamBuildSummary {
+ get {
+ return ResourceManager.GetString("Report_UpdatingTeamBuildSummary", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Absolute path to coverage file: {0}.
///
@@ -203,5 +257,14 @@ internal static string TRX_WARN_InvalidTrx {
return ResourceManager.GetString("TRX_WARN_InvalidTrx", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to ** WARNING: Support for XAML builds is deprecated since version 4.1 and will be removed in version 5.0 of the Scanner for MSBuild **.
+ ///
+ internal static string WARN_XamlBuildDeprecated {
+ get {
+ return ResourceManager.GetString("WARN_XamlBuildDeprecated", resourceCulture);
+ }
+ }
}
}
diff --git a/src/SonarScanner.MSBuild.TFS/Resources.resx b/src/SonarScanner.MSBuild.TFS/Resources.resx
index 981d07b99..ee7d7f886 100644
--- a/src/SonarScanner.MSBuild.TFS/Resources.resx
+++ b/src/SonarScanner.MSBuild.TFS/Resources.resx
@@ -129,6 +129,24 @@
Fetching code coverage report information from TFS...
+
+ Analysis failed for SonarQube project {0}
+
+
+ Analysis succeeded for SonarQube project {0} [(Analysis results)] ({1})
+
+
+ Invalid projects: {0}, skipped projects: {1}, excluded projects: {2}
+
+
+ Product projects: {0}, test projects: {1}
+
+
+ "{0}", version {2}
+
+
+ Updating the TeamBuild summary...
+
Absolute path to coverage file: {0}
@@ -165,4 +183,7 @@
Located trx file is not a valid xml file. File: {0}. File load error: {1}
+
+ ** WARNING: Support for XAML builds is deprecated since version 4.1 and will be removed in version 5.0 of the Scanner for MSBuild **
+
\ No newline at end of file
diff --git a/src/SonarScanner.MSBuild.TFS/SonarScanner.MSBuild.TFS.csproj b/src/SonarScanner.MSBuild.TFS/SonarScanner.MSBuild.TFS.csproj
index a9bf574bd..453a06f86 100644
--- a/src/SonarScanner.MSBuild.TFS/SonarScanner.MSBuild.TFS.csproj
+++ b/src/SonarScanner.MSBuild.TFS/SonarScanner.MSBuild.TFS.csproj
@@ -6,6 +6,7 @@
+
diff --git a/src/SonarScanner.MSBuild.PostProcessor/SummaryReportBuilder.cs b/src/SonarScanner.MSBuild.TFS/SummaryReportBuilder.cs
similarity index 91%
rename from src/SonarScanner.MSBuild.PostProcessor/SummaryReportBuilder.cs
rename to src/SonarScanner.MSBuild.TFS/SummaryReportBuilder.cs
index b09da3dcd..8a5259fe2 100644
--- a/src/SonarScanner.MSBuild.PostProcessor/SummaryReportBuilder.cs
+++ b/src/SonarScanner.MSBuild.TFS/SummaryReportBuilder.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -20,13 +20,13 @@
using System;
using System.Diagnostics;
-using System.Linq;
-using SonarScanner.MSBuild.Common;
using SonarScanner.MSBuild.Shim;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common;
+using SonarScanner.MSBuild.Common.Interfaces;
+using SonarScanner.MSBuild.Common.TFS;
+using System.Linq;
-namespace SonarScanner.MSBuild.PostProcessor
+namespace SonarScanner.MSBuild.TFS
{
///
/// Generates summary reports for various build systems
@@ -68,16 +68,23 @@ public SummaryReportBuilder(ILegacyTeamBuildFactory legacyTeamBuildFactory, ILog
///
/// Generates summary reports for LegacyTeamBuild and for Build Vnext
///
- public void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, ProjectInfoAnalysisResult result)
+ public void GenerateReports(ITeamBuildSettings settings, AnalysisConfig config, bool ranToCompletion, string fullPropertiesFilePath)
{
this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.config = config ?? throw new ArgumentNullException(nameof(config));
- this.result = result ?? throw new ArgumentNullException(nameof(result));
+
+ result = new ProjectInfoAnalysisResult();
+ result.RanToCompletion = ranToCompletion;
+ result.FullPropertiesFilePath = fullPropertiesFilePath;
+
+ new PropertiesFileGenerator(config, logger).TryWriteProperties(new PropertiesWriter(config, logger), out var allProjects);
+
+ result.Projects.AddRange(allProjects);
GenerateReports();
}
- #endregion IReportBuilder interface methods
+ #endregion IReportBuilder interface methods
private void GenerateReports()
{
@@ -158,7 +165,7 @@ private static string FindBranch(AnalysisConfig config)
return branch;
}
-
+
private void UpdateLegacyTeamBuildSummary(SummaryReportData summaryData)
{
logger.LogInfo(Resources.Report_UpdatingTeamBuildSummary);
diff --git a/src/SonarScanner.MSBuild.TFS/TrxFileReader.cs b/src/SonarScanner.MSBuild.TFS/TrxFileReader.cs
index a7d6359d3..01bb47295 100644
--- a/src/SonarScanner.MSBuild.TFS/TrxFileReader.cs
+++ b/src/SonarScanner.MSBuild.TFS/TrxFileReader.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/BuildTaskConstants.cs b/src/SonarScanner.MSBuild.Tasks/BuildTaskConstants.cs
index e3d6aa808..f11004068 100644
--- a/src/SonarScanner.MSBuild.Tasks/BuildTaskConstants.cs
+++ b/src/SonarScanner.MSBuild.Tasks/BuildTaskConstants.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/GetAnalyzerSettings.cs b/src/SonarScanner.MSBuild.Tasks/GetAnalyzerSettings.cs
index c06fa5dec..c1f0ff5a3 100644
--- a/src/SonarScanner.MSBuild.Tasks/GetAnalyzerSettings.cs
+++ b/src/SonarScanner.MSBuild.Tasks/GetAnalyzerSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -173,7 +173,7 @@ public override bool Execute()
var serverVersion = config?.FindServerVersion();
if (serverVersion == null || serverVersion < new Version("7.4"))
{
- logger.LogInfo(Resources.AnalyzerSettings_ExternalIssueNotSupported);
+ logger.LogInfo(Resources.AnalyzerSettings_ExternalIssueNotSupported, SonarProduct.GetSonarProductToLog(config?.SonarQubeHostUrl));
return false;
}
diff --git a/src/SonarScanner.MSBuild.Tasks/IsTestFileByName.cs b/src/SonarScanner.MSBuild.Tasks/IsTestFileByName.cs
index 6a3ecdd77..ebb81b457 100644
--- a/src/SonarScanner.MSBuild.Tasks/IsTestFileByName.cs
+++ b/src/SonarScanner.MSBuild.Tasks/IsTestFileByName.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/MSBuildLoggerAdapter.cs b/src/SonarScanner.MSBuild.Tasks/MSBuildLoggerAdapter.cs
index fade560ae..4e779c5ed 100644
--- a/src/SonarScanner.MSBuild.Tasks/MSBuildLoggerAdapter.cs
+++ b/src/SonarScanner.MSBuild.Tasks/MSBuildLoggerAdapter.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/MakeUniqueDir.cs b/src/SonarScanner.MSBuild.Tasks/MakeUniqueDir.cs
index 44a32190d..47353730e 100644
--- a/src/SonarScanner.MSBuild.Tasks/MakeUniqueDir.cs
+++ b/src/SonarScanner.MSBuild.Tasks/MakeUniqueDir.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild.Tasks/Properties/AssemblyInfo.cs
index 75e4384ba..ee8be0e02 100644
--- a/src/SonarScanner.MSBuild.Tasks/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild.Tasks/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/Properties/InternalsVisibleTo.cs b/src/SonarScanner.MSBuild.Tasks/Properties/InternalsVisibleTo.cs
index 9d5b6ac52..03fa24e18 100644
--- a/src/SonarScanner.MSBuild.Tasks/Properties/InternalsVisibleTo.cs
+++ b/src/SonarScanner.MSBuild.Tasks/Properties/InternalsVisibleTo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/Resources.Designer.cs b/src/SonarScanner.MSBuild.Tasks/Resources.Designer.cs
index fa161046f..12689bc46 100644
--- a/src/SonarScanner.MSBuild.Tasks/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild.Tasks/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild.Tasks {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -79,7 +79,7 @@ internal static string AnalyzerSettings_CreatingMergedRuleset {
}
///
- /// Looks up a localized string similar to External issues are not supported on this version of SonarQube. SQv7.4+ is required..
+ /// Looks up a localized string similar to External issues are not supported on this version of {0}. SQv7.4+ is required..
///
internal static string AnalyzerSettings_ExternalIssueNotSupported {
get {
@@ -124,7 +124,7 @@ internal static string AnalyzerSettings_MergingSettings {
}
///
- /// Looks up a localized string similar to No analysis settings were found in the Sonar config file for the current language: {0}.
+ /// Looks up a localized string similar to No analysis settings were found in the config file for the current language: {0}.
///
internal static string AnalyzerSettings_NoSettingsFoundForCurrentLanguage {
get {
@@ -133,7 +133,7 @@ internal static string AnalyzerSettings_NoSettingsFoundForCurrentLanguage {
}
///
- /// Looks up a localized string similar to Analyzer settings for language {0} have not been specified in the analysis config file.
+ /// Looks up a localized string similar to Analyzer settings for language {0} have not been specified in the analysis config file..
///
internal static string AnalyzerSettings_NotSpecifiedInConfig {
get {
@@ -297,6 +297,15 @@ internal static string WPIF_FailedToResolvePath {
}
}
+ ///
+ /// Looks up a localized string similar to No ProjectGuid has been found in neither the csproj nor the solution (Project {0}). A random one has been generated ({1})..
+ ///
+ internal static string WPIF_GeneratingRandomGuid {
+ get {
+ return ResourceManager.GetString("WPIF_GeneratingRandomGuid", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded to SonarQube. Project file: {0}.
///
diff --git a/src/SonarScanner.MSBuild.Tasks/Resources.resx b/src/SonarScanner.MSBuild.Tasks/Resources.resx
index 6089ce65f..1a029c7bc 100644
--- a/src/SonarScanner.MSBuild.Tasks/Resources.resx
+++ b/src/SonarScanner.MSBuild.Tasks/Resources.resx
@@ -145,7 +145,7 @@ Error: {1}
Failed to resolve path relative to project file. Path: {0}
- The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded to SonarQube. Project file: {0}
+ The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: {0}We're including the project file name in the message as only the message appears in the TeamBuild summary.
@@ -161,7 +161,7 @@ Error: {1}
Analysis setting "{0}" does not have "Value" metadata and will be ignored
- Analyzer settings for language {0} have not been specified in the analysis config file
+ Analyzer settings for language {0} have not been specified in the analysis config file.Using default regular expression for detecting test projects: {0}
@@ -179,7 +179,7 @@ Error: {1}
Overwriting analysis settings...
- No analysis settings were found in the Sonar config file for the current language: {0}
+ No analysis settings were found in the config file for the current language: {0}Removing duplicate files: {0}
@@ -200,7 +200,7 @@ Error: {1}
Failed to find ruleset file: '{0}'
- External issues are not supported on this version of SonarQube. SQv7.4+ is required.
+ External issues are not supported on this version of {0}. SQv7.4+ is required.{0}={1}
@@ -217,4 +217,7 @@ Error: {1}
Writing zero-length file:{0}
+
+ No ProjectGuid has been found in neither the csproj nor the solution (Project {0}). A random one has been generated ({1}).
+
\ No newline at end of file
diff --git a/src/SonarScanner.MSBuild.Tasks/Targets/SonarQube.Integration.targets b/src/SonarScanner.MSBuild.Tasks/Targets/SonarQube.Integration.targets
index 920760c80..458bbbd8c 100644
--- a/src/SonarScanner.MSBuild.Tasks/Targets/SonarQube.Integration.targets
+++ b/src/SonarScanner.MSBuild.Tasks/Targets/SonarQube.Integration.targets
@@ -498,13 +498,13 @@
- @(SonarReportFilePath->'%(identity)','|')
- $(ProjectSpecificOutDir)
diff --git a/src/SonarScanner.MSBuild.Tasks/TaskUtilities.cs b/src/SonarScanner.MSBuild.Tasks/TaskUtilities.cs
index 82e8d6ba9..65a010868 100644
--- a/src/SonarScanner.MSBuild.Tasks/TaskUtilities.cs
+++ b/src/SonarScanner.MSBuild.Tasks/TaskUtilities.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild.Tasks/WriteProjectInfoFile.cs b/src/SonarScanner.MSBuild.Tasks/WriteProjectInfoFile.cs
index b72b56e8a..f5bc7fe15 100644
--- a/src/SonarScanner.MSBuild.Tasks/WriteProjectInfoFile.cs
+++ b/src/SonarScanner.MSBuild.Tasks/WriteProjectInfoFile.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -340,7 +340,12 @@ private bool TryGetSettingValue(ITaskItem taskItem, out string metadataValue)
.FirstOrDefault();
}
- return null;
+ var generatedGuid = Guid.NewGuid().ToString();
+
+ Log.LogMessage(Resources.WPIF_GeneratingRandomGuid, FullProjectPath, generatedGuid);
+
+ //Generating a new guid for projects without one
+ return generatedGuid;
bool ArePathEquals(string filePath, FileInfo file) =>
filePath != null &&
diff --git a/src/SonarScanner.MSBuild.Tasks/WriteZeroLengthFiles.cs b/src/SonarScanner.MSBuild.Tasks/WriteZeroLengthFiles.cs
index 35a575575..8f56b24cd 100644
--- a/src/SonarScanner.MSBuild.Tasks/WriteZeroLengthFiles.cs
+++ b/src/SonarScanner.MSBuild.Tasks/WriteZeroLengthFiles.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/ArgumentProcessor.cs b/src/SonarScanner.MSBuild/ArgumentProcessor.cs
index 79199abbe..151adbfed 100644
--- a/src/SonarScanner.MSBuild/ArgumentProcessor.cs
+++ b/src/SonarScanner.MSBuild/ArgumentProcessor.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/BootstrapperClass.cs b/src/SonarScanner.MSBuild/BootstrapperClass.cs
index bb419dbde..0021a90f2 100644
--- a/src/SonarScanner.MSBuild/BootstrapperClass.cs
+++ b/src/SonarScanner.MSBuild/BootstrapperClass.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -23,9 +23,9 @@
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Threading.Tasks;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
-using SonarScanner.MSBuild.TFS.Interfaces;
+using SonarScanner.MSBuild.Common.Interfaces;
namespace SonarScanner.MSBuild
{
@@ -59,7 +59,7 @@ public BootstrapperClass(IProcessorFactory processorFactory, IBootstrapperSettin
///
/// Bootstraps a begin or end step, based on the bootstrap settings.
///
- public int Execute()
+ public async Task Execute()
{
int exitCode;
@@ -73,7 +73,7 @@ public int Execute()
{
if (phase == AnalysisPhase.PreProcessing)
{
- exitCode = PreProcess();
+ exitCode = await PreProcess();
}
else
{
@@ -90,7 +90,7 @@ public int Execute()
return exitCode;
}
- private int PreProcess()
+ private async Task PreProcess()
{
this.logger.LogInfo(Resources.MSG_PreparingDirectories);
@@ -104,7 +104,7 @@ private int PreProcess()
var preProcessor = this.processorFactory.CreatePreProcessor();
Directory.SetCurrentDirectory(this.bootstrapSettings.TempDirectory);
- var success = preProcessor.Execute(this.bootstrapSettings.ChildCmdLineArgs.ToArray());
+ var success = await preProcessor.Execute(this.bootstrapSettings.ChildCmdLineArgs.ToArray());
return success ? SuccessCode : ErrorCode;
}
diff --git a/src/SonarScanner.MSBuild/BootstrapperSettings.cs b/src/SonarScanner.MSBuild/BootstrapperSettings.cs
index 3ecfa2f88..09b7a1cd4 100644
--- a/src/SonarScanner.MSBuild/BootstrapperSettings.cs
+++ b/src/SonarScanner.MSBuild/BootstrapperSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/DefaultProcessorFactory.cs b/src/SonarScanner.MSBuild/DefaultProcessorFactory.cs
index 423ed80f9..5889eab61 100644
--- a/src/SonarScanner.MSBuild/DefaultProcessorFactory.cs
+++ b/src/SonarScanner.MSBuild/DefaultProcessorFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -18,9 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-using System;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
using SonarScanner.MSBuild.PostProcessor;
using SonarScanner.MSBuild.PostProcessor.Interfaces;
using SonarScanner.MSBuild.PreProcessor;
@@ -31,28 +29,20 @@ namespace SonarScanner.MSBuild
public class DefaultProcessorFactory : IProcessorFactory
{
private readonly ILogger logger;
- private readonly ILegacyTeamBuildFactory legacyTeamBuildFactory;
- private readonly ICoverageReportConverter coverageReportConverter;
- public DefaultProcessorFactory(ILogger logger,
- ILegacyTeamBuildFactory legacyTeamBuildFactory,
- ICoverageReportConverter coverageReportConverter)
+ public DefaultProcessorFactory(ILogger logger)
{
this.logger = logger;
- this.legacyTeamBuildFactory
- = legacyTeamBuildFactory ?? throw new ArgumentNullException(nameof(legacyTeamBuildFactory));
- this.coverageReportConverter
- = coverageReportConverter ?? throw new ArgumentNullException(nameof(coverageReportConverter));
}
public IMSBuildPostProcessor CreatePostProcessor()
{
return new MSBuildPostProcessor(
- new CoverageReportProcessor(legacyTeamBuildFactory, coverageReportConverter, logger),
new SonarScannerWrapper(logger),
- new SummaryReportBuilder(legacyTeamBuildFactory, logger),
logger,
- new TargetsUninstaller(logger));
+ new TargetsUninstaller(logger),
+ new TfsProcessorWrapper(logger),
+ new SonarProjectPropertiesValidator());
}
public ITeamBuildPreProcessor CreatePreProcessor()
diff --git a/src/SonarScanner.MSBuild/Interfaces/IBootstrapperSettings.cs b/src/SonarScanner.MSBuild/Interfaces/IBootstrapperSettings.cs
index 101043993..270e6f6ed 100644
--- a/src/SonarScanner.MSBuild/Interfaces/IBootstrapperSettings.cs
+++ b/src/SonarScanner.MSBuild/Interfaces/IBootstrapperSettings.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/Interfaces/IProcessorFactory.cs b/src/SonarScanner.MSBuild/Interfaces/IProcessorFactory.cs
index b838b4efb..2e8dfb543 100644
--- a/src/SonarScanner.MSBuild/Interfaces/IProcessorFactory.cs
+++ b/src/SonarScanner.MSBuild/Interfaces/IProcessorFactory.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/Program.cs b/src/SonarScanner.MSBuild/Program.cs
index 7ac5c14c0..cdf5777d9 100644
--- a/src/SonarScanner.MSBuild/Program.cs
+++ b/src/SonarScanner.MSBuild/Program.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
@@ -19,8 +19,8 @@
*/
using System;
+using System.Threading.Tasks;
using SonarScanner.MSBuild.Common;
-using SonarScanner.MSBuild.TFS;
namespace SonarScanner.MSBuild
{
@@ -29,26 +29,19 @@ public static class Program
public const int ErrorCode = 1;
public const int SuccessCode = 0;
- private static int Main(string[] args)
- => Execute(args, false);
+ private static async Task Main(string[] args)
+ => await Execute(args);
- public static int ExecuteFromLegacyEntryPoint(string[] args)
- => Execute(args, true);
-
- private static int Execute(string[] args, bool showDeprecatedWarning)
+ private static async Task Execute(string[] args)
{
var logger = new ConsoleLogger(includeTimestamp: false);
- if (showDeprecatedWarning)
- {
- logger.LogWarning(Resources.WARN_Deprecated_Entry_Point);
- }
- return Execute(args, logger);
+ return await Execute(args, logger);
}
- public static int Execute(string[] args, ILogger logger)
+ public static async Task Execute(string[] args, ILogger logger)
{
Utilities.LogAssemblyVersion(logger, Resources.AssemblyDescription);
-#if IS_NET_FRAMEWORK
+#if NET46
logger.LogInfo("Using the .NET Framework version of the Scanner for MSBuild");
#else
logger.LogInfo("Using the .NET Core version of the Scanner for MSBuild");
@@ -71,7 +64,7 @@ public static int Execute(string[] args, ILogger logger)
logger.ResumeOutput();
return SuccessCode;
}
-
+
try
{
if (!ArgumentProcessor.TryProcessArgs(args, logger, out IBootstrapperSettings settings))
@@ -82,10 +75,9 @@ public static int Execute(string[] args, ILogger logger)
return ErrorCode;
}
- var processorFactory = new DefaultProcessorFactory(logger, GetLegacyTeamBuildFactory(logger),
- GetCoverageReportConverter(logger));
+ var processorFactory = new DefaultProcessorFactory(logger);
var bootstrapper = new BootstrapperClass(processorFactory, settings, logger);
- var exitCode = bootstrapper.Execute();
+ var exitCode = await bootstrapper.Execute();
Environment.ExitCode = exitCode;
return exitCode;
}
@@ -97,24 +89,6 @@ public static int Execute(string[] args, ILogger logger)
}
}
- private static ICoverageReportConverter GetCoverageReportConverter(ILogger logger)
- {
-#if IS_NET_FRAMEWORK
- return new SonarScanner.MSBuild.TFS.Classic.BinaryToXmlCoverageReportConverter(logger);
-#else
- return new NullCoverageReportConverter();
-#endif
- }
-
- private static ILegacyTeamBuildFactory GetLegacyTeamBuildFactory(ILogger logger)
- {
-#if IS_NET_FRAMEWORK
- return new SonarScanner.MSBuild.TFS.Classic.XamlBuild.LegacyTeamBuildFactory(logger);
-#else
- return new NotSupportedLegacyTeamBuildFactory();
-#endif
- }
-
#if DEBUG
private static void DEBUG_DumpLoadedAssemblies(ILogger logger)
{
diff --git a/src/SonarScanner.MSBuild/Properties/AssemblyInfo.cs b/src/SonarScanner.MSBuild/Properties/AssemblyInfo.cs
index f6b8cf07f..018f7fa24 100644
--- a/src/SonarScanner.MSBuild/Properties/AssemblyInfo.cs
+++ b/src/SonarScanner.MSBuild/Properties/AssemblyInfo.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
diff --git a/src/SonarScanner.MSBuild/Resources.Designer.cs b/src/SonarScanner.MSBuild/Resources.Designer.cs
index 54febe797..00190d244 100644
--- a/src/SonarScanner.MSBuild/Resources.Designer.cs
+++ b/src/SonarScanner.MSBuild/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace SonarScanner.MSBuild {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -97,7 +97,7 @@ internal static string ERROR_CmdLine_BothBeginAndEndSupplied {
}
///
- /// Looks up a localized string similar to SonarQube analysis could not be completed because the analysis configuration file could not be found: {0}..
+ /// Looks up a localized string similar to {1} analysis could not be completed because the analysis configuration file could not be found: {0}..
///
internal static string ERROR_ConfigFileNotFound {
get {
diff --git a/src/SonarScanner.MSBuild/SonarQube.Analysis.xml b/src/SonarScanner.MSBuild/SonarQube.Analysis.xml
index 65439d2c1..a11d51709 100644
--- a/src/SonarScanner.MSBuild/SonarQube.Analysis.xml
+++ b/src/SonarScanner.MSBuild/SonarQube.Analysis.xml
@@ -12,8 +12,8 @@
- A property defined in the SonarQube User Interface at global level which can't override anything.
Note that the following properties cannot be set through an MSBuild project file or an SonarQube.Analysis.xml file:
- sonar.projectName, sonar.projectKey, sonar.projectVersion
- The following flags need to be used to set their value: /n:[SonarQube Project Name] /k:[SonarQube Project Key] /v:[SonarQube Project Version]
+ sonar.projectName, sonar.projectKey, sonar.projectVersion, sonar.organization
+ The following flags need to be used to set their value: /n:[SonarQube Project Name] /k:[SonarQube Project Key] /v:[SonarQube Project Version] /o:[Sonar Project Organization]
-->
diff --git a/src/SonarScanner.MSBuild/SonarScanner.MSBuild.csproj b/src/SonarScanner.MSBuild/SonarScanner.MSBuild.csproj
index b4295dad9..5d1582fe8 100644
--- a/src/SonarScanner.MSBuild/SonarScanner.MSBuild.csproj
+++ b/src/SonarScanner.MSBuild/SonarScanner.MSBuild.csproj
@@ -1,6 +1,6 @@
- $(ScannerNetCoreAppVersion);$(ScannerNetFxVersion);$(ScannerNetCoreGlobalToolVersion)
+ $(ScannerNetCoreVersion);$(ScannerNetFxVersion);$(ScannerNetVersion)SonarScanner.MSBuildExe
@@ -10,18 +10,15 @@
Designer
+
+
+
-
-
-
-
-
- True
@@ -36,10 +33,4 @@
-
-
-
- $(DefineConstants);IS_NET_FRAMEWORK
-
-
\ No newline at end of file
diff --git a/tests/SonarScanner.MSBuild.Tasks.Integrationtests/MSBuildExecution/BuildLog.cs b/tests/SonarScanner.MSBuild.Tasks.Integrationtests/MSBuildExecution/BuildLog.cs
index 5a8b4a7ed..ffc1db9f7 100644
--- a/tests/SonarScanner.MSBuild.Tasks.Integrationtests/MSBuildExecution/BuildLog.cs
+++ b/tests/SonarScanner.MSBuild.Tasks.Integrationtests/MSBuildExecution/BuildLog.cs
@@ -1,6 +1,6 @@
/*
* SonarScanner for MSBuild
- * Copyright (C) 2016-2019 SonarSource SA
+ * Copyright (C) 2016-2020 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or