@@ -18,7 +18,19 @@ let project = "FsToolkit.ErrorHandling"
1818let 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+
2234let solutionFile = " FsToolkit.ErrorHandling.sln"
2335
2436let 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
269281let 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