|
| 1 | +module Model |
| 2 | + |
| 3 | +open FSharp.Core |
| 4 | +open Fake.Core |
| 5 | +open Fake.IO |
| 6 | +open Fake.IO.FileSystemOperators |
| 7 | +open System.IO |
| 8 | + |
| 9 | +type Release = |
| 10 | + { RepoKey: string |
| 11 | + Title: string |
| 12 | + AssemblyVersion: string |
| 13 | + PackageVersion: string |
| 14 | + ReleaseNotes: string |
| 15 | + ReleaseNotesFile: string } |
| 16 | + |
| 17 | +type ZipPackage = |
| 18 | + { Id: string |
| 19 | + Release: Release |
| 20 | + Title: string } |
| 21 | + |
| 22 | +type NuGetPackage = |
| 23 | + { Id: string |
| 24 | + Release: Release } |
| 25 | + |
| 26 | +type VisualStudioProject = |
| 27 | + { AssemblyName: string |
| 28 | + ProjectFile: string |
| 29 | + OutputDir: string |
| 30 | + Release: Release |
| 31 | + NuGetPackages: NuGetPackage list } |
| 32 | + |
| 33 | +type NativeVisualStudioProject = |
| 34 | + { BinaryName: string |
| 35 | + ProjectFile: string |
| 36 | + OutputDir: string |
| 37 | + Release: Release |
| 38 | + NuGetPackages: NuGetPackage list } |
| 39 | + |
| 40 | +type NativeBashScriptProject = |
| 41 | + { BinaryName: string |
| 42 | + BashScriptFile: string |
| 43 | + OutputDir: string |
| 44 | + Release: Release |
| 45 | + NuGetPackages: NuGetPackage list } |
| 46 | + |
| 47 | +type Project = |
| 48 | + | VisualStudio of VisualStudioProject |
| 49 | + | NativeVisualStudio of NativeVisualStudioProject |
| 50 | + | NativeBashScript of NativeBashScriptProject |
| 51 | + |
| 52 | +type Solution = |
| 53 | + { Key: string |
| 54 | + SolutionFile: string |
| 55 | + Projects: Project list |
| 56 | + Release: Release |
| 57 | + ZipPackages: ZipPackage list |
| 58 | + OutputDir: string |
| 59 | + OutputLibDir: string |
| 60 | + OutputLibStrongNameDir: string |
| 61 | + OutputZipDir: string |
| 62 | + OutputNuGetDir: string } |
| 63 | + |
| 64 | +type NuGetSpecification = |
| 65 | + { NuGet: NuGetPackage |
| 66 | + NuSpecFile: string |
| 67 | + Dependencies: (string * string) list |
| 68 | + Title: string } |
| 69 | + |
| 70 | +let release repoKey title releaseNotesFile : Release = |
| 71 | + let info = ReleaseNotes.load releaseNotesFile |
| 72 | + let buildPart = "0" |
| 73 | + let assemblyVersion = info.AssemblyVersion + "." + buildPart |
| 74 | + let packageVersion = info.NugetVersion |
| 75 | + let notes = info.Notes |> List.map (fun l -> l.Replace("*","").Replace("`","")) |> String.toLines |
| 76 | + { Release.RepoKey = repoKey |
| 77 | + Title = title |
| 78 | + AssemblyVersion = assemblyVersion |
| 79 | + PackageVersion = packageVersion |
| 80 | + ReleaseNotes = notes |
| 81 | + ReleaseNotesFile = releaseNotesFile } |
| 82 | + |
| 83 | +let zipPackage packageId title release = |
| 84 | + { ZipPackage.Id = packageId |
| 85 | + Title = title |
| 86 | + Release = release } |
| 87 | + |
| 88 | +let nugetPackage packageId release = |
| 89 | + { NuGetPackage.Id = packageId |
| 90 | + Release = release } |
| 91 | + |
| 92 | +let project assemblyName projectFile nuGetPackages = |
| 93 | + { VisualStudioProject.AssemblyName = assemblyName |
| 94 | + ProjectFile = projectFile |
| 95 | + OutputDir = (Path.GetDirectoryName projectFile) </> "bin" </> "Release" |
| 96 | + NuGetPackages = nuGetPackages |
| 97 | + Release = nuGetPackages |> List.map (fun p -> p.Release) |> List.distinct |> List.exactlyOne } |
| 98 | + |> Project.VisualStudio |
| 99 | + |
| 100 | +let nativeProject binaryName projectFile nuGetPackages = |
| 101 | + { NativeVisualStudioProject.BinaryName = binaryName |
| 102 | + ProjectFile = projectFile |
| 103 | + OutputDir = (Path.GetDirectoryName projectFile) </> "bin" </> "Release" |
| 104 | + NuGetPackages = nuGetPackages |
| 105 | + Release = nuGetPackages |> List.map (fun p -> p.Release) |> List.distinct |> List.exactlyOne } |
| 106 | + |> Project.NativeVisualStudio |
| 107 | + |
| 108 | +let nativeBashScriptProject binaryName bashScriptFile nuGetPackages = |
| 109 | + { NativeBashScriptProject.BinaryName = binaryName |
| 110 | + BashScriptFile = bashScriptFile |
| 111 | + OutputDir = (Path.GetDirectoryName bashScriptFile) </> "bin" </> "Release" |
| 112 | + NuGetPackages = nuGetPackages |
| 113 | + Release = nuGetPackages |> List.map (fun p -> p.Release) |> List.distinct |> List.exactlyOne } |
| 114 | + |> Project.NativeBashScript |
| 115 | + |
| 116 | + |
| 117 | +let projectOutputDir = function |
| 118 | + | VisualStudio p -> p.OutputDir |
| 119 | + | NativeVisualStudio p -> p.OutputDir |
| 120 | + | NativeBashScript p -> p.OutputDir |
| 121 | + |
| 122 | +let projectRelease = function |
| 123 | + | VisualStudio p -> p.Release |
| 124 | + | NativeVisualStudio p -> p.Release |
| 125 | + | NativeBashScript p -> p.Release |
| 126 | + |
| 127 | +let projectNuGetPackages = function |
| 128 | + | VisualStudio p -> p.NuGetPackages |
| 129 | + | NativeVisualStudio p -> p.NuGetPackages |
| 130 | + | NativeBashScript p -> p.NuGetPackages |
| 131 | + |
| 132 | +let solution key solutionFile projects zipPackages = |
| 133 | + { Solution.Key = key |
| 134 | + SolutionFile = solutionFile |
| 135 | + Projects = projects |
| 136 | + ZipPackages = zipPackages |
| 137 | + Release = List.concat [ projects |> List.map projectRelease; zipPackages |> List.map (fun p -> p.Release) ] |> List.distinct |> List.exactlyOne |
| 138 | + OutputDir = "out" </> key |
| 139 | + OutputLibDir = "out" </> key </> "Lib" |
| 140 | + OutputLibStrongNameDir = "out" </> key </> "Lib-StrongName" |
| 141 | + OutputZipDir = "out" </> key </> "Zip" |
| 142 | + OutputNuGetDir = "out" </> key </> "NuGet" } |
0 commit comments