Skip to content

Commit a8ab052

Browse files
committed
Build: more clean up
1 parent ef49abd commit a8ab052

7 files changed

Lines changed: 261 additions & 268 deletions

File tree

build/Building.fs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,38 @@ open Fake.DotNet
66
open Fake.IO.FileSystemOperators
77

88
open Model
9-
open Dotnet
109

11-
let rootDir = System.Environment.CurrentDirectory
1210

13-
let clean (solution:Solution) = dotnet rootDir (sprintf "clean %s --configuration Release --verbosity minimal" solution.SolutionFile)
11+
let private dotnet command =
12+
DotNet.exec id command "" |> ignore<ProcessResult>
1413

15-
let restoreWeak (solution:Solution) = dotnetWeak rootDir (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
16-
let restoreStrong (solution:Solution) = dotnetStrong rootDir (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
14+
let private dotnetWeak command =
15+
let properties = [ ("StrongName", "False") ]
16+
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
17+
DotNet.exec id command suffix |> ignore<ProcessResult>
1718

18-
let buildWeak (solution:Solution) = dotnetWeak rootDir (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
19-
let buildStrong (solution:Solution) = dotnetStrong rootDir (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
19+
let private dotnetStrong command =
20+
let properties = [ ("StrongName", "True") ]
21+
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
22+
DotNet.exec id command suffix |> ignore<ProcessResult>
2023

21-
let packWeak (solution:Solution) = dotnetWeak rootDir (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
22-
let packStrong (solution:Solution) = dotnetStrong rootDir (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
24+
25+
let clean (solution:Solution) = dotnet (sprintf "clean %s --configuration Release --verbosity minimal" solution.SolutionFile)
26+
27+
let restoreWeak (solution:Solution) = dotnetWeak (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
28+
let restoreStrong (solution:Solution) = dotnetStrong (sprintf "restore %s --verbosity minimal" solution.SolutionFile)
29+
30+
let buildWeak (solution:Solution) = dotnetWeak (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
31+
let buildStrong (solution:Solution) = dotnetStrong (sprintf "build %s --configuration Release --no-incremental --no-restore --verbosity minimal" solution.SolutionFile)
32+
33+
let packWeak (solution:Solution) = dotnetWeak (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
34+
let packStrong (solution:Solution) = dotnetStrong (sprintf "pack %s --configuration Release --no-restore --verbosity minimal" solution.SolutionFile)
2335

2436
let packProjectWeak = function
25-
| VisualStudio p -> dotnetWeak rootDir (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
37+
| VisualStudio p -> dotnetWeak (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
2638
| _ -> failwith "Project type not supported"
2739
let packProjectStrong = function
28-
| VisualStudio p -> dotnetStrong rootDir (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
40+
| VisualStudio p -> dotnetStrong (sprintf "pack %s --configuration Release --no-restore --no-build" p.ProjectFile)
2941
| _ -> failwith "Project type not supported"
3042

3143
let buildVS2019x86 config isIncremental subject =
@@ -44,6 +56,3 @@ let buildVS2019x64 config isIncremental subject =
4456
[("Configuration", config); ("Platform","x64")]
4557
subject
4658
|> ignore<string list>
47-
48-
let test testsDir testsProj framework =
49-
dotnet testsDir (sprintf "run --project %s --configuration Release --framework %s --no-restore --no-build" testsProj framework)

build/Documentation.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
open FSharp.Core
44
open Fake.Core
5+
open Fake.DotNet
56
open Fake.IO
67
open Fake.IO.FileSystemOperators
78
open System
89

910
open Model
11+
open Dotnet
1012

1113
let provideDocExtraFiles extraDocs (releases:Release list) =
1214
for (fileName, docName) in extraDocs do Shell.copyFile ("docs" </> docName) fileName
@@ -18,3 +20,6 @@ let provideDocExtraFiles extraDocs (releases:Release list) =
1820
""
1921
File.readAsString release.ReleaseNotesFile ]
2022
|> File.replaceContent ("docs" </> (release.ReleaseNotesFile |> String.replace "RELEASENOTES" "ReleaseNotes"))
23+
24+
let buildDocs outputDir = dotnet (sprintf "fsdocs build --noapidocs --output %s" outputDir)
25+
let watchDocs outputDir = dotnet (sprintf "fsdocs watch --noapidocs --output %s" outputDir)

build/Dotnet.fs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,4 @@ open FSharp.Core
44
open Fake.Core
55
open Fake.DotNet
66

7-
let dotnet workingDir command =
8-
DotNet.exec (fun c -> { c with WorkingDirectory = workingDir}) command "" |> ignore<ProcessResult>
9-
10-
let dotnetWeak workingDir command =
11-
let properties = [ ("StrongName", "False") ]
12-
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
13-
DotNet.exec (fun c -> { c with WorkingDirectory = workingDir }) command suffix |> ignore<ProcessResult>
14-
15-
let dotnetStrong workingDir command =
16-
let properties = [ ("StrongName", "True") ]
17-
let suffix = properties |> List.map (fun (name, value) -> sprintf """ /p:%s="%s" /nr:false """ name value) |> String.concat ""
18-
DotNet.exec (fun c -> { c with WorkingDirectory = workingDir}) command suffix |> ignore<ProcessResult>
7+
let dotnet command = DotNet.exec id command "" |> ignore<ProcessResult>

build/Packaging.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let provideLicense path =
3131
|> String.convertTextToWindowsLineBreaks
3232
|> File.replaceContent (path </> "license.txt")
3333

34-
let provideReadme header title (release:Release) path =
34+
let private provideReadme header title (release:Release) path =
3535
String.concat Environment.NewLine [header; " " + title; ""; File.readAsString release.ReleaseNotesFile]
3636
|> String.convertTextToWindowsLineBreaks
3737
|> File.replaceContent (path </> "readme.txt")
@@ -78,7 +78,7 @@ let zip (package:ZipPackage) header zipDir filesDir filesFilter =
7878
Directory.delete "obj/Zip"
7979

8080

81-
let updateNuspec (nuget:NuGetPackage) outPath dependencies (spec:NuGet.NuGet.NuGetParams) =
81+
let private updateNuspec (nuget:NuGetPackage) outPath dependencies (spec:NuGet.NuGet.NuGetParams) =
8282
{ spec with ToolPath = "packages/build/NuGet.CommandLine/tools/NuGet.exe"
8383
OutputPath = outPath
8484
WorkingDir = "obj/NuGet"

build/Testing.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Testing
2+
3+
open FSharp.Core
4+
open Fake.Core
5+
open Fake.DotNet
6+
7+
let test testsDir testsProj framework =
8+
DotNet.exec
9+
(fun c -> { c with WorkingDirectory = testsDir })
10+
(sprintf "run --project %s --configuration Release --framework %s --no-restore --no-build" testsProj framework)
11+
""
12+
|> ignore<ProcessResult>

0 commit comments

Comments
 (0)