Skip to content

Commit 8cdeeee

Browse files
committed
Switch to KoreBuild
1 parent 1593e14 commit 8cdeeee

File tree

4 files changed

+120
-111
lines changed

4 files changed

+120
-111
lines changed

.gitignore

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
1-
[Oo]bj/
2-
[Bb]in/
3-
TestResults/
4-
.nuget/
5-
.testPublish/
6-
*.sln.ide/
7-
_ReSharper.*/
8-
packages/
9-
artifacts/
10-
.build/
11-
PublishProfiles/
12-
.vs/
13-
bower_components/
14-
node_modules/
15-
**/wwwroot/lib/
16-
debugSettings.json
17-
project.lock.json
18-
*.user
1+
bin
2+
obj
193
*.suo
20-
*.cache
21-
*.docstates
4+
*.user
225
_ReSharper.*
23-
nuget.exe
24-
*net45.csproj
25-
*net451.csproj
26-
*k10.csproj
27-
*.psess
28-
*.vsp
29-
*.pidb
6+
*.DS_Store
307
*.userprefs
31-
*DS_Store
32-
*.ncrunchsolution
33-
*.*sdf
34-
*.ipch
35-
.settings
36-
*.sln.ide
8+
*.pidb
9+
*.vspx
10+
*.psess
11+
packages
12+
target
13+
artifacts
14+
StyleCop.Cache
3715
node_modules
38-
**/[Cc]ompiler/[Rr]esources/**/*.js
16+
*.snk
17+
.nuget/NuGet.exe
18+
project.lock.json
19+
.build

build.cmd

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,2 @@
1-
@ECHO off
2-
SETLOCAL
3-
4-
SET REPO_FOLDER=%~dp0
5-
CD %REPO_FOLDER%
6-
7-
SET BUILD_FOLDER=.build
8-
SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet
9-
SET KOREBUILD_VERSION=
10-
11-
SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe
12-
SET NUGET_VERSION=latest
13-
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
14-
15-
IF NOT EXIST %BUILD_FOLDER% (
16-
md %BUILD_FOLDER%
17-
)
18-
19-
IF NOT EXIST %NUGET_PATH% (
20-
IF NOT EXIST %CACHED_NUGET% (
21-
echo Downloading latest version of NuGet.exe...
22-
IF NOT EXIST %LocalAppData%\NuGet (
23-
md %LocalAppData%\NuGet
24-
)
25-
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
26-
)
27-
28-
copy %CACHED_NUGET% %NUGET_PATH% > nul
29-
)
30-
31-
IF NOT EXIST %KOREBUILD_FOLDER% (
32-
SET KOREBUILD_DOWNLOAD_ARGS=
33-
IF NOT "%KOREBUILD_VERSION%"=="" (
34-
SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION%
35-
)
36-
37-
%BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS%
38-
)
39-
40-
"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %*
1+
@ECHO OFF
2+
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"

build.ps1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
4+
{
5+
while($true)
6+
{
7+
try
8+
{
9+
Invoke-WebRequest $url -OutFile $downloadLocation
10+
break
11+
}
12+
catch
13+
{
14+
$exceptionMessage = $_.Exception.Message
15+
Write-Host "Failed to download '$url': $exceptionMessage"
16+
if ($retries -gt 0) {
17+
$retries--
18+
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
19+
Start-Sleep -Seconds 10
20+
21+
}
22+
else
23+
{
24+
$exception = $_.Exception
25+
throw $exception
26+
}
27+
}
28+
}
29+
}
30+
31+
cd $PSScriptRoot
32+
33+
$repoFolder = $PSScriptRoot
34+
$env:REPO_FOLDER = $repoFolder
35+
36+
$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip"
37+
if ($env:KOREBUILD_ZIP)
38+
{
39+
$koreBuildZip=$env:KOREBUILD_ZIP
40+
}
41+
42+
$buildFolder = ".build"
43+
$buildFile="$buildFolder\KoreBuild.ps1"
44+
45+
if (!(Test-Path $buildFolder)) {
46+
Write-Host "Downloading KoreBuild from $koreBuildZip"
47+
48+
$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
49+
New-Item -Path "$tempFolder" -Type directory | Out-Null
50+
51+
$localZipFile="$tempFolder\korebuild.zip"
52+
53+
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
54+
55+
Add-Type -AssemblyName System.IO.Compression.FileSystem
56+
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
57+
58+
New-Item -Path "$buildFolder" -Type directory | Out-Null
59+
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse
60+
61+
# Cleanup
62+
if (Test-Path $tempFolder) {
63+
Remove-Item -Recurse -Force $tempFolder
64+
}
65+
}
66+
67+
&"$buildFile" $args

build.sh

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
#!/usr/bin/env bash
2+
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
cd $repoFolder
24

3-
SOURCE="${BASH_SOURCE[0]}"
4-
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
5-
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
6-
SOURCE="$(readlink "$SOURCE")"
7-
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
8-
done
9-
repoFolder="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
10-
11-
buildFolder=.build
12-
koreBuildFolder=$buildFolder/KoreBuild-dotnet
13-
14-
nugetPath=$buildFolder/nuget.exe
15-
16-
if test `uname` = Darwin; then
17-
cachedir=~/Library/Caches/KBuild
18-
else
19-
if [ -z $XDG_DATA_HOME ]; then
20-
cachedir=$HOME/.local/share
21-
else
22-
cachedir=$XDG_DATA_HOME;
23-
fi
5+
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip"
6+
if [ ! -z $KOREBUILD_ZIP ]; then
7+
koreBuildZip=$KOREBUILD_ZIP
248
fi
25-
mkdir -p $cachedir
26-
nugetVersion=latest
27-
cacheNuget=$cachedir/nuget.$nugetVersion.exe
289

29-
nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe
10+
buildFolder=".build"
11+
buildFile="$buildFolder/KoreBuild.sh"
3012

3113
if test ! -d $buildFolder; then
14+
echo "Downloading KoreBuild from $koreBuildZip"
15+
16+
tempFolder="/tmp/KoreBuild-$(uuidgen)"
17+
mkdir $tempFolder
18+
19+
localZipFile="$tempFolder/korebuild.zip"
20+
21+
retries=6
22+
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
23+
do
24+
echo "Failed to download '$koreBuildZip'"
25+
if [ "$retries" -le 0 ]; then
26+
exit 1
27+
fi
28+
retries=$((retries - 1))
29+
echo "Waiting 10 seconds before retrying. Retries left: $retries"
30+
sleep 10s
31+
done
32+
33+
unzip -q -d $tempFolder $localZipFile
34+
3235
mkdir $buildFolder
33-
fi
34-
35-
if test ! -f $nugetPath; then
36-
if test ! -f $cacheNuget; then
37-
wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null
36+
cp -r $tempFolder/**/build/** $buildFolder
37+
38+
chmod +x $buildFile
39+
40+
# Cleanup
41+
if test ! -d $tempFolder; then
42+
rm -rf $tempFolder
3843
fi
39-
40-
cp $cacheNuget $nugetPath
41-
fi
42-
43-
if test ! -d $koreBuildFolder; then
44-
mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre
4544
fi
4645

47-
source $koreBuildFolder/build/KoreBuild.sh
46+
$buildFile -r $repoFolder "$@"

0 commit comments

Comments
 (0)