Skip to content
This repository
tag: 1.42.19.0
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 203 lines (164 sloc) 6.733 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
#I @"tools\FAKE"
#r "FakeLib.dll"

open Fake
 
// properties
let projectName = "FAKE"
let projectSummary = "FAKE - F# Make - Get rid of the noise in your build scripts."
let projectDescription = "FAKE - F# Make - is a build automation tool for .NET. Tasks and dependencies are specified in a DSL which is integrated in F#."
let authors = ["Steffen Forkmann"]
let mail = "forkmann@gmx.de"
let homepage = "http://github.com/forki/fake"

TraceEnvironmentVariables()
  
let buildDir = @".\build\"
let testDir = @".\test\"
let metricsDir = @".\BuildMetrics\"
let deployDir = @".\Publish\"
let docsDir = @".\docs\"
let nugetDir = @".\nuget\"
let templatesSrcDir = @".\docu\src\Docu.Console\templates\"

let deployZip = deployDir + sprintf "%s-%s.zip" projectName buildVersion

// files
let appReferences = !+ @"src\app\**\*.*sproj" |> Scan
let testReferences = !+ @"src\test\**\*.*sproj" |> Scan

// tools
let nunitPath = @".\Tools\NUnit"

// Targets
Target? Clean <-
    fun _ -> CleanDirs [buildDir; testDir; deployDir; docsDir; metricsDir; nugetDir]


Target? BuildApp <-
    fun _ ->
        if not isLocalBuild then
            AssemblyInfo
             (fun p ->
                {p with
                   CodeLanguage = FSharp;
                   AssemblyVersion = buildVersion;
                   AssemblyTitle = "FAKE - F# Make Command line tool";
                   Guid = "fb2b540f-d97a-4660-972f-5eeff8120fba";
                   OutputFileName = @".\src\app\FAKE\AssemblyInfo.fs"})
                   
            AssemblyInfo
             (fun p ->
                {p with
                   CodeLanguage = FSharp;
                   AssemblyVersion = buildVersion;
                   AssemblyTitle = "FAKE - F# Make Lib";
                   Guid = "d6dd5aec-636d-4354-88d6-d66e094dadb5";
                   OutputFileName = @".\src\app\FakeLib\AssemblyInfo.fs"})

            AssemblyInfo
             (fun p ->
                {p with
                   CodeLanguage = FSharp;
                   AssemblyVersion = buildVersion;
                   AssemblyTitle = "FAKE - F# Make SQL Lib";
                   Guid = "A161EAAF-EFDA-4EF2-BD5A-4AD97439F1BE";
                   OutputFileName = @".\src\app\Fake.SQL\AssemblyInfo.fs"})
                      
            AssemblyInfo
             (fun p ->
                {p with
                   CodeLanguage = FSharp;
                   AssemblyVersion = buildVersion;
                   AssemblyTitle = "FAKE - F# Make Git Lib";
                   Guid = "2101B852-0B08-4EAA-A343-85E399327A98";
                   OutputFileName = @".\src\app\Fake.Git\AssemblyInfo.fs"})
                     
        MSBuildRelease buildDir "Build" appReferences
            |> Log "AppBuild-Output: "

Target? BuildDocu <-
    fun _ ->
        MSBuildRelease null "Build" [@".\docu\Build.proj"]
            |> Log "DocuBuild-Output: "
        Copy buildDir [@".\docu\artifacts\docu.exe"; @".\docu\License.txt"]
        Rename (buildDir + @"DocuLicense.txt") (buildDir + @"License.txt")


Target? GenerateDocumentation <-
    fun _ ->
        !+ (buildDir + "Fake*.dll")
          |> Scan
          |> Docu (fun p ->
                {p with
                    ToolPath = buildDir @@ "docu.exe"
                    TemplatesPath = templatesSrcDir
                    OutputPath = docsDir })
            

Target? CopyLicense <-
    fun _ -> Copy buildDir [@"License.txt"; @"readme.markdown"]

Target? BuildZip <-
    fun _ ->
      !+ (buildDir + @"\**\*.*")
        -- "*.zip"
        -- "**/*.pdb"
          |> Scan
          |> Zip buildDir deployZip

Target? BuildTest <-
    fun _ ->
        MSBuildDebug testDir "Build" testReferences
          |> Log "TestBuild-Output: "

Target? Test <-
    fun _ ->
        !+ (testDir + @"\*.dll")
          |> Scan
          |> NUnit (fun p ->
                {p with
                   ToolPath = nunitPath;
                   DisableShadowCopy = true;
                   Framework = "net-2.0.50727";
                   OutputFile = metricsDir @@ "nunit-result.xml"})

Target? ZipCalculatorSample <-
    fun _ ->
        // copy fake file output to sample tools path
        !+ (buildDir + @"\**\*.*")
          |> Scan
          |> Copy @".\Samples\Calculator\tools\FAKE\"
        
        !+ @"Samples\Calculator\**\*.*"
          -- "**\*Resharper*\**"
          -- "**\*Resharper*"
          -- "**\bin\Debug\**"
          -- "**\obj\Debug\**"
          -- "**\bin\Release\**"
          -- "**\obj\Release\**"
            |> Scan
            |> Zip @".\Samples\Calculator" (deployDir @@ sprintf "CalculatorSample-%s.zip" buildVersion)

Target? ZipDocumentation <-
    fun _ ->
        !+ (docsDir + @"\**\*.*")
          |> Scan
          |> Zip docsDir (deployDir @@ sprintf "Documentation-%s.zip" buildVersion)

Target? DeployNuGet <-
    fun _ ->
        let nugetDocsDir = nugetDir @@ "docs/"
        let nugetToolsDir = nugetDir @@ "sol/"
        
        XCopy docsDir nugetDocsDir
        XCopy buildDir nugetToolsDir

        CopyFile nugetDir @".\fake.nuspec"

        let replacements =
          ["@build.number@",if not isLocalBuild then buildVersion else "0.1.0.0"
           "@authors@",authors |> Seq.map (sprintf "<author>%s</author>") |> separated " "
           "@project@",projectName
           "@summary@",projectSummary
           "@description@",projectDescription]

        processTemplates replacements [nugetDir @@ "fake.nuspec"]
        
        let nugetTool = @".\tools\NuGet\NuGet.exe"
        let args = "pack fake.nuspec"
        let result =
            ExecProcess (fun info ->
                info.FileName <- nugetTool
                info.WorkingDirectory <- nugetDir |> FullName
                info.Arguments <- args) System.TimeSpan.MaxValue
               
        if result <> 0 then failwithf "Error during NuGet creation. %s %s" nugetTool args

Target? Deploy <- DoNothing
Target? Default <- DoNothing

// Dependencies

For? BuildApp <- Dependency? Clean
For? Test <- Dependency? Clean
For? BuildZip <- Dependency? BuildApp |> And? CopyLicense
For? ZipCalculatorSample <- Dependency? Clean
For? Test <- Dependency? BuildApp |> And? BuildTest

For? DeployNuGet <-
    Dependency? Test
      |> And? BuildDocu
      |> And? BuildZip
      |> And? ZipCalculatorSample
      |> And? ZipDocumentation

For? Deploy <- Dependency? DeployNuGet
For? GenerateDocumentation <- Dependency? BuildApp
For? ZipDocumentation <- Dependency? GenerateDocumentation
For? Default <- Dependency? Deploy

// start build
Run? Default
Something went wrong with that request. Please try again.