Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Update to latest common build files
Browse files Browse the repository at this point in the history
  • Loading branch information
avanderhoorn committed Dec 27, 2016
1 parent e7b3281 commit e489881
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 102 deletions.
42 changes: 2 additions & 40 deletions build.cmd
@@ -1,40 +1,2 @@
@echo off
cd %~dp0

SETLOCAL
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe
SET BUILDCMD_KOREBUILD_VERSION=
SET BUILDCMD_DNX_VERSION=

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\Sake goto getdnx
IF "%BUILDCMD_KOREBUILD_VERSION%"=="" (
.nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
) ELSE (
.nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre
)
.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages

:getdnx
IF "%BUILDCMD_DNX_VERSION%"=="" (
SET BUILDCMD_DNX_VERSION=latest
)
IF "%SKIP_DNX_INSTALL%"=="" (
CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default
CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default
) ELSE (
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
)

packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
67 changes: 67 additions & 0 deletions build.ps1
@@ -0,0 +1,67 @@
$ErrorActionPreference = "Stop"

function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
{
while($true)
{
try
{
Invoke-WebRequest $url -OutFile $downloadLocation
break
}
catch
{
$exceptionMessage = $_.Exception.Message
Write-Host "Failed to download '$url': $exceptionMessage"
if ($retries -gt 0) {
$retries--
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
Start-Sleep -Seconds 10

}
else
{
$exception = $_.Exception
throw $exception
}
}
}
}

cd $PSScriptRoot

$repoFolder = $PSScriptRoot
$env:REPO_FOLDER = $repoFolder

$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if ($env:KOREBUILD_ZIP)
{
$koreBuildZip=$env:KOREBUILD_ZIP
}

$buildFolder = ".build"
$buildFile="$buildFolder\KoreBuild.ps1"

if (!(Test-Path $buildFolder)) {
Write-Host "Downloading KoreBuild from $koreBuildZip"

$tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid()
New-Item -Path "$tempFolder" -Type directory | Out-Null

$localZipFile="$tempFolder\korebuild.zip"

DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6

Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)

New-Item -Path "$buildFolder" -Type directory | Out-Null
copy-item "$tempFolder\**\build\*" $buildFolder -Recurse

# Cleanup
if (Test-Path $tempFolder) {
Remove-Item -Recurse -Force $tempFolder
}
}

&"$buildFile" $args
77 changes: 40 additions & 37 deletions build.sh
@@ -1,43 +1,46 @@
#!/usr/bin/env bash
repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $repoFolder

if test `uname` = Darwin; then
cachedir=~/Library/Caches/KBuild
else
if [ -z $XDG_DATA_HOME ]; then
cachedir=$HOME/.local/share
else
cachedir=$XDG_DATA_HOME;
fi
fi
mkdir -p $cachedir
nugetVersion=latest
cachePath=$cachedir/nuget.$nugetVersion.exe

url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe

if test ! -f $cachePath; then
wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null
fi

if test ! -e .nuget; then
mkdir .nuget
cp $cachePath .nuget/nuget.exe
koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip"
if [ ! -z $KOREBUILD_ZIP ]; then
koreBuildZip=$KOREBUILD_ZIP
fi

if test ! -d packages/Sake; then
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages
fi

if ! type dnvm > /dev/null 2>&1; then
source packages/KoreBuild/build/dnvm.sh
fi

if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
buildFolder=".build"
buildFile="$buildFolder/KoreBuild.sh"

if test ! -d $buildFolder; then
echo "Downloading KoreBuild from $koreBuildZip"

tempFolder="/tmp/KoreBuild-$(uuidgen)"
mkdir $tempFolder

localZipFile="$tempFolder/korebuild.zip"

retries=6
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
do
echo "Failed to download '$koreBuildZip'"
if [ "$retries" -le 0 ]; then
exit 1
fi
retries=$((retries - 1))
echo "Waiting 10 seconds before retrying. Retries left: $retries"
sleep 10s
done

unzip -q -d $tempFolder $localZipFile

mkdir $buildFolder
cp -r $tempFolder/**/build/** $buildFolder

chmod +x $buildFile

# Cleanup
if test -d $tempFolder; then
rm -rf $tempFolder
fi
fi

mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@"
$buildFile -r $repoFolder "$@"
17 changes: 0 additions & 17 deletions devenv.cmd

This file was deleted.

7 changes: 1 addition & 6 deletions makefile.shade
Expand Up @@ -4,9 +4,4 @@ var FULL_VERSION='0.1'
var AUTHORS='Microsoft Open Technologies, Inc.'

use-standard-lifecycle
k-standard-goals

#xml-docs-test .clean .build-compile description='Check generated XML documentation files for errors' target='test'
k-xml-docs-test


k-standard-goals
4 changes: 2 additions & 2 deletions pack.cmd
Expand Up @@ -17,14 +17,14 @@ REM get time
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set DATE=%%c%%a%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set TIME=%%a%%b)

set MILESTONE=beta2-%DATE%%TIME%
set MILESTONE=0-beta2-%DATE%%TIME%

call dotnet pack .\src\Glimpse.Common\Glimpse.Common.csproj --configuration Release --version-suffix %MILESTONE%
call dotnet pack .\src\Glimpse.Server\Glimpse.Server.csproj --configuration Release --version-suffix %MILESTONE%
call dotnet pack .\src\Glimpse.Agent.AspNet\Glimpse.Agent.AspNet.csproj --configuration Release --version-suffix %MILESTONE%
call dotnet pack .\src\Glimpse.Agent.AspNet.Mvc\Glimpse.Agent.AspNet.Mvc.csproj --configuration Release --version-suffix %MILESTONE%

call nuget pack src\Glimpse\Glimpse.nuspec -OutputDirectory dist -version 2.0.0-%MILESTONE%
call nuget pack src\Glimpse\Glimpse.nuspec -OutputDirectory dist -version 2.0.%MILESTONE%

copy /Y src\Glimpse.Common\bin\Release\*.nupkg dist
copy /Y src\Glimpse.Server\bin\Release\*.nupkg dist
Expand Down

0 comments on commit e489881

Please sign in to comment.