<commit_before>#r @"tools\FAKE.Core\tools\FakeLib.dll"
open Fake
open System

let authors = ["<NAME>"]

let projectName = "ScriptCs.Octokit"
let projectDescription = "Octokit Script Pack for ScriptCs."
let projectSummary = projectDescription

let buildDir = "./src/ScriptCs.Octokit/bin"
let packagingRoot = "./packaging/"
let packagingDir = packagingRoot @@ "ScriptCs.Octokit"
let localNuGet = "C:\NuGet"

let buildMode = getBuildParamOrDefault "buildMode" "Release"
let releaseNotes =
  ReadFile "ReleaseNotes.md"
  |> ReleaseNotesHelper.parseReleaseNotes

MSBuildDefaults <- {
  MSBuildDefaults with
    ToolsVersion = Some "12.0"
    Verbosity = Some MSBuildVerbosity.Minimal
}

Target "Clean" (fun _ ->
    CleanDirs [buildDir; packagingDir; packagingRoot;]
)

Target "AssemblyInfo" (fun _ ->
    AssemblyInfoHelper.ReplaceAssemblyInfoVersions (fun p ->
        {p with
            OutputFileName = "./src/ScriptCs.Octokit/Properties/AssemblyInfo.cs"
            AssemblyVersion = releaseNotes.AssemblyVersion
            AssemblyFileVersion = releaseNotes.AssemblyVersion
            AssemblyInformationalVersion = releaseNotes.AssemblyVersion
        })
)

let setParams defaults = {
  defaults with
    ToolsVersion = Some("12.0")
    Targets = ["Build"]
    Properties =
      [
        "Configuration", buildMode
        "RestorePackages", "true"
      ]
}

Target "BuildApp" (fun _ ->
  build setParams "./ScriptCs.Octokit.sln"
    |> DoNothing
)

let private packageFileName project version = sprintf "%s.%s.nupkg" project version

Target "RunTests" (fun _ ->
    CopyFile localNuGet (packagingRoot @@ (packageFileName projectName releaseNotes.AssemblyVersion) )

    let result = ExecProcess(fun info ->
        info.FileName <- FullName "./src/ScriptCs.Octokit.Sample/run.cmd"
        info.UseShellExecute <- false
        info.WorkingDirectory <- FullName "./src/ScriptCs.Octokit.Sample/") (TimeSpan.FromMinutes 5.0)
    if result <> 0 then failwithf "run.cmd returned with a non-zero exit code"
)

Target "CreateNuGetPackage" (fun _ ->
  let net45Dir = packagingDir @@ "lib/net45"
  CleanDirs [net45Dir]

  CopyFile net45Dir (buildDir @@ "Release/ScriptCs.Octokit.dll")

  NuGet (fun p ->
    {p with
      Authors = authors
      Project = projectName
      Description = projectDescription
      OutputPath = packagingRoot
      Summary = projectSummary
      WorkingDir = packagingDir
      Version = releaseNotes.AssemblyVersion
      ReleaseNotes = toLines releaseNotes.Notes
      Dependencies =
        [
          "Octokit", GetPackageVersion "./packages/" "Octokit"
          "ScriptCs.Contracts", GetPackageVersion "./packages/" "ScriptCs.Contracts"
        ]
      Publish = false }) "./ScriptCs.Octokit.nuspec"
)

Target "PublishNuGetPackage" (fun _ ->
    trace "This is where we will publish the NuGet package to NuGet"
    NuGetPublish (fun p ->
    {p with
        OutputPath = packagingRoot
        WorkingDir = packagingDir
        Project = projectName
        Version = releaseNotes.AssemblyVersion
        AccessKey = getBuildParamOrDefault "nugetApiKey" ""
    })
)

Target "Default" DoNothing

Target "CreatePackage" DoNothing

Target "PublishPackage" DoNothing

"Clean"
  ==> "AssemblyInfo"
  ==> "BuildApp"
  ==> "Default"
  ==> "CreateNuGetPackage"
  ==> "CreatePackage"
  ==> "RunTests"
  =?> ("PublishNuGetPackage", hasBuildParam "nugetApiKey")<commit_msg>More build script tweaking<commit_after>#r @"tools\FAKE.Core\tools\FakeLib.dll"
open Fake
open System

let authors = ["<NAME>"]

let projectName = "ScriptCs.Octokit"
let projectDescription = "Octokit Script Pack for ScriptCs."
let projectSummary = projectDescription

let buildDir = "./src/ScriptCs.Octokit/bin"
let packagingRoot = "./packaging/"
let packagingDir = packagingRoot @@ "ScriptCs.Octokit"
let localNuGet = "C:\NuGet"

let buildMode = getBuildParamOrDefault "buildMode" "Release"
let releaseNotes =
  ReadFile "ReleaseNotes.md"
  |> ReleaseNotesHelper.parseReleaseNotes

let private packageFileName project version = sprintf "%s.%s.nupkg" project version

MSBuildDefaults <- {
  MSBuildDefaults with
    ToolsVersion = Some "12.0"
    Verbosity = Some MSBuildVerbosity.Minimal
}

let setParams defaults = {
  defaults with
    ToolsVersion = Some("12.0")
    Targets = ["Build"]
    Properties =
      [
        "Configuration", buildMode
      ]
}

Target "Clean" (fun _ ->
    CleanDirs [buildDir; packagingDir; packagingRoot;]
)

Target "AssemblyInfo" (fun _ ->
    AssemblyInfoHelper.ReplaceAssemblyInfoVersions (fun p ->
        {p with
            OutputFileName = "./src/ScriptCs.Octokit/Properties/AssemblyInfo.cs"
            AssemblyVersion = releaseNotes.AssemblyVersion
            AssemblyFileVersion = releaseNotes.AssemblyVersion
            AssemblyInformationalVersion = releaseNotes.AssemblyVersion
        })
)

Target "BuildApp" (fun _ ->
    RestorePackages()
    build setParams "./ScriptCs.Octokit.sln"
        |> DoNothing
)

Target "UnitTests" (fun _ -> 
    trace "This is where unit tests should be run"
)

Target "EndToEndTests" (fun _ ->
    CopyFile localNuGet (packagingRoot @@ (packageFileName projectName releaseNotes.AssemblyVersion) )

    let result = ExecProcess(fun info ->
        info.FileName <- FullName "./src/ScriptCs.Octokit.Sample/run.cmd"
        info.UseShellExecute <- false
        info.WorkingDirectory <- FullName "./src/ScriptCs.Octokit.Sample/") (TimeSpan.FromMinutes 5.0)
    if result <> 0 then failwithf "run.cmd returned with a non-zero exit code"
)

Target "CreateNuGetPackage" (fun _ ->
  let net45Dir = packagingDir @@ "lib/net45"
  CleanDirs [net45Dir]

  CopyFile net45Dir (buildDir @@ "Release/ScriptCs.Octokit.dll")

  NuGet (fun p ->
    {p with
      Authors = authors
      Project = projectName
      Description = projectDescription
      OutputPath = packagingRoot
      Summary = projectSummary
      WorkingDir = packagingDir
      Version = releaseNotes.AssemblyVersion
      ReleaseNotes = toLines releaseNotes.Notes
      Dependencies =
        [
          "Octokit", GetPackageVersion "./packages/" "Octokit"
          "ScriptCs.Contracts", GetPackageVersion "./packages/" "ScriptCs.Contracts"
        ]
      Publish = false }) "./ScriptCs.Octokit.nuspec"
)

Target "PublishNuGetPackage" (fun _ ->
    NuGetPublish (fun p ->
    {p with
        OutputPath = packagingRoot
        WorkingDir = packagingDir
        Project = projectName
        Version = releaseNotes.AssemblyVersion
        AccessKey = getBuildParamOrDefault "nugetApiKey" ""
    })
)

Target "Default" DoNothing

Target "CreatePackage" DoNothing

Target "PublishPackage" DoNothing

"Clean"
  ==> "AssemblyInfo"
  ==> "BuildApp"
  ==> "UnitTests"
  ==> "Default"
  ==> "CreateNuGetPackage"
  ==> "CreatePackage"
  ==> "EndToEndTests"
  =?> ("PublishNuGetPackage", hasBuildParam "nugetApiKey")
{'fraction_non_alphanumeric': 0.10572429906542057, 'fraction_numerical': 0.004964953271028037, 'mean_word_length': 3.2940438871473354, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2668454', 'n_tokens_mistral': 2119, 'n_tokens_neox': 2006, 'n_words': 480}