diff --git a/FAKE.sln b/FAKE.sln
index e8ce2b4e63b..da17813a32c 100644
--- a/FAKE.sln
+++ b/FAKE.sln
@@ -66,7 +66,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "help", "help", "{564BD198-0
help\nuget.md = help\nuget.md
help\octopusdeploy.md = help\octopusdeploy.md
help\slacknotification.md = help\slacknotification.md
- help\sonarcube.md = help\sonarcube.md
help\specifictargets.md = help\specifictargets.md
help\teamcity.md = help\teamcity.md
help\typescript.md = help\typescript.md
diff --git a/build.fsx b/build.fsx
index 13f534735fc..4a0717bb1a0 100644
--- a/build.fsx
+++ b/build.fsx
@@ -202,7 +202,8 @@ let dotnetAssemblyInfos =
"Fake.Tools.Git", "Running git commands"
"Fake.Testing.Common", "Common testing data types"
"Fake.Tracing.NAntXml", "NAntXml"
- "Fake.Windows.Chocolatey", "Running and packaging with Chocolatey" ]
+ "Fake.Windows.Chocolatey", "Running and packaging with Chocolatey"
+ "Fake.Testing.SonarQube", "Analyzing your project with SonarQube" ]
let assemblyInfos =
[ "./src/app/FAKE/AssemblyInfo.fs",
diff --git a/help/markdown/todo-sonarcube.md b/help/markdown/testing-sonarqube.md
similarity index 89%
rename from help/markdown/todo-sonarcube.md
rename to help/markdown/testing-sonarqube.md
index bb65e5ac906..c2ebe755784 100644
--- a/help/markdown/todo-sonarcube.md
+++ b/help/markdown/testing-sonarqube.md
@@ -1,7 +1,5 @@
# Analyze your code with SonarQube
-**Note: This documentation is for FAKE.exe before version 5 (or the non-netcore version). The documentation needs te be updated, please help! **
-
From the [web page](http://sonarqube.org):
"The SonarQube® platform is an open source quality management platform, dedicated to continuously analyzing and measuring the technical quality of source code, from project portfolio down to the method level"
@@ -16,8 +14,10 @@ compilation has finished. The result is then collected and sent to the SonarQube
## Minimal working example
+ open Fake.Testing
+
Target "BeginSonarQube" (fun _ ->
- SonarQube Begin (fun p ->
+ SonarQube.Begin (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
@@ -26,7 +26,7 @@ compilation has finished. The result is then collected and sent to the SonarQube
)
Target "EndSonarQube" (fun _ ->
- SonarQubeEnd()
+ SonarQube.End None
)
Target "Default" DoNothing
@@ -49,7 +49,7 @@ By default, the SonarQube module looks for the MSBuild runner in the 'tools/Sona
* You can send additional global settings to the server with the '/d:' parameter.
In the SonarQubeParams, this is the new field Settings:
- SonarQube Begin (fun p ->
+ SonarQube.Begin (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
@@ -60,7 +60,7 @@ In the SonarQubeParams, this is the new field Settings:
* Configuration can also be read from a configuration file. This is the '/s:' parameter.
This can be done with the new field Config:
- SonarQube Begin (fun p ->
+ SonarQube.Begin (fun p ->
{p with
Key = "MyProject"
Name = "Main solution"
diff --git a/help/templates/template.cshtml b/help/templates/template.cshtml
index 55977b50ca2..c0fef50d54b 100644
--- a/help/templates/template.cshtml
+++ b/help/templates/template.cshtml
@@ -110,6 +110,12 @@
Chocolatey
+
+ Testing
+
+
Legacy / Not Migrated
@@ -119,7 +125,6 @@
Windows.WiX
API.Slack
API.MsTeams
- Testing.SonarQube
DotNet.StyleCop
Fake.Deploy
?.?.IIS
diff --git a/src/Fake-netcore.sln b/src/Fake-netcore.sln
index f99043c8f8c..174cd207fa2 100644
--- a/src/Fake-netcore.sln
+++ b/src/Fake-netcore.sln
@@ -61,6 +61,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fake.DotNet.Paket", "app\Fa
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fake.netcore", "app\Fake.netcore\Fake.netcore.fsproj", "{6B339DA3-8DED-4262-A427-3C4CCDD00650}"
EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fake.Testing.SonarQube", "app\Fake.Testing.SonarQube\Fake.Testing.SonarQube.fsproj", "{2A985028-4410-40F7-992C-5397DC1ED116}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -410,6 +412,18 @@ Global
{CDFB2B10-050A-4188-8F72-2BCC61E9814F}.Release|x64.Build.0 = Release|x64
{CDFB2B10-050A-4188-8F72-2BCC61E9814F}.Release|x86.ActiveCfg = Release|x86
{CDFB2B10-050A-4188-8F72-2BCC61E9814F}.Release|x86.Build.0 = Release|x86
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|x64.ActiveCfg = Debug|x64
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|x64.Build.0 = Debug|x64
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|x86.ActiveCfg = Debug|x86
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Debug|x86.Build.0 = Debug|x86
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|x64.ActiveCfg = Release|x64
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|x64.Build.0 = Release|x64
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|x86.ActiveCfg = Release|x86
+ {2A985028-4410-40F7-992C-5397DC1ED116}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E2CF8635-E7C4-4470-92DD-F706F052BF7B} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
@@ -440,5 +454,6 @@ Global
{E32B2631-476A-4C2D-AE18-275ED7A22F10} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{80314941-78D5-4928-B943-93FC945E050F} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
{CDFB2B10-050A-4188-8F72-2BCC61E9814F} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
+ {2A985028-4410-40F7-992C-5397DC1ED116} = {7BFFAE76-DEE9-417A-A79B-6A6644C4553A}
EndGlobalSection
EndGlobal
diff --git a/src/app/Fake.Testing.SonarQube/AssemblyInfo.fs b/src/app/Fake.Testing.SonarQube/AssemblyInfo.fs
new file mode 100644
index 00000000000..26fa39bb774
--- /dev/null
+++ b/src/app/Fake.Testing.SonarQube/AssemblyInfo.fs
@@ -0,0 +1,17 @@
+// Auto-Generated by FAKE; do not edit
+namespace System
+open System.Reflection
+
+[]
+[]
+[]
+[]
+[]
+do ()
+
+module internal AssemblyVersionInformation =
+ let [] AssemblyTitle = "FAKE - F# Make Analizing your project with SOnarQube"
+ let [] AssemblyProduct = "FAKE - F# Make"
+ let [] AssemblyVersion = "5.0.0"
+ let [] AssemblyInformationalVersion = "5.0.0"
+ let [] AssemblyFileVersion = "5.0.0"
diff --git a/src/app/Fake.Testing.SonarQube/Fake.Testing.SonarQube.fsproj b/src/app/Fake.Testing.SonarQube/Fake.Testing.SonarQube.fsproj
new file mode 100644
index 00000000000..e611a9a12a6
--- /dev/null
+++ b/src/app/Fake.Testing.SonarQube/Fake.Testing.SonarQube.fsproj
@@ -0,0 +1,34 @@
+
+
+ 1.0.0-alpha-10
+ netstandard1.6
+ $(DefineConstants);NO_DOTNETCORE_BOOTSTRAP
+ pdbonly
+ true
+ Fake.Testing.SonarQube
+ Library
+ $(PackageTargetFallback);portable-net45+win8;dnxcore50
+
+
+ $(DefineConstants);NETSTANDARD;USE_HTTPCLIENT
+
+
+ $(DefineConstants);RELEASE
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.0.0-preview2-020000
+
+
+
+
diff --git a/src/app/Fake.Testing.SonarQube/SonarQube.fs b/src/app/Fake.Testing.SonarQube/SonarQube.fs
new file mode 100644
index 00000000000..cd9bfaccfaf
--- /dev/null
+++ b/src/app/Fake.Testing.SonarQube/SonarQube.fs
@@ -0,0 +1,101 @@
+/// Contains a task to run the msbuild runner of [SonarQube analyzer](http://sonarqube.org).
+module Fake.Testing.SonarQube
+
+ open System.IO
+ open Fake.Core
+ open Fake.Core.Globbing
+ open Fake.Core.Process
+ open Fake.IO.FileSystem.Operators
+
+ /// [omit]
+ /// The supported commands of SonarQube. It is called with Begin before compilation, and End after compilation.
+ type private SonarQubeCall = Begin | End
+
+ /// Parameter type to configure the SonarQube runner.
+ type SonarQubeParams = {
+ /// FileName of the SonarQube runner exe.
+ ToolsPath : string
+ /// Key to identify the SonarQube project
+ Key : string
+ /// Name of the project
+ Name : string
+ /// Version number of the project
+ Version : string
+ /// Individual global settings for SonarQube
+ Settings : string list
+ /// Read settings from configuration file
+ Config : string option
+ }
+
+ /// SonarQube default parameters - tries to locate MSBuild.SonarQube.exe in any subfolder.
+ let SonarQubeDefaults =
+ { ToolsPath = Tools.findToolInSubPath "MSBuild.SonarQube.Runner.exe" (Directory.GetCurrentDirectory() @@ "tools" @@ "SonarQube")
+ Key = null
+ Name = null
+ Version = "1.0"
+ Settings = []
+ Config = None }
+
+ /// [omit]
+ /// Execute the external msbuild runner of SonarQube. Parameters are given to the command line tool as required.
+ let private SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
+ let sonarPath = parameters.ToolsPath
+ let setArgs = parameters.Settings |> List.fold (fun acc x -> acc + "/d:" + x + " ") ""
+
+ let cfgArgs =
+ match parameters.Config with
+ | Some(x) -> (" /s:"+x)
+ | None -> ""
+
+ let args =
+ match call with
+ | Begin -> "begin /k:\"" + parameters.Key + "\" /n:\"" + parameters.Name + "\" /v:\"" + parameters.Version + "\" " + setArgs + cfgArgs
+ | End -> "end " + setArgs + cfgArgs
+
+ let result =
+ ExecProcess (fun info ->
+ info.FileName <- sonarPath
+ info.Arguments <- args) System.TimeSpan.MaxValue
+ if result <> 0 then failwithf "Error during sonar qube call %s" (call.ToString())
+
+ /// This task to can be used to run the begin command of [Sonar Qube](http://sonarqube.org/) on a project.
+ /// ## Parameters
+ ///
+ /// - `setParams` - Function used to overwrite the SonarQube default parameters.
+ ///
+ /// ## Sample
+
+ /// open Fake.Testing
+ ///
+ /// SonarQube.Begin (fun p ->
+ /// {p with
+ /// Key = "MyProject"
+ /// Name = "MainTool"
+ /// Version = "1.0 })
+ ///
+ let Begin setParams =
+ use __ = Trace.traceTask "SonarQube" "Begin"
+ let parameters = setParams SonarQubeDefaults
+ SonarQubeCall Begin parameters
+
+ /// This task to can be used to run the end command of [Sonar Qube](http://sonarqube.org/) on a project.
+ /// ## Parameters
+ ///
+ /// - `setParams` - Function used to overwrite the SonarQube default parameters.
+ ///
+ /// ## Sample
+
+ /// open Fake.Testing
+ ///
+ /// SonarQube.End None
+ ///
+ /// SonarQube.End (fun p ->
+ /// {p with
+ /// Settings = ["sonar.login=login", "sonar.password=password"] })
+ ///
+ let End setParams =
+ use __ = Trace.traceTask "SonarQube" "End"
+ let parameters = match setParams with
+ | Some setParams -> setParams SonarQubeDefaults
+ | None -> (fun p -> { p with Settings = [] }) SonarQubeDefaults
+ SonarQubeCall End parameters
diff --git a/src/app/Fake.Testing.SonarQube/paket.references b/src/app/Fake.Testing.SonarQube/paket.references
new file mode 100644
index 00000000000..95d3ffa1cb7
--- /dev/null
+++ b/src/app/Fake.Testing.SonarQube/paket.references
@@ -0,0 +1,4 @@
+group netcore
+FSharp.NET.Sdk
+FSharp.Core
+NETStandard.Library
\ No newline at end of file
diff --git a/src/app/FakeLib/FakeLib.fsproj b/src/app/FakeLib/FakeLib.fsproj
index 619bc805261..589a1f1f819 100644
--- a/src/app/FakeLib/FakeLib.fsproj
+++ b/src/app/FakeLib/FakeLib.fsproj
@@ -254,6 +254,9 @@
Fake.DotNet.Paket/PaketTemplate.fs
+
+ Fake.Testing.SonarQube/SonarQube.fs
+
diff --git a/src/app/FakeLib/SonarQubeHelper.fs b/src/app/FakeLib/SonarQubeHelper.fs
index e7d06eba1d6..2eb8b938032 100644
--- a/src/app/FakeLib/SonarQubeHelper.fs
+++ b/src/app/FakeLib/SonarQubeHelper.fs
@@ -1,10 +1,13 @@
/// Contains a task to run the msbuild runner of [Sonar Qube analyzer](http://sonarqube.org).
+[]
module Fake.SonarQubeHelper
open TraceHelper
/// The supported commands of Sonar Qube. It is called with Begin before compilation, and End after compilation.
+[]
type SonarQubeCall = Begin | End
+[]
/// Parameter type to configure the sonar qube runner.
[]
type SonarQubeParams =
@@ -22,6 +25,7 @@ type SonarQubeParams =
Config : string option
}
+[]
/// SonarQube default parameters - tries to locate MSBuild.SonarQube.exe in any subfolder.
let SonarQubeDefaults =
{ ToolsPath = findToolInSubPath "MSBuild.SonarQube.Runner.exe" (currentDirectory @@ "tools" @@ "SonarQube")
@@ -31,6 +35,7 @@ let SonarQubeDefaults =
Settings = []
Config = None }
+[]
/// Execute the external msbuild runner of Sonar Qube. Parameters are fiven to the command line tool as required.
let SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
let sonarPath = parameters.ToolsPath
@@ -66,6 +71,7 @@ let SonarQubeCall (call: SonarQubeCall) (parameters : SonarQubeParams) =
/// Name = "MainTool"
/// Version = "1.0 })
///
+[]
let SonarQube (call: SonarQubeCall) setParams =
use __ = traceStartTaskUsing "SonarQube" (call.ToString())
let parameters = setParams SonarQubeDefaults
@@ -77,5 +83,6 @@ let SonarQube (call: SonarQubeCall) setParams =
/// SonarQubeEnd
///
+[]
let SonarQubeEnd() =
SonarQube End (fun p -> { p with Settings = [] })