Skip to content

Commit

Permalink
Merge pull request #564 from jamescrowley/NDepend
Browse files Browse the repository at this point in the history
NDepend helper
  • Loading branch information
forki committed Oct 16, 2014
2 parents 90fd29a + b63d4ab commit 3dcea47
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="FXCopHelper.fs" />
<Compile Include="FSharpFormattingHelper.fs" />
<Compile Include="NCoverHelper.fs" />
<Compile Include="NDependHelper.fs" />
<Compile Include="MsBuildLogger.fs" />
<Compile Include="FileHelper.fs" />
<Compile Include="MSBuildHelper.fs" />
Expand Down Expand Up @@ -416,4 +417,4 @@
</ItemGroup>
</When>
</Choose>
</Project>
</Project>
42 changes: 42 additions & 0 deletions src/app/FakeLib/NDependHelper.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Fake.NDepend

open Fake
open System
open System.IO
open System.Text

let getWorkingDir workingDir =
Seq.find isNotNullOrEmpty [workingDir; environVar("teamcity.build.workingDir"); "."]
|> Path.GetFullPath

let buildParamsAndExecute parameters buildArguments toolPath workingDir =
let args = buildArguments parameters
trace (toolPath + " " + args)
let result = ExecProcess (fun info ->
info.FileName <- toolPath
info.WorkingDirectory <- getWorkingDir workingDir
info.Arguments <- args) TimeSpan.MaxValue
if result <> 0 then failwithf "Error running %s" toolPath

type NDependParams =
{ ToolPath: string
WorkingDir: string
ProjectFile: string
CoverageFiles: string list }

let NDependDefaults =
{ ToolPath = findToolInSubPath "ndepend.console.exe" (currentDirectory @@ "tools" @@ "NDepend")
WorkingDir = ""
ProjectFile = ""
CoverageFiles = [] }

let buildNDependArgs parameters =
new StringBuilder()
|> append parameters.ProjectFile
|> appendWithoutQuotes "/CoverageFiles "
|> appendFileNamesIfNotNull parameters.CoverageFiles
|> toText

let NDepend (setParams: NDependParams -> NDependParams) =
let parameters = (NDependDefaults |> setParams)
buildParamsAndExecute parameters buildNDependArgs parameters.ToolPath parameters.WorkingDir

0 comments on commit 3dcea47

Please sign in to comment.