Skip to content

Commit

Permalink
Fixed build.cmd and made a best effort for build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
NogginBops committed Jun 18, 2022
1 parent 7aee2b9 commit 0b00bec
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
20 changes: 3 additions & 17 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
@echo off
cls

SET PATH=%LOCALAPPDATA%\Microsoft\dotnet;%PATH%
.paket\paket.bootstrapper.exe
if errorlevel 1 (
exit /b %errorlevel%
)

.paket\paket.exe restore
if errorlevel 1 (
exit /b %errorlevel%
)

IF NOT EXIST build.fsx (
.paket\paket.exe update
packages\FAKE\tools\FAKE.exe init.fsx
)

SET BuildTarget=
if "%BuildRunner%" == "MyGet" (
Expand All @@ -25,6 +12,5 @@ if "%BuildRunner%" == "MyGet" (
echo * git build >> RELEASE_NOTES.md
)

dotnet restore

packages\FAKE\tools\FAKE.exe build.fsx %* %BuildTarget%
dotnet tool restore
dotnet fake run build.fsx %*
45 changes: 36 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
#!/usr/bin/env bash
#!/bin/bash

set -e -o

function version_compare() {
ver1=(${1//./ })
ver2=(${2//./ })

len1=${#ver1[@]}
len2=${#ver2[@]}

vlen=$(($len1 < $len2 ? $len1 : $len2))

for ((i=0;i<vlen;i++))
do
if [ ${ver1[$i]} -gt ${ver2[$i]} ]; then
return 1
fi
done
return 0
}

MINIMAL_DOTNET_VERSION=6.0.200

EXIT_CODE=0

set -eu
set -o pipefail
CURRENT_DOTNET_VERSION=$(dotnet --version 2> /dev/null) || EXIT_CODE=$?

cd `dirname $0`
if (($EXIT_CODE == 0)) && version_compare "$MINIMAL_DOTNET_VERSION" "$CURRENT_DOTNET_VERSION"; then
echo "dotnet command already installed"
else
# Install .NET Core (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script)
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.1.100

PATH="~/.dotnet:$PATH"
fi

FSIARGS=""
OS=${OS:-"unknown"}
Expand All @@ -29,8 +59,5 @@ then
mozroots --import --sync --quiet
fi

run .paket/paket.exe restore

[ ! -e build.fsx ] && run .paket/paket.exe update
[ ! -e build.fsx ] && run packages/FAKE/tools/FAKE.exe init.fsx
run packages/FAKE/tools/FAKE.exe "$@" $FSIARGS build.fsx
dotnet tool restore
dotnet fake run $FSIARGS build.fsx $@

0 comments on commit 0b00bec

Please sign in to comment.