Skip to content

Commit

Permalink
scripts(build): several tiny improvements
Browse files Browse the repository at this point in the history
* If none of the .NET versions were found, a mysterious
InvalidOperationException was being thrown from calling
Fsdk: now we use a newer version that allows to handle
the case gracefully.

* Check if buildTool is dotnet instead of using #if clauses
because we might support soon both at the same time being
handled by make.fsx.

* Don't compare exactly against 'dotnet' but use "StartsWith"
in case we use the whole thing ('dotnet build') in the
buildTool variable soon.
  • Loading branch information
knocte committed Aug 12, 2023
1 parent 75f7f39 commit 8591d4a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scripts/bump.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open System
open System.IO

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
open System.Configuration
Expand Down
14 changes: 12 additions & 2 deletions scripts/configure.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open System
open System.IO

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
open System.Configuration
Expand All @@ -25,7 +25,17 @@ let initialConfigFile, buildTool =
match Process.ConfigCommandCheck ["dotnet"] false true with
| Some _ -> "dotnet"
| None ->
Process.VsWhere "MSBuild\\**\\Bin\\MSBuild.exe"
Console.Write "checking for msbuild... "
match Process.VsWhere "MSBuild\\**\\Bin\\MSBuild.exe" with
| None ->
Console.WriteLine "not found"
Console.Out.Flush()
Console.Error.WriteLine "Error, please install 'dotnet' aka .NET (6.0 or newer), and/or .NETFramework 4.x ('msbuild')"
Environment.Exit 1
failwith "Unreachable"
| Some msbuildPath ->
Console.WriteLine "found"
msbuildPath

Map.empty, buildTool
| platform (* Unix *) ->
Expand Down
2 changes: 1 addition & 1 deletion scripts/find.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open System.IO
open System.Linq

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
#load "fsx/Fsdk/Misc.fs"
Expand Down
13 changes: 6 additions & 7 deletions scripts/make.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open System.Xml.Linq
open System.Xml.XPath

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
open System.Configuration
Expand Down Expand Up @@ -154,18 +154,17 @@ let BuildSolution
let buildTool,buildArg = buildToolAndBuildArg

let configOption =
#if !LEGACY_FRAMEWORK
sprintf "--configuration %s" (binaryConfig.ToString())
#else
sprintf "/p:Configuration=%s" (binaryConfig.ToString())
#endif
if buildTool.StartsWith "dotnet" then
sprintf "--configuration %s" (binaryConfig.ToString())
else
sprintf "/p:Configuration=%s" (binaryConfig.ToString())

let defineConstantsFromBuildConfig =
match buildConfigContents |> Map.tryFind "DefineConstants" with
| Some constants -> constants.Split([|";"|], StringSplitOptions.RemoveEmptyEntries) |> Seq.ofArray
| None -> Seq.empty
let defineConstantsSoFar =
if buildTool <> "dotnet" then
if not (buildTool.StartsWith "dotnet") then
Seq.append ["LEGACY_FRAMEWORK"] defineConstantsFromBuildConfig
else
defineConstantsFromBuildConfig
Expand Down
2 changes: 1 addition & 1 deletion scripts/sanitycheck.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open System.Xml.Linq
open System.Xml.XPath

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
open System.Configuration
Expand Down
2 changes: 1 addition & 1 deletion scripts/snap_release.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open System.Xml.Linq
open System.Xml.XPath

#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk"
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
#else
#r "System.Configuration"
open System.Configuration
Expand Down

0 comments on commit 8591d4a

Please sign in to comment.