Skip to content

Commit 2a35ed3

Browse files
committed
Fix dotnet CI
1 parent a93e8a6 commit 2a35ed3

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
dotnet-build:
99
strategy:
1010
matrix:
11+
# Builds for Debug and Release configurations
12+
configuration: [Debug, Release]
13+
# Builds for Ubuntu, Windows, and macOS
1114
os: [ubuntu-latest, windows-latest, macOS-latest]
1215
runs-on: ${{ matrix.os }}
1316

@@ -26,11 +29,13 @@ jobs:
2629
chmod +x ./build.sh
2730
./build.sh
2831
env:
32+
CONFIGURATION: ${{ matrix.configuration }}
2933
CI: true
3034
- name: Build via Windows
3135
if: runner.os == 'Windows'
3236
run: ./build.cmd
3337
env:
38+
CONFIGURATION: ${{ matrix.configuration }}
3439
CI: true
3540

3641
# Fable Npm Build

build/build.fs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ let project = "FsToolkit.ErrorHandling"
1818
let summary =
1919
"FsToolkit.ErrorHandling is a utility library to work with the Result type in F#, and allows you to do clear, simple and powerful error handling."
2020

21-
let configuration = "Release"
21+
let isRelease (targets: Target list) =
22+
targets
23+
|> Seq.map (fun t -> t.Name)
24+
|> Seq.exists ((=) "Release")
25+
26+
let configuration (targets: Target list) =
27+
let defaultVal = if isRelease targets then "Release" else "Debug"
28+
29+
match Environment.environVarOrDefault "CONFIGURATION" defaultVal with
30+
| "Debug" -> DotNet.BuildConfiguration.Debug
31+
| "Release" -> DotNet.BuildConfiguration.Release
32+
| config -> DotNet.BuildConfiguration.Custom config
33+
2234
let solutionFile = "FsToolkit.ErrorHandling.sln"
2335

2436
let rootDir =
@@ -126,11 +138,11 @@ let clean _ =
126138
|> Seq.iter Shell.rm
127139

128140

129-
let build _ =
141+
let build ctx =
130142
let setParams (defaults: DotNet.BuildOptions) = {
131143
defaults with
132144
NoRestore = true
133-
Configuration = DotNet.BuildConfiguration.fromString configuration
145+
Configuration = (configuration ctx.Context.AllExecutingTargets)
134146
}
135147

136148
DotNet.build setParams solutionFile
@@ -156,7 +168,7 @@ let dotnetTest ctx =
156168

157169
{
158170
c with
159-
Configuration = DotNet.BuildConfiguration.Release
171+
Configuration = configuration ctx.Context.AllExecutingTargets
160172
Common =
161173
c.Common
162174
|> DotNet.Options.withAdditionalArgs args
@@ -238,14 +250,14 @@ let release =
238250
</> "RELEASE_NOTES.md"
239251
)
240252

241-
let generateAssemblyInfo _ =
253+
let generateAssemblyInfo ctx =
242254
let getAssemblyInfoAttributes projectName = [
243255
AssemblyInfo.Title(projectName)
244256
AssemblyInfo.Product project
245257
AssemblyInfo.Description summary
246258
AssemblyInfo.Version release.AssemblyVersion
247259
AssemblyInfo.FileVersion release.AssemblyVersion
248-
AssemblyInfo.Configuration configuration
260+
AssemblyInfo.Configuration(string (configuration (ctx.Context.AllExecutingTargets)))
249261
]
250262

251263
let getProjectDetails (projectPath: string) =
@@ -268,14 +280,14 @@ let generateAssemblyInfo _ =
268280

269281
let releaseNotes = String.toLines release.Notes
270282

271-
let dotnetPack _ =
283+
let dotnetPack ctx =
272284
[ solutionFile ]
273285
|> Seq.iter (
274286
DotNet.pack (fun p -> {
275287
p with
276288
// ./bin from the solution root matching the "PublishNuget" target WorkingDir
277289
OutputPath = Some distDir
278-
Configuration = DotNet.BuildConfiguration.Release
290+
Configuration = configuration ctx.Context.AllExecutingTargets
279291
MSBuildParams = {
280292
MSBuild.CliArguments.Create() with
281293
// "/p" (property) arguments to MSBuild.exe
@@ -399,7 +411,8 @@ let initTargets () =
399411
==>! "Build"
400412

401413
"Build"
402-
==>! "DotnetTest"
414+
==> "DotnetTest"
415+
==>! "DotnetPack"
403416
//*** Dotnet Build ***//
404417

405418

0 commit comments

Comments
 (0)