Skip to content

Commit

Permalink
Target netstandard 2.0 with lib, update project to .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Jan 4, 2024
1 parent c2cc3bb commit 6560990
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 111 deletions.
23 changes: 19 additions & 4 deletions build/BasicTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ let clean = BuildTask.create "Clean" [] {
|> Shell.cleanDirs
}

let build = BuildTask.create "Build" [clean] {
solutionFile
|> DotNet.build id
}
let buildSolution =
BuildTask.create "BuildSolution" [ clean ] {
solutionFile
|> DotNet.build (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"warnon", "3390"
])
DisableInternalBinLog = true
}
{
p with
MSBuildParams = msBuildParams

}
|> DotNet.Options.withCustomParams (Some "-tl")
)
}
10 changes: 5 additions & 5 deletions build/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ open ReleaseTasks
let _release =
BuildTask.createEmpty
"Release"
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs]
[clean; buildSolution; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs]

/// Full release of nuget package, git tag, and documentation for the prerelease version.
let _preRelease =
BuildTask.createEmpty
"PreRelease"
[setPrereleaseTag; clean; build; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs]
[setPrereleaseTag; clean; buildSolution; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs]

/// Full release of nuget package for the prerelease version.
let _releaseNoDocs =
BuildTask.createEmpty
"ReleaseNoDocs"
[clean; build; runTests; pack; createTag; publishNuget;]
[clean; buildSolution; runTests; pack; createTag; publishNuget;]

/// Full release of nuget package for the prerelease version.
let _preReleaseNoDocs =
BuildTask.createEmpty
"PreReleaseNoDocs"
[setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]
[setPrereleaseTag; clean; buildSolution; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]

ReleaseNotesTasks.updateReleaseNotes |> ignore

[<EntryPoint>]
let main args =
runOrDefault build args
runOrDefault buildSolution args
8 changes: 4 additions & 4 deletions build/DocumentationTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ open BasicTasks

open BlackFox.Fake

let buildDocs = BuildTask.create "BuildDocs" [build] {
let buildDocs = BuildTask.create "BuildDocs" [buildSolution] {
printfn "building docs with stable version %s" stableVersionTag
runDotNet
(sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag)
"./"
}

let buildDocsPrerelease = BuildTask.create "BuildDocsPrerelease" [setPrereleaseTag; build] {
let buildDocsPrerelease = BuildTask.create "BuildDocsPrerelease" [setPrereleaseTag; buildSolution] {
printfn "building docs with prerelease version %s" prereleaseTag
runDotNet
(sprintf "fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag)
"./"
}

let watchDocs = BuildTask.create "WatchDocs" [build] {
let watchDocs = BuildTask.create "WatchDocs" [buildSolution] {
printfn "watching docs with stable version %s" stableVersionTag
runDotNet
(sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" stableVersionTag)
"./"
}

let watchDocsPrerelease = BuildTask.create "WatchDocsPrerelease" [setPrereleaseTag; build] {
let watchDocsPrerelease = BuildTask.create "WatchDocsPrerelease" [setPrereleaseTag; buildSolution] {
printfn "watching docs with prerelease version %s" prereleaseTag
runDotNet
(sprintf "fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s" prereleaseTag)
Expand Down
35 changes: 20 additions & 15 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ open TestTasks

open BlackFox.Fake
open Fake.Core
open Fake.DotNet
open Fake.IO.Globbing.Operators

open System.Text.RegularExpressions
Expand All @@ -17,7 +18,7 @@ let private replaceCommitLink input =
let commitLinkPattern = @"\[\[#[a-z0-9]*\]\(.*\)\] "
Regex.Replace(input,commitLinkPattern,"")

let pack = BuildTask.create "Pack" [clean; build; runTests] {
let pack = BuildTask.create "Pack" [clean; buildSolution; runTests] {
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag )
then
!! "src/**/*.*proj"
Expand All @@ -29,35 +30,39 @@ let pack = BuildTask.create "Pack" [clean; build; runTests] {
"Version",stableVersionTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.concat "\r\n" )
] @ p.MSBuildParams.Properties)
DisableInternalBinLog = true
}
{
p with
MSBuildParams = msBuildParams
OutputPath = Some pkgDir
}
|> DotNet.Options.withCustomParams (Some "-tl")
))
else failwith "aborted"
}

let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; runTests] {
let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; buildSolution; runTests] {
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag )
then
!! "src/**/*.*proj"
-- "src/bin/*"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines )
] @ p.MSBuildParams.Properties)
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
MSBuildParams = msBuildParams
}
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> List.map replaceCommitLink |> String.toLines )
] @ p.MSBuildParams.Properties)
DisableInternalBinLog = true
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
MSBuildParams = msBuildParams
}
|> DotNet.Options.withCustomParams (Some "-tl")
))
else
failwith "aborted"
Expand Down
8 changes: 4 additions & 4 deletions build/ReleaseTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ open Fake.Tools
open Fake.IO
open Fake.IO.Globbing.Operators

let createTag = BuildTask.create "CreateTag" [clean; build; runTests; pack] {
let createTag = BuildTask.create "CreateTag" [clean; buildSolution; runTests; pack] {
if promptYesNo (sprintf "tagging branch with %s OK?" stableVersionTag ) then
Git.Branches.tag "" stableVersionTag
Git.Branches.pushTag "" projectRepo stableVersionTag
else
failwith "aborted"
}

let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build; runTests; packPrerelease] {
let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; buildSolution; runTests; packPrerelease] {
if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag ) then
Git.Branches.tag "" prereleaseTag
Git.Branches.pushTag "" projectRepo prereleaseTag
Expand All @@ -32,7 +32,7 @@ let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseT
}


let publishNuget = BuildTask.create "PublishNuget" [clean; build; runTests; pack] {
let publishNuget = BuildTask.create "PublishNuget" [clean; buildSolution; runTests; pack] {
let targets = (!! (sprintf "%s/*.*pkg" pkgDir ))
for target in targets do printfn "%A" target
let msg = sprintf "release package with version %s?" stableVersionTag
Expand All @@ -45,7 +45,7 @@ let publishNuget = BuildTask.create "PublishNuget" [clean; build; runTests; pack
else failwith "aborted"
}

let publishNugetPrerelease = BuildTask.create "PublishNugetPrerelease" [clean; build; runTests; packPrerelease] {
let publishNugetPrerelease = BuildTask.create "PublishNugetPrerelease" [clean; buildSolution; runTests; packPrerelease] {
let targets = (!! (sprintf "%s/*.*pkg" pkgDir ))
for target in targets do printfn "%A" target
let msg = sprintf "release package with version %s?" prereleaseTag
Expand Down
26 changes: 3 additions & 23 deletions build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Fake.DotNet
open ProjectInfo
open BasicTasks

let runTests = BuildTask.create "RunTests" [clean; build] {
let runTests = BuildTask.create "RunTests" [clean; buildSolution] {
testProjects
|> Seq.iter (fun testProject ->
Fake.DotNet.DotNet.test(fun testParams ->
Expand All @@ -15,29 +15,9 @@ let runTests = BuildTask.create "RunTests" [clean; build] {
Logger = Some "console;verbosity=detailed"
Configuration = DotNet.BuildConfiguration.fromString configuration
NoBuild = true
MSBuildParams = { testParams.MSBuildParams with DisableInternalBinLog = true}
}
) testProject
)
}

// to do: use this once we have actual tests
let runTestsWithCodeCov = BuildTask.create "RunTestsWithCodeCov" [clean; build] {
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
testProjects
|> Seq.iter(fun testProject ->
Fake.DotNet.DotNet.test(fun testParams ->
{
testParams with
MSBuildParams = {
standardParams with
Properties = [
"AltCover","true"
"AltCoverCobertura","../../codeCov.xml"
"AltCoverForce","true"
]
};
Logger = Some "console;verbosity=detailed"
}
|> DotNet.Options.withCustomParams (Some "-tl")
) testProject
)
}
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.100",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/AnyBadge.NET.Tool/AnyBadge.NET.Tool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AnyBadge.NET/AnyBadge.NET.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand Down
4 changes: 2 additions & 2 deletions src/AnyBadge.NET/Badge.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Badge(
| None -> value

// text_color can be passed as a single value or a pair of comma delimited values
let textColors = textColor.Split(",")
let textColors = textColor.Split(',')
let labelTextColor = textColors.[0]
let valueTextColor =
if textColors.Length > 1 then
Expand Down Expand Up @@ -355,7 +355,7 @@ type Badge(
Globals.GITLAB_SCOPED_TEMPLATE
else
// Identify whether template is a file or the actual template text
if this.Template.Split("\n").Length = 1 then
if this.Template.Split('\n').Length = 1 then
try
File.ReadAllText(this.Template)
with _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/AnyBadge.NET/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module Helpers =

for c in text do
for k in char_width_percentages.Keys do
if k.Contains(c) then
if Array.contains c (k.ToCharArray()) then
size <- size + (char_width_percentages[k] * float(fontWidth))

int(size)
Loading

0 comments on commit 6560990

Please sign in to comment.