Skip to content

Commit d8b8cfa

Browse files
committed
Update build pipeline, add strong name
1 parent aafff8d commit d8b8cfa

File tree

13 files changed

+250
-106
lines changed

13 files changed

+250
-106
lines changed

Plotly.NET.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{BF60
88
.editorconfig = .editorconfig
99
.config\dotnet-tools.json = .config\dotnet-tools.json
1010
global.json = global.json
11+
key.snk = key.snk
1112
LICENSE = LICENSE
1213
README.md = README.md
1314
RELEASE_NOTES.md = RELEASE_NOTES.md

build/BasicTasks.fs

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,56 @@ open Fake.IO.Globbing.Operators
77

88
open ProjectInfo
99

10+
/// Buildtask for setting a prerelease tag (also sets the mutable isPrerelease to true, and the PackagePrereleaseTag of all project infos accordingly.)
1011
let setPrereleaseTag =
1112
BuildTask.create "SetPrereleaseTag" [] {
1213
printfn "Please enter pre-release package suffix"
1314
let suffix = System.Console.ReadLine()
1415
prereleaseSuffix <- suffix
15-
prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix)
1616
isPrerelease <- true
17+
projects
18+
|> List.iter (fun p ->
19+
p.PackagePrereleaseTag <- (sprintf "%s-%s" p.PackageVersionTag suffix)
20+
)
21+
//
22+
prereleaseTag <- (sprintf "%s-%s" CoreProject.PackageVersionTag suffix)
1723
}
1824

25+
/// cleans the bin, obj/obj dir of all projects and test projects, as well as the pkg dir.
1926
let clean =
2027
BuildTask.create "Clean" [] {
2128
!! "src/**/bin" ++ "src/**/obj" ++ "tests/**/bin" ++ "tests/**/obj" ++ "pkg" |> Shell.cleanDirs
2229
}
2330

24-
let build =
25-
BuildTask.create "Build" [ clean ] { solutionFile |> DotNet.build id }
31+
/// builds the solution file (dotnet build solution.sln)
32+
let buildSolution =
33+
BuildTask.create "BuildSolution" [ clean ] { solutionFile |> DotNet.build id }
34+
35+
/// builds the individual project files (dotnet build project.*proj)
36+
///
37+
/// The following MSBuild params are set for each project accordingly to the respective ProjectInfo:
38+
///
39+
/// - AssemblyVersion
40+
///
41+
/// - AssemblyInformationalVersion
42+
let build = BuildTask.create "Build" [clean] {
43+
projects
44+
|> List.iter (fun pInfo ->
45+
let proj = pInfo.ProjFile
46+
proj
47+
|> DotNet.build (fun p ->
48+
let msBuildParams =
49+
{p.MSBuildParams with
50+
Properties = ([
51+
"AssemblyVersion", pInfo.AssemblyVersion
52+
"InformationalVersion", pInfo.AssemblyInformationalVersion
53+
])
54+
}
55+
{
56+
p with
57+
MSBuildParams = msBuildParams
58+
}
59+
|> DotNet.Options.withCustomParams (Some "--no-dependencies")
60+
)
61+
)
62+
}

build/DocumentationTasks.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ open BlackFox.Fake
88

99
let buildDocs =
1010
BuildTask.create "BuildDocs" [ build ] {
11-
printfn "building docs with stable version %s" stableVersionTag
11+
printfn "building docs with stable version %s" stableDocsVersionTag
1212

1313
runDotNet
1414
(sprintf
1515
"fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
16-
stableVersionTag)
16+
stableDocsVersionTag)
1717
"./"
1818
}
1919

@@ -30,12 +30,12 @@ let buildDocsPrerelease =
3030

3131
let watchDocs =
3232
BuildTask.create "WatchDocs" [ build ] {
33-
printfn "watching docs with stable version %s" stableVersionTag
33+
printfn "watching docs with stable version %s" stableDocsVersionTag
3434

3535
runDotNet
3636
(sprintf
3737
"fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
38-
stableVersionTag)
38+
stableDocsVersionTag)
3939
"./"
4040
}
4141

build/PackageTasks.fs

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,52 @@ open TestTasks
88

99
open BlackFox.Fake
1010
open Fake.Core
11+
open Fake.DotNet
1112
open Fake.IO.Globbing.Operators
1213

13-
let pack =
14-
BuildTask.create "Pack" [ clean; build; runTests ] {
15-
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag) then
16-
!! "src/**/*.*proj" -- "src/bin/*"
17-
|> Seq.iter (
18-
Fake.DotNet.DotNet.pack (fun p ->
19-
let msBuildParams =
14+
let pack = BuildTask.create "Pack" [ clean; build; runTests ] {
15+
projects
16+
|> List.iter (fun pInfo ->
17+
if promptYesNo $"creating stable package for {pInfo.Name}{System.Environment.NewLine}\tpackage version: {pInfo.PackageVersionTag}{System.Environment.NewLine}\tassembly version: {pInfo.AssemblyVersion}{System.Environment.NewLine}\tassembly informational version: {pInfo.AssemblyInformationalVersion}{System.Environment.NewLine} OK?" then
18+
pInfo.ProjFile
19+
|> Fake.DotNet.DotNet.pack (fun p ->
20+
let msBuildParams =
21+
match pInfo.ReleaseNotes with
22+
| Some r ->
23+
{ p.MSBuildParams with
24+
Properties =
25+
([
26+
"Version",pInfo.PackageVersionTag
27+
"AssemblyVersion", pInfo.AssemblyVersion
28+
"AssemblyInformationalVersion", pInfo.AssemblyVersion
29+
"PackageReleaseNotes", (r.Notes |> String.concat "\r\n")
30+
"TargetsForTfmSpecificContentInPackage", "" //https://github.com/dotnet/fsharp/issues/12320
31+
]
32+
@ p.MSBuildParams.Properties)
33+
}
34+
| _ ->
2035
{ p.MSBuildParams with
2136
Properties =
2237
([
23-
"Version", stableVersionTag
24-
"PackageReleaseNotes", (release.Notes |> String.concat "\r\n")
25-
]
26-
@ p.MSBuildParams.Properties)
38+
"Version",pInfo.PackageVersionTag
39+
"AssemblyVersion", pInfo.AssemblyVersion
40+
"AssemblyInformationalVersion", pInfo.AssemblyVersion
41+
"TargetsForTfmSpecificContentInPackage", "" //https://github.com/dotnet/fsharp/issues/12320
42+
]
43+
@ p.MSBuildParams.Properties)
2744
}
45+
2846

29-
{ p with
30-
MSBuildParams = msBuildParams
31-
OutputPath = Some pkgDir
32-
})
47+
{ p with
48+
MSBuildParams = msBuildParams
49+
OutputPath = Some pkgDir
50+
NoBuild = true
51+
}
52+
|> DotNet.Options.withCustomParams (Some "--no-dependencies")
3353
)
3454
else
3555
failwith "aborted"
56+
)
3657
}
3758

3859
let packPrerelease =
@@ -44,26 +65,44 @@ let packPrerelease =
4465
build
4566
runTests
4667
] {
47-
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag) then
48-
!! "src/**/*.*proj" -- "src/bin/*"
49-
|> Seq.iter (
50-
Fake.DotNet.DotNet.pack (fun p ->
68+
projects
69+
|> List.iter (fun pInfo ->
70+
if promptYesNo $"creating prerelease package for {pInfo.Name}{System.Environment.NewLine}\tpackage version: {pInfo.PackagePrereleaseTag}{System.Environment.NewLine}\tassembly version: {pInfo.AssemblyVersion}{System.Environment.NewLine}\tassembly informational version: {pInfo.AssemblyInformationalVersion}{System.Environment.NewLine} OK?" then
71+
pInfo.ProjFile
72+
|> Fake.DotNet.DotNet.pack (fun p ->
5173
let msBuildParams =
52-
{ p.MSBuildParams with
53-
Properties =
54-
([
55-
"Version", prereleaseTag
56-
"PackageReleaseNotes", (release.Notes |> String.toLines)
57-
]
58-
@ p.MSBuildParams.Properties)
59-
}
74+
match pInfo.ReleaseNotes with
75+
| Some r ->
76+
{ p.MSBuildParams with
77+
Properties =
78+
([
79+
"Version",pInfo.PackagePrereleaseTag
80+
"AssemblyVersion", pInfo.AssemblyVersion
81+
"InformationalVersion", pInfo.AssemblyInformationalVersion
82+
"PackageReleaseNotes", (r.Notes |> String.concat "\r\n")
83+
"TargetsForTfmSpecificContentInPackage", "" //https://github.com/dotnet/fsharp/issues/12320
84+
])
85+
}
86+
| _ ->
87+
{ p.MSBuildParams with
88+
Properties =
89+
([
90+
"Version",pInfo.PackagePrereleaseTag
91+
"AssemblyVersion", pInfo.AssemblyVersion
92+
"InformationalVersion", pInfo.AssemblyInformationalVersion
93+
"TargetsForTfmSpecificContentInPackage", "" //https://github.com/dotnet/fsharp/issues/12320
94+
])
95+
}
6096

6197
{ p with
6298
VersionSuffix = Some prereleaseSuffix
6399
OutputPath = Some pkgDir
64100
MSBuildParams = msBuildParams
65-
})
66-
)
67-
else
68-
failwith "aborted"
101+
NoBuild = true
102+
}
103+
|> DotNet.Options.withCustomParams (Some "--no-dependencies")
104+
)
105+
else
106+
failwith "aborted"
107+
)
69108
}

build/ProjectInfo.fs

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,103 @@
22

33
open Fake.Core
44

5-
let project = "Plotly.NET"
5+
/// Contains relevant information about a project (e.g. version info, project location)
6+
type ProjectInfo = {
7+
Name: string
8+
ProjFile: string
9+
ReleaseNotes: ReleaseNotes.ReleaseNotes Option
10+
PackageVersionTag: string
11+
mutable PackagePrereleaseTag: string
12+
AssemblyVersion: string
13+
AssemblyInformationalVersion: string
14+
} with
15+
/// creates a ProjectInfo given a name, project file path, and release notes file path.
16+
/// version info is created from the version header of the uppermost release notes entry.
17+
/// Assembly version is set to X.0.0, where X is the major version from the releas enotes.
18+
static member create(
19+
name: string,
20+
projFile: string,
21+
releaseNotesPath: string
22+
): ProjectInfo =
23+
let release = releaseNotesPath |> ReleaseNotes.load
24+
let stableVersion = release.NugetVersion |> SemVer.parse
25+
let stableVersionTag = $"{stableVersion.Major}.{stableVersion.Minor}.{stableVersion.Patch}"
26+
let assemblyVersion = $"{stableVersion.Major}.0.0"
27+
let assemblyInformationalVersion = stableVersionTag
28+
{
29+
Name = name
30+
ProjFile = projFile
31+
ReleaseNotes = Some release
32+
PackagePrereleaseTag = ""
33+
PackageVersionTag = stableVersionTag
34+
AssemblyVersion = assemblyVersion
35+
AssemblyInformationalVersion = assemblyInformationalVersion
36+
}
37+
static member create(
38+
name: string,
39+
projFile: string
40+
): ProjectInfo =
41+
{
42+
Name = name
43+
ProjFile = projFile
44+
ReleaseNotes = None
45+
PackagePrereleaseTag = ""
46+
PackageVersionTag = ""
47+
AssemblyVersion = ""
48+
AssemblyInformationalVersion = ""
49+
}
650

7-
let testProjects =
8-
[
9-
"tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj"
10-
"tests/Plotly.NET.ImageExport.Tests/Plotly.NET.ImageExport.Tests.fsproj"
11-
"tests/Plotly.NET.Tests.CSharp/Plotly.NET.Tests.CSharp.csproj"
12-
]
51+
let projectName = "Plotly.NET"
1352

14-
let solutionFile = $"{project}.sln"
15-
16-
let configuration = "Release"
53+
let solutionFile = $"{projectName}.sln"
1754

1855
let gitOwner = "plotly"
56+
let gitHome = $"https://github.com/{gitOwner}"
57+
let projectRepo = $"https://github.com/{gitOwner}/{projectName}"
1958

20-
let gitHome =
21-
$"https://github.com/{gitOwner}"
59+
/// packages are generated in this directory.
60+
let pkgDir = "pkg"
2261

23-
let projectRepo =
24-
$"https://github.com/{gitOwner}/{project}"
62+
/// binaries are built using this configuration.
63+
let configuration = "Release"
2564

26-
let pkgDir = "pkg"
65+
let CoreTestProject = ProjectInfo.create("Plotly.NET.Tests", "tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj")
66+
let ImageExportTestProject = ProjectInfo.create("Plotly.NET.ImageExport.Tests", "tests/Plotly.NET.ImageExport.Tests/Plotly.NET.ImageExport.Tests.fsproj")
67+
let CSharpInteroperabilityTestProject = ProjectInfo.create("Plotly.NET.Tests.CSharpInteroperability", "tests/Plotly.NET.Tests.CSharpInteroperability/Plotly.NET.Tests.CSharpInteroperability.csproj")
68+
let CSharpTestProject = ProjectInfo.create("Plotly.NET.CSharp.Tests", "tests/Plotly.NET.CSharp.Tests/Plotly.NET.CSharp.Tests.csproj")
69+
70+
/// contains project info about all test projects
71+
let testProjects =
72+
[
73+
CoreTestProject
74+
ImageExportTestProject
75+
CSharpTestProject
76+
]
77+
78+
let CoreProject = ProjectInfo.create("Plotly.NET", "src/Plotly.NET/Plotly.NET.fsproj", "src/Plotly.NET/RELEASE_NOTES.md")
79+
let InteractiveProject = ProjectInfo.create("Plotly.NET.Interactive", "src/Plotly.NET.Interactive/Plotly.NET.Interactive.fsproj", "src/Plotly.NET.Interactive/RELEASE_NOTES.md")
80+
let ImageExportProject = ProjectInfo.create("Plotly.NET.ImageExport", "src/Plotly.NET.ImageExport/Plotly.NET.ImageExport.fsproj", "src/Plotly.NET.ImageExport/RELEASE_NOTES.md")
81+
let CSharpProject = ProjectInfo.create("Plotly.NET.CSharp", "src/Plotly.NET.CSharp/Plotly.NET.CSharp.csproj", "src/Plotly.NET.CSharp/RELEASE_NOTES.md")
2782

28-
let release =
29-
ReleaseNotes.load "RELEASE_NOTES.md"
83+
/// contains project info about all projects
84+
let projects = [
85+
CoreProject
86+
InteractiveProject
87+
ImageExportProject
88+
CSharpProject
89+
]
3090

31-
let stableVersion =
32-
SemVer.parse release.NugetVersion
91+
/// docs are always targeting the version of the core project
92+
let stableDocsVersionTag = CoreProject.PackageVersionTag
3393

34-
let stableVersionTag =
35-
(sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch)
94+
/// branch tag is always the version of the core project
95+
let branchTag = CoreProject.PackageVersionTag
3696

97+
/// prerelease suffix used by prerelease buildtasks
3798
let mutable prereleaseSuffix = ""
3899

100+
/// prerelease tag used by prerelease buildtasks
39101
let mutable prereleaseTag = ""
40102

103+
/// mutable switch used to signal that we are building a prerelease version, used in prerelease buildtasks
41104
let mutable isPrerelease = false

0 commit comments

Comments
 (0)