Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDepend helper #564

Merged
merged 2 commits into from
Oct 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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