@@ -18,45 +18,39 @@ module Environment =
1818 let [<Literal>] REPOSITORY = " https://github.com/Kimserey/Groomgy.HealthChecks.AspNetCore.git"
1919
2020module GitVersion =
21- module Process =
22- let exec f =
21+ let showVariable =
22+ let execProcess f =
2323 Process.execWithResult f ( System.TimeSpan.FromMinutes 2. )
24-
25- let private exec commit args =
26- match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ BRANCH, Environment.environVarOrNone Environment.APPVEYOR_ PULL_ REQUEST_ NUMBER with
27- | Some branch, None ->
28- Process.exec ( fun info ->
29- { info with
30- FileName = " gitversion"
31- Arguments = sprintf " /url %s /b b-%s /dynamicRepoLocation .\g itversion /c %s %s " Environment.REPOSITORY branch commit args })
32- | _ ->
33- Process.exec ( fun info -> { info with FileName = " gitversion" ; Arguments = args })
34-
35- let private getResult ( result : ProcessResult ) =
36- result.Messages |> List.head
24+ |> fun r -> r.Messages
25+ |> List.head
26+
27+ let commit =
28+ match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ COMMIT with
29+ | Some c -> c
30+ | None -> execProcess ( fun info -> { info with FileName = " git" ; Arguments = " rev-parse HEAD" })
31+
32+ printfn " Executing gitversion from commit '%s '." commit
33+
34+ fun variable ->
35+ match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ BRANCH, Environment.environVarOrNone Environment.APPVEYOR_ PULL_ REQUEST_ NUMBER with
36+ | Some branch, None ->
37+ execProcess ( fun info ->
38+ { info with
39+ FileName = " gitversion"
40+ Arguments = sprintf " /showvariable %s /url %s /b b-%s /dynamicRepoLocation .\g itversion /c %s " variable Environment.REPOSITORY branch commit })
41+ | _ ->
42+ execProcess ( fun info -> { info with FileName = " gitversion" ; Arguments = sprintf " /showvariable %s " variable })
3743
3844 let get =
39- let mutable value : Option <( unit -> ProcessResult ) * string * string > = None
45+ let mutable value : Option < string * string * string > = None
4046
4147 fun () ->
4248 match value with
4349 | None ->
44- let commit =
45- match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ COMMIT with
46- | Some c -> c
47- | None -> Process.exec ( fun info -> { info with FileName = " git" ; Arguments = " rev-parse HEAD" }) |> getResult
48-
49- printfn " Executing gitversion from commit '%s '." commit
50-
51- match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ TAG_ NAME with
52- | Some v ->
53- printfn " Full sementic versioning: '%s ', NuGet sementic versioning: '%s '" v v
54- value <- Some (( fun () -> exec commit " /updateassemblyinfo" ), v, v)
55- | None ->
56- let fullSemVer = exec commit " /showvariable FullSemVer" |> getResult
57- let nuGetVer = exec commit " /showvariable NuGetVersionV2" |> getResult
58- printfn " Full sementic versioning: '%s ', NuGet sementic versioning: '%s '" fullSemVer nuGetVer
59- value <- Some (( fun () -> exec commit " /updateassemblyinfo" ), fullSemVer, nuGetVer)
50+ value <-
51+ match Environment.environVarOrNone Environment.APPVEYOR_ REPO_ TAG_ NAME with
52+ | Some v -> Some ( v, showVariable " AssemblySemVer" , v)
53+ | None -> Some ( showVariable " FullSemVer" , showVariable " AssemblySemVer" , showVariable " NuGetVersionV2" )
6054
6155 Target.activateFinal " ClearGitVersionRepositoryLocation"
6256 Option.get value
@@ -70,24 +64,27 @@ Target.create "Clean" (fun _ ->
7064 |> Shell.deleteDirs
7165)
7266
73- Target.create " PatchAssemblyInfo" ( fun _ ->
74- let ( updateAssemblyInfo , _ , _ ) = GitVersion.get()
75-
76- updateAssemblyInfo()
77- |> fun res -> res.Messages
78- |> List.iter ( printfn " %s " )
67+ Target.create " PrintVersion" ( fun _ ->
68+ let ( fullSemVer , assemblyVer , nugetVer ) = GitVersion.get()
69+ printfn " Full version: '%s '" fullSemVer
70+ printfn " Assembly version: '%s '" assemblyVer
71+ printfn " NuGet version: '%s '" nugetVer
7972)
8073
8174Target.create " UpdateBuildVersion" ( fun _ ->
82- let ( _ , fullSemVer , _ ) = GitVersion.get()
75+ let ( fullSemVer , _ , _ ) = GitVersion.get()
8376
8477 Shell.Exec( " appveyor" , sprintf " UpdateBuild -Version \" %s (%s )\" " fullSemVer ( Environment.environVar Environment.APPVEYOR_ BUILD_ NUMBER))
8578 |> ignore
8679)
8780
8881Target.create " Build" ( fun _ ->
82+ let ( fullSemVer , assemblyVer , _ ) = GitVersion.get()
83+
8984 let setParams ( buildOptions : DotNet.BuildOptions ) =
90- { buildOptions with Configuration = DotNet.BuildConfiguration.fromEnvironVarOrDefault Environment.BUILD_ CONFIGURATION DotNet.BuildConfiguration.Debug }
85+ { buildOptions with
86+ Common = { buildOptions.Common with DotNet.CustomParams = Some ( sprintf " /p:Version=%s /p:FileVersion=%s " fullSemVer assemblyVer) }
87+ Configuration = DotNet.BuildConfiguration.fromEnvironVarOrDefault Environment.BUILD_ CONFIGURATION DotNet.BuildConfiguration.Debug }
9188
9289 !! " **/*.*proj"
9390 -- " **/samples/**/*.*proj"
@@ -118,7 +115,7 @@ Target.createFinal "ClearGitVersionRepositoryLocation" (fun _ ->
118115Target.create " All" ignore
119116
120117" Clean"
121- =?> ( " PatchAssemblyInfo " , Environment.environVarAsBool Environment.APPVEYOR )
118+ ==> " PrintVersion "
122119 =?> ( " UpdateBuildVersion" , Environment.environVarAsBool Environment.APPVEYOR)
123120 ==> " Build"
124121 ==> " Pack"
0 commit comments