restructure the output layout
also reorganize the scripts folder
This commit is contained in:
parent
df3a5fba7a
commit
4cc15b1246
61 changed files with 926 additions and 3213 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -33,8 +33,11 @@ TestResults/
|
|||
*.pyc
|
||||
*.pyo
|
||||
|
||||
# OSX Packaging temp files
|
||||
*.pkg
|
||||
|
||||
# Profiler result files, just in case they are left lying around :)
|
||||
.vs/
|
||||
|
||||
# CMake generated files
|
||||
cmake/
|
||||
cmake/
|
||||
|
|
34
build.cmd
34
build.cmd
|
@ -1,33 +1 @@
|
|||
@echo off
|
||||
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
for %%a IN (%*) DO (
|
||||
if /I "%%a"=="release" set CONFIGURATION=Release
|
||||
if /I "%%a"=="debug" set CONFIGURATION=Debug
|
||||
)
|
||||
|
||||
if "%CONFIGURATION%" equ "" set CONFIGURATION=Debug
|
||||
|
||||
REM UTC Timestamp of the last commit is used as the build number. This is for easy synchronization of build number between Windows, OSX and Linux builds.
|
||||
REM Using powershell is way easier to retrive and format the timestamp in any way we want.
|
||||
set LAST_COMMIT_TIMESTAMP=powershell -Command "& { $timestamp = git log -1 --format=%%ct ; $origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0; $commitTime = $origin.AddSeconds($timestamp); echo $commitTime.ToString(\"yyyyMMdd-HHmmss\");}"
|
||||
|
||||
for /f %%i in ('%LAST_COMMIT_TIMESTAMP%') do set DOTNET_BUILD_VERSION=0.0.1-alpha-%%i
|
||||
|
||||
where dnvm
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
|
||||
set PATH=!PATH!;!USERPROFILE!\.dnx\bin
|
||||
set DNX_HOME=!USERPROFILE!\.dnx
|
||||
goto continue
|
||||
)
|
||||
|
||||
:continue
|
||||
echo *** Building dotnet - %CONFIGURATION% ***
|
||||
call %~dp0scripts/bootstrap.cmd
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
echo *** Packaging dotnet ***
|
||||
call %~dp0scripts/package.cmd
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
@powershell -NoProfile -NoLogo -File %~dp0scripts\build.ps1 %*
|
||||
|
|
16
build.sh
16
build.sh
|
@ -27,6 +27,8 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/scripts/_common.sh"
|
||||
|
||||
# UTC Timestamp of the last commit is used as the build number. This is for easy synchronization of build number between Windows, OSX and Linux builds.
|
||||
LAST_COMMIT_TIMESTAMP=$(git log -1 --format=%ct)
|
||||
|
||||
|
@ -36,18 +38,18 @@ else
|
|||
export DOTNET_BUILD_VERSION=0.0.1-alpha-$(date -ud @$LAST_COMMIT_TIMESTAMP "+%Y%m%d-%H%M%S")
|
||||
fi
|
||||
|
||||
echo Building dotnet tools verison - $DOTNET_BUILD_VERSION - $CONFIGURATION
|
||||
header "Building dotnet tools version $DOTNET_BUILD_VERSION - $CONFIGURATION"
|
||||
|
||||
if [ ! -z "$BUILD_IN_DOCKER" ]; then
|
||||
export BUILD_COMMAND="/opt/code/scripts/bootstrap.sh"
|
||||
$DIR/scripts/dockerbuild.sh
|
||||
export BUILD_COMMAND="/opt/code/scripts/compile.sh"
|
||||
$DIR/scripts/docker/dockerbuild.sh
|
||||
else
|
||||
$DIR/scripts/bootstrap.sh
|
||||
$DIR/scripts/compile.sh
|
||||
fi
|
||||
|
||||
if [ ! -z "$PACKAGE_IN_DOCKER" ]; then
|
||||
export BUILD_COMMAND="/opt/code/scripts/package.sh"
|
||||
$DIR/scripts/dockerbuild.sh
|
||||
export BUILD_COMMAND="/opt/code/scripts/package/package.sh"
|
||||
$DIR/scripts/docker/dockerbuild.sh
|
||||
else
|
||||
$DIR/scripts/package.sh
|
||||
$DIR/scripts/package/package.sh
|
||||
fi
|
||||
|
|
|
@ -14,15 +14,12 @@ if [ -z "$DOTNET_BUILD_VERSION" ]; then
|
|||
echo "Provide a version number (DOTNET_BUILD_VERSION) $DOTNET_BUILD_VERSION" && exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$RID" ]; then
|
||||
UNAME=$(uname)
|
||||
if [ "$UNAME" == "Darwin" ]; then
|
||||
OSNAME=osx
|
||||
RID=osx.10.10-x64
|
||||
else
|
||||
echo "Package (OSX) only runs on Darwin"
|
||||
exit 0
|
||||
fi
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
OSNAME=osx
|
||||
RID=osx.10.10-x64
|
||||
else
|
||||
echo "Package (OSX) only runs on Darwin"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2
|
||||
|
@ -36,7 +33,7 @@ PACKAGE_DIR=$REPOROOT/artifacts/packages/pkg
|
|||
[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR
|
||||
|
||||
PACKAGE_NAME=$PACKAGE_DIR/dotnet-cli-x64.${DOTNET_BUILD_VERSION}.pkg
|
||||
chmod -R 755 $STAGE2_DIR
|
||||
#chmod -R 755 $STAGE2_DIR
|
||||
pkgbuild --root $STAGE2_DIR \
|
||||
--version $DOTNET_BUILD_VERSION \
|
||||
--scripts $DIR/scripts \
|
||||
|
@ -52,4 +49,4 @@ productbuild --version $DOTNET_BUILD_VERSION --identifier com.microsoft.dotnet.c
|
|||
rm $DIR/dotnet-osx-x64.$DOTNET_BUILD_VERSION.pkg
|
||||
rm $DIR/Dist
|
||||
|
||||
$REPOROOT/scripts/publish.sh $PACKAGE_NAME
|
||||
$REPOROOT/scripts/publish/publish.sh $PACKAGE_NAME
|
||||
|
|
15
scripts/_common.ps1
Normal file
15
scripts/_common.ps1
Normal file
|
@ -0,0 +1,15 @@
|
|||
$Rid = "win7-x64"
|
||||
$Tfm = "dnxcore50"
|
||||
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\.."
|
||||
|
||||
$OutputDir = "$RepoRoot\artifacts\$Rid"
|
||||
$Stage1Dir = "$OutputDir\stage1"
|
||||
$Stage2Dir = "$OutputDir\stage2"
|
||||
$HostDir = "$OutputDir\corehost"
|
||||
$PackageDir = "$RepoRoot\artifacts\packages\dnvm"
|
||||
|
||||
function header([string]$message)
|
||||
{
|
||||
Write-Host -ForegroundColor Green "*** $message ***"
|
||||
}
|
|
@ -27,7 +27,7 @@ cecho()
|
|||
printf "%b\n" "$text"
|
||||
}
|
||||
|
||||
banner()
|
||||
header()
|
||||
{
|
||||
local text=$1
|
||||
cecho "${BGre}*** $text ***${RCol}"
|
||||
|
@ -51,18 +51,34 @@ error()
|
|||
cecho "${Red}error:${RCol} $text" 1>&2
|
||||
}
|
||||
|
||||
UNAME=$(uname)
|
||||
die()
|
||||
{
|
||||
local text=$1
|
||||
error "$text"
|
||||
exit 1
|
||||
}
|
||||
|
||||
export UNAME=$(uname)
|
||||
|
||||
if [ -z "$RID" ]; then
|
||||
if [ "$UNAME" == "Darwin" ]; then
|
||||
OSNAME=osx
|
||||
RID=osx.10.10-x64
|
||||
export OSNAME=osx
|
||||
export RID=osx.10.10-x64
|
||||
elif [ "$UNAME" == "Linux" ]; then
|
||||
# Detect Distro?
|
||||
OSNAME=linux
|
||||
RID=ubuntu.14.04-x64
|
||||
export OSNAME=linux
|
||||
export RID=ubuntu.14.04-x64
|
||||
else
|
||||
error "unknown OS: $UNAME" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
export OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||
export DNX_DIR=$OUTPUT_ROOT/dnx
|
||||
export STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||
export STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||
export HOST_DIR=$OUTPUT_ROOT/corehost
|
||||
|
||||
# TODO: Replace this with a dotnet generation
|
||||
export TFM=dnxcore50
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
REM This trick gets the absolute path from a relative path
|
||||
pushd %~dp0..
|
||||
set REPOROOT=%CD%
|
||||
popd
|
||||
|
||||
set RID=win7-x64
|
||||
set TFM=dnxcore50
|
||||
set DNX_DIR=%REPOROOT%\artifacts\%RID%\dnx
|
||||
set STAGE1_DIR=%REPOROOT%\artifacts\%RID%\stage1
|
||||
set STAGE2_DIR=%REPOROOT%\artifacts\%RID%\stage2
|
||||
set HOST_DIR=%REPOROOT%\artifacts\%RID%\corehost
|
||||
set START_PATH=%PATH%
|
||||
|
||||
if "%CONFIGURATION%" equ "" set CONFIGURATION=Debug
|
||||
|
||||
call %~dp0dnvm2.cmd upgrade -a dotnet_stage0
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
REM Gross! But CMD has no other way to do this :(
|
||||
where dotnet > "%temp%\dotnet-cli-build-temp.tmp"
|
||||
set /P DOTNET_PATH= < "%temp%\dotnet-cli-build-temp.tmp"
|
||||
pushd "%DOTNET_PATH%\.."
|
||||
set STAGE0_DIR=%CD%
|
||||
set DNX_ROOT=%STAGE0_DIR%\dnx
|
||||
popd
|
||||
|
||||
echo Building corehost
|
||||
set CMAKE_OUTPUT=%~dp0..\src\corehost\cmake
|
||||
if not exist "%CMAKE_OUTPUT%" mkdir "%CMAKE_OUTPUT%"
|
||||
pushd "%CMAKE_OUTPUT%"
|
||||
cmake .. -G "Visual Studio 14 2015 Win64"
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="%CONFIGURATION%"
|
||||
|
||||
if exist "%HOST_DIR%" rd /s /q "%HOST_DIR%"
|
||||
mkdir "%HOST_DIR%"
|
||||
copy "%CONFIGURATION%\*" "%HOST_DIR%"
|
||||
|
||||
popd
|
||||
|
||||
if exist "%STAGE1_DIR%" rd /s /q "%STAGE1_DIR%"
|
||||
|
||||
echo Running 'dotnet restore' to restore packages
|
||||
call dotnet restore "%REPOROOT%" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building basic dotnet tools using older dotnet SDK version
|
||||
|
||||
echo Building stage1 dotnet.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-compile.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-compile-csc.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-repl.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Repl"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-repl-csi.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Repl.Csi"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-publish.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 resgen.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage1 dotnet-run.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE1_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Run"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
REM deploy corehost.exe to the output
|
||||
copy "%HOST_DIR%\corehost.exe" "%STAGE1_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
if exist "%HOST_DIR%\corehost.pdb" copy "%HOST_DIR%\corehost.pdb" "%STAGE1_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Re-building dotnet tools with the bootstrapped version
|
||||
REM This should move into a proper build script of some kind once we are bootstrapped
|
||||
set PATH=%STAGE1_DIR%;%START_PATH%
|
||||
|
||||
if exist %STAGE2_DIR% rd /s /q %STAGE2_DIR%
|
||||
|
||||
echo Building stage2 dotnet.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Cli"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-compile.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-compile-csc.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-repl.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Repl"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-repl-csi.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Repl.Csi"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-publish.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Publish"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 resgen.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Resgen"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Building stage2 dotnet-run.exe ...
|
||||
dotnet publish --framework "%TFM%" --runtime "%RID%" --output "%STAGE2_DIR%" --configuration "%CONFIGURATION%" "%REPOROOT%\src\Microsoft.DotNet.Tools.Run"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
REM deploy corehost.exe to the output
|
||||
copy "%HOST_DIR%\corehost.exe" "%STAGE2_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
if exist "%HOST_DIR%\corehost.pdb" copy "%HOST_DIR%\corehost.pdb" "%STAGE2_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
echo Crossgening Roslyn compiler ...
|
||||
call "%~dp0crossgen\crossgen_roslyn.cmd" "%STAGE2_DIR%"
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
REM Copy DNX in to stage2
|
||||
xcopy /s /q "%DNX_ROOT%" "%STAGE2_DIR%\dnx\"
|
||||
|
||||
REM Copy the dotnet-restore script
|
||||
copy "%~dp0dotnet-restore.cmd" "%STAGE2_DIR%\dotnet-restore.cmd"
|
||||
|
||||
REM Smoke-test the output
|
||||
set PATH=%STAGE2_DIR%;%START_PATH%
|
||||
|
||||
del "%REPOROOT%\test\TestApp\project.lock.json"
|
||||
dotnet restore "%REPOROOT%\test\TestApp" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
dotnet compile "%REPOROOT%\test\TestApp" --output "%REPOROOT%\artifacts\%RID%\smoketest"
|
||||
|
||||
set CLRHOST_CLR_PATH=%STAGE2_DIR%
|
||||
"%REPOROOT%\artifacts\%RID%\smoketest\TestApp" 2>nul >nul
|
||||
if errorlevel 1 goto fail
|
||||
|
||||
REM Check that a compiler error is reported
|
||||
dotnet compile "%REPOROOT%\test\compile\failing\SimpleCompilerError" --framework "%TFM%" >nul 2>nul
|
||||
if %errorlevel% == 0 goto fail
|
||||
|
||||
echo Bootstrapped dotnet to %STAGE2_DIR%
|
||||
|
||||
goto end
|
||||
|
||||
:fail
|
||||
echo Bootstrapping failed
|
||||
exit /B 1
|
||||
|
||||
:end
|
||||
exit /B 0
|
|
@ -1,146 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
|
||||
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||
DNX_DIR=$OUTPUT_ROOT/dnx
|
||||
STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||
STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||
HOST_DIR=$OUTPUT_ROOT/corehost
|
||||
|
||||
if ! type -p cmake >/dev/null; then
|
||||
error "cmake is required to build the native host 'corehost'"
|
||||
error "OS X w/Homebrew: 'brew install cmake'"
|
||||
error "Ubuntu: 'sudo apt-get install cmake'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -z "$CONFIGURATION" ] && CONFIGURATION=Debug
|
||||
|
||||
# TODO: Replace this with a dotnet generation
|
||||
TFM=dnxcore50
|
||||
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
START_PATH=$PATH
|
||||
|
||||
banner "Installing stage0"
|
||||
[ -d "$HOME/.dotnet" ] || mkdir -p "$HOME/.dotnet"
|
||||
source $DIR/dnvm2.sh
|
||||
dnvm upgrade -a dotnet_stage0
|
||||
DNX_ROOT="$(dirname $(which dotnet))/dnx"
|
||||
|
||||
banner "Restoring packages"
|
||||
|
||||
dotnet restore "$REPOROOT" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
|
||||
# Clean up stage1
|
||||
[ -d "$STAGE1_DIR" ] && rm -Rf "$STAGE1_DIR"
|
||||
|
||||
banner "Building corehost"
|
||||
|
||||
# Set up the environment to be used for building with clang.
|
||||
if which "clang-3.5" > /dev/null 2>&1
|
||||
then
|
||||
export CC="$(which clang-3.5)"
|
||||
export CXX="$(which clang++-3.5)"
|
||||
elif which "clang-3.6" > /dev/null 2>&1
|
||||
then
|
||||
export CC="$(which clang-3.6)"
|
||||
export CXX="$(which clang++-3.6)"
|
||||
elif which clang > /dev/null 2>&1
|
||||
then
|
||||
export CC="$(which clang)"
|
||||
export CXX="$(which clang++)"
|
||||
else
|
||||
error "Unable to find Clang Compiler"
|
||||
error "Install clang-3.5 or clang3.6"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$REPOROOT/src/corehost" 2>&1 >/dev/null
|
||||
[ -d "cmake/$RID" ] || mkdir -p "cmake/$RID"
|
||||
cd "cmake/$RID"
|
||||
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=$CONFIGURATION
|
||||
make
|
||||
|
||||
# Publish to artifacts
|
||||
[ -d "$HOST_DIR" ] || mkdir -p $HOST_DIR
|
||||
cp "$REPOROOT/src/corehost/cmake/$RID/corehost" $HOST_DIR
|
||||
popd 2>&1 >/dev/null
|
||||
|
||||
banner "Building stage1 using downloaded stage0"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
|
||||
|
||||
# Deploy CLR host to the output
|
||||
cp "$HOST_DIR/corehost" "$STAGE1_DIR"
|
||||
|
||||
# Add stage1 to the path and use it to build stage2
|
||||
export PATH=$STAGE1_DIR:$START_PATH
|
||||
|
||||
# Clean up stage2
|
||||
[ -d "$STAGE2_DIR" ] && rm -Rf "$STAGE2_DIR"
|
||||
|
||||
banner "Building stage2 dotnet using compiled stage1 ..."
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
|
||||
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Run"
|
||||
|
||||
echo "Crossgenning Roslyn compiler ..."
|
||||
$REPOROOT/scripts/crossgen/crossgen_roslyn.sh "$STAGE2_DIR"
|
||||
|
||||
# Deploy CLR host to the output
|
||||
cp "$HOST_DIR/corehost" "$STAGE2_DIR"
|
||||
|
||||
# Make Stage 2 Folder Accessible
|
||||
chmod -R a+r $REPOROOT
|
||||
|
||||
# Copy DNX in to stage2
|
||||
cp -R $DNX_ROOT $STAGE2_DIR/dnx
|
||||
|
||||
# Copy and CHMOD the dotnet-restore script
|
||||
cp $DIR/dotnet-restore.sh $STAGE2_DIR/dotnet-restore
|
||||
chmod a+x $STAGE2_DIR/dotnet-restore
|
||||
|
||||
# Smoke-test the output
|
||||
banner "Testing stage2 ..."
|
||||
export PATH=$STAGE2_DIR:$START_PATH
|
||||
|
||||
rm "$REPOROOT/test/TestApp/project.lock.json"
|
||||
dotnet restore "$REPOROOT/test/TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
|
||||
dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest"
|
||||
|
||||
export CLRHOST_CLR_PATH=$STAGE2_DIR
|
||||
|
||||
# set -e will abort if the exit code of this is non-zero
|
||||
$REPOROOT/artifacts/$RID/smoketest/TestApp
|
||||
|
||||
# Check that a compiler error is reported
|
||||
set +e
|
||||
dotnet compile "$REPOROOT/test/compile/failing/SimpleCompilerError" --framework "$TFM" 2>/dev/null >/dev/null
|
||||
rc=$?
|
||||
if [ $rc == 0 ]; then
|
||||
error "Compiler failure test failed! The compiler did not fail to compile!"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
20
scripts/build.ps1
Normal file
20
scripts/build.ps1
Normal file
|
@ -0,0 +1,20 @@
|
|||
param(
|
||||
[string]$Configuration="Debug")
|
||||
|
||||
$ErrorActionPreference="Stop"
|
||||
|
||||
if (!$env:DOTNET_BUILD_VERSION) {
|
||||
# Get the timestamp of the most recent commit
|
||||
$timestamp = git log -1 --format=%ct
|
||||
$origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0
|
||||
$commitTime = $origin.AddSeconds($timestamp)
|
||||
$LastCommitTimestamp = $commitTime.ToString("yyyyMMdd-HHmmss")
|
||||
|
||||
$env:DOTNET_BUILD_VERSION = "0.0.1-alpha-$LastCommitTimestamp"
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "*** Building dotnet tools version $($env:DOTNET_BUILD_VERSION) - $Configuration ***"
|
||||
& "$PSScriptRoot\compile.ps1" -Configuration:$Configuration
|
||||
|
||||
Write-Host -ForegroundColor Green "*** Packaging dotnet ***"
|
||||
& "$PSScriptRoot\package\package.ps1"
|
66
scripts/build/build-stage.ps1
Normal file
66
scripts/build/build-stage.ps1
Normal file
|
@ -0,0 +1,66 @@
|
|||
param(
|
||||
[Parameter(Mandatory=$true)][string]$Tfm,
|
||||
[Parameter(Mandatory=$true)][string]$Rid,
|
||||
[Parameter(Mandatory=$true)][string]$Configuration,
|
||||
[Parameter(Mandatory=$true)][string]$OutputDir,
|
||||
[Parameter(Mandatory=$true)][string]$RepoRoot,
|
||||
[Parameter(Mandatory=$true)][string]$HostDir)
|
||||
|
||||
$Projects = @(
|
||||
"Microsoft.DotNet.Cli",
|
||||
"Microsoft.DotNet.Tools.Compiler",
|
||||
"Microsoft.DotNet.Tools.Compiler.Csc",
|
||||
"Microsoft.DotNet.Tools.Publish",
|
||||
"Microsoft.DotNet.Tools.Resgen",
|
||||
"Microsoft.DotNet.Tools.Run"
|
||||
)
|
||||
|
||||
$BinariesForCoreHost = @(
|
||||
"csc"
|
||||
"vbc"
|
||||
)
|
||||
|
||||
$FilesToClean = @(
|
||||
"README.md"
|
||||
"Microsoft.DotNet.Runtime.exe"
|
||||
"Microsoft.DotNet.Runtime.dll"
|
||||
"Microsoft.DotNet.Runtime.deps"
|
||||
"Microsoft.DotNet.Runtime.pdb"
|
||||
)
|
||||
|
||||
if (Test-Path $OutputDir) {
|
||||
del -rec -for $OutputDir
|
||||
}
|
||||
|
||||
$RuntimeOutputDir = "$OutputDir\runtime\coreclr"
|
||||
|
||||
# Publish each project
|
||||
$Projects | ForEach-Object {
|
||||
dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$OutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$_"
|
||||
}
|
||||
|
||||
# Publish the runtime
|
||||
dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$RuntimeOutputDir" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime"
|
||||
|
||||
# Clean up bogus additional files
|
||||
$FilesToClean | ForEach-Object {
|
||||
$path = Join-Path $RuntimeOutputDir $_
|
||||
if (Test-Path $path) {
|
||||
del -for $path
|
||||
}
|
||||
}
|
||||
|
||||
# Copy the runtime app-local for the tools
|
||||
cp -rec "$RuntimeOutputDir\*" "$OutputDir\bin"
|
||||
|
||||
# Deploy the CLR host to the output
|
||||
cp "$HostDir\corehost.exe" "$OutputDir\bin"
|
||||
|
||||
# corehostify externally-provided binaries (csc, vbc, etc.)
|
||||
$BinariesForCoreHost | ForEach-Object {
|
||||
mv $OutputDir\bin\$_.exe $OutputDir\bin\$_.dll
|
||||
cp $OutputDir\bin\corehost.exe $OutputDir\bin\$_.exe
|
||||
}
|
||||
|
||||
# remove any deps files that got brought along (they aren't needed because we have an app-local runtime and dependencies)
|
||||
del $OutputDir\bin\*.deps
|
83
scripts/build/build-stage.sh
Executable file
83
scripts/build/build-stage.sh
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/../.." && pwd )"
|
||||
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
[ ! -z "$TFM" ] || die "Missing required environment variable TFM"
|
||||
[ ! -z "$RID" ] || die "Missing required environment variable RID"
|
||||
[ ! -z "$CONFIGURATION" ] || die "Missing required environment variable CONFIGURATION"
|
||||
[ ! -z "$OUTPUT_DIR" ] || die "Missing required environment variable OUTPUT_DIR"
|
||||
[ ! -z "$HOST_DIR" ] || die "Missing required environment variable HOST_DIR"
|
||||
|
||||
PROJECTS=( \
|
||||
Microsoft.DotNet.Cli \
|
||||
Microsoft.DotNet.Tools.Compiler \
|
||||
Microsoft.DotNet.Tools.Compiler.Csc \
|
||||
Microsoft.DotNet.Tools.Publish \
|
||||
Microsoft.DotNet.Tools.Resgen \
|
||||
Microsoft.DotNet.Tools.Run \
|
||||
)
|
||||
|
||||
BINARIES_FOR_COREHOST=( \
|
||||
csc \
|
||||
vbc \
|
||||
)
|
||||
|
||||
FILES_TO_CLEAN=( \
|
||||
README.md \
|
||||
Microsoft.DotNet.Runtime \
|
||||
Microsoft.DotNet.Runtime.dll \
|
||||
Microsoft.DotNet.Runtime.deps \
|
||||
Microsoft.DotNet.Runtime.pdb \
|
||||
)
|
||||
|
||||
# Clean up output
|
||||
[ -d "$OUTPUT_DIR" ] && rm -Rf "$OUTPUT_DIR"
|
||||
|
||||
RUNTIME_OUTPUT_DIR="$OUTPUT_DIR/runtime/coreclr"
|
||||
|
||||
for project in ${PROJECTS[@]}
|
||||
do
|
||||
dotnet publish --framework "$TFM" --runtime "$RID" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
||||
done
|
||||
|
||||
# Bring in the runtime
|
||||
dotnet publish --framework "$TFM" --runtime "$RID" --output "$RUNTIME_OUTPUT_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Runtime"
|
||||
|
||||
# Clean up bogus additional files
|
||||
for file in ${FILES_TO_CLEAN[@]}
|
||||
do
|
||||
[ -e "$RUNTIME_OUTPUT_DIR/$file" ] && rm "$RUNTIME_OUTPUT_DIR/$file"
|
||||
done
|
||||
|
||||
# Copy the runtime app-local for the tools
|
||||
cp -R $RUNTIME_OUTPUT_DIR/* $OUTPUT_DIR/bin
|
||||
|
||||
# Deploy CLR host to the output
|
||||
cp "$HOST_DIR/corehost" "$OUTPUT_DIR/bin"
|
||||
|
||||
# corehostify externally-provided binaries (csc, vbc, etc.)
|
||||
for binary in ${BINARIES_FOR_COREHOST[@]}
|
||||
do
|
||||
cp $OUTPUT_DIR/bin/corehost $OUTPUT_DIR/bin/$binary
|
||||
mv $OUTPUT_DIR/bin/${binary}.exe $OUTPUT_DIR/bin/${binary}.dll
|
||||
done
|
||||
|
||||
# remove any deps files that got brought along (they aren't needed because we have an app-local runtime and dependencies)
|
||||
rm $OUTPUT_DIR/bin/*.deps
|
||||
|
||||
cd $OUTPUT_DIR
|
||||
|
||||
# Fix up permissions. Sometimes they get dropped with the wrong info
|
||||
find . -type f | xargs chmod 644
|
||||
$DIR/fix-mode-flags.sh
|
15
scripts/build/fix-mode-flags.sh
Executable file
15
scripts/build/fix-mode-flags.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Managed code doesn't need 'x'
|
||||
find . -type f -name "*.dll" | xargs chmod 644
|
||||
find . -type f -name "*.exe" | xargs chmod 644
|
||||
|
||||
# Generally, dylibs and sos have 'x' (no idea if it's required ;))
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
find . -type f -name "*.dylib" | xargs chmod 755
|
||||
else
|
||||
find . -type f -name "*.so" | xargs chmod 755
|
||||
fi
|
||||
|
||||
# Executables (those without dots) are executable :)
|
||||
find . -type f ! -name "*.*" | xargs chmod 755
|
|
@ -1,5 +1,6 @@
|
|||
@echo off
|
||||
|
||||
set DOTNET_INSTALL_DIR=%~dp0..\artifacts\win7-x64\stage0
|
||||
CALL %~dp0..\build.cmd %*
|
||||
|
||||
exit /b %errorlevel%
|
||||
|
|
|
@ -11,6 +11,11 @@ SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|||
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
# Tell install scripts to skip pre-req check since the CI has the pre-reqs but not ldconfig it seems
|
||||
# Also, install to a directory under the repo root since we don't have permission to work elsewhere
|
||||
export DOTNET_INSTALL_SKIP_PREREQS=1
|
||||
export DOTNET_INSTALL_DIR=$SCRIPT_DIR/../artifacts/$RID/stage0
|
||||
|
||||
# Some things depend on HOME and it may not be set. We should fix those things, but until then, we just patch a value in
|
||||
if [ -z "$HOME" ]; then
|
||||
export HOME=$SCRIPT_DIR/../artifacts/home
|
||||
|
@ -34,7 +39,7 @@ if [[ "$(uname)" == "Linux" ]]; then
|
|||
|
||||
export DOTNET_BUILD_CONTAINER_NAME="$container_name"
|
||||
export PACKAGE_IN_DOCKER="true"
|
||||
|
||||
|
||||
$SCRIPT_DIR/../build.sh $@
|
||||
else
|
||||
$SCRIPT_DIR/../build.sh $@
|
||||
|
|
|
@ -12,7 +12,7 @@ if [[ "$(uname)" == "Linux" ]]; then
|
|||
|
||||
export DOTNET_BUILD_CONTAINER_NAME="$container_name"
|
||||
|
||||
$SCRIPT_DIR/dockerpostbuild.sh $@
|
||||
$SCRIPT_DIR/docker/dockerpostbuild.sh $@
|
||||
fi
|
||||
|
||||
ret_code=$?
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
@echo off
|
||||
|
||||
REM Generate project files for the coreclr host
|
||||
set CMAKE_OUTPUT=%~dp0..\src\corehost\cmake
|
||||
if not exist %CMAKE_OUTPUT% mkdir %CMAKE_OUTPUT%
|
||||
pushd %CMAKE_OUTPUT%
|
||||
cmake .. -G "Visual Studio 14 2015 Win64"
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
popd
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
|
||||
# Generate make files for the coreclr host
|
||||
CMAKE_OUTPUT=$DIR/../src/corehost/cmake/$RID
|
||||
if [ ! -d $CMAKE_OUTPUT ]; then
|
||||
mkdir -p $CMAKE_OUTPUT
|
||||
fi
|
||||
pushd $CMAKE_OUTPUT
|
||||
cmake ../.. -G "Unix Makefiles"
|
||||
popd
|
89
scripts/compile.ps1
Normal file
89
scripts/compile.ps1
Normal file
|
@ -0,0 +1,89 @@
|
|||
param([string]$Configuration = "Debug")
|
||||
|
||||
$ErrorActionPreference="Stop"
|
||||
|
||||
. $PSScriptRoot\_common.ps1
|
||||
|
||||
# Capture PATH for later
|
||||
$StartPath = $env:PATH
|
||||
$StartDotNetHome = $env:DOTNET_HOME
|
||||
|
||||
try {
|
||||
|
||||
# Check prereqs
|
||||
if (!(Get-Command -ErrorAction SilentlyContinue cmake)) {
|
||||
throw @"
|
||||
cmake is required to build the native host 'corehost'"
|
||||
Download it from https://www.cmake.org
|
||||
"@
|
||||
}
|
||||
|
||||
# Install a stage 0
|
||||
header "Installing dotnet stage 0"
|
||||
& "$PSScriptRoot\install.ps1"
|
||||
|
||||
# Put stage 0 on the path
|
||||
$DotNetTools = "$($env:LOCALAPPDATA)\Microsoft\dotnet\cli"
|
||||
if (Test-Path "$DotNetTools\dotnet.exe") {
|
||||
Write-Warning "Your stage0 is using the old layout"
|
||||
$DnxDir = "$DotNetTools\dnx"
|
||||
$env:PATH = "$DotNetTools;$StartPath"
|
||||
} elseif (Test-Path "$DotNetTools\bin\dotnet.exe") {
|
||||
$DnxDir = "$DotNetTools\bin\dnx"
|
||||
$env:PATH = "$DotNetTools\bin;$StartPath"
|
||||
}
|
||||
|
||||
# Restore packages
|
||||
header "Restoring packages"
|
||||
dotnet restore "$RepoRoot" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
|
||||
header "Building corehost"
|
||||
pushd "$RepoRoot\src\corehost"
|
||||
try {
|
||||
if (!(Test-Path "cmake\$Rid")) {
|
||||
mkdir "cmake\$Rid" | Out-Null
|
||||
}
|
||||
cd "cmake\$Rid"
|
||||
cmake ..\.. -G "Visual Studio 14 2015 Win64"
|
||||
$pf = $env:ProgramFiles
|
||||
if (Test-Path "env:\ProgramFiles(x86)") {
|
||||
$pf = (cat "env:\ProgramFiles(x86)")
|
||||
}
|
||||
& "$pf\MSBuild\14.0\Bin\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration="$Configuration"
|
||||
|
||||
if (!(Test-Path $HostDir)) {
|
||||
mkdir $HostDir | Out-Null
|
||||
}
|
||||
cp "$RepoRoot\src\corehost\cmake\$Rid\$Configuration\corehost.exe" $HostDir
|
||||
cp "$RepoRoot\src\corehost\cmake\$Rid\$Configuration\corehost.pdb" $HostDir
|
||||
} finally {
|
||||
popd
|
||||
}
|
||||
|
||||
# Build Stage 1
|
||||
header "Building stage1 dotnet using downloaded stage0 ..."
|
||||
& "$PSScriptRoot\build\build-stage.ps1" -Tfm:$Tfm -Rid:$Rid -Configuration:$Configuration -OutputDir:$Stage1Dir -RepoRoot:$RepoRoot -HostDir:$HostDir
|
||||
|
||||
# Build Stage 2 using Stage 1
|
||||
$env:PATH = "$Stage1Dir\bin;$StartPath"
|
||||
header "Building stage2 dotnet using just-built stage1 ..."
|
||||
& "$PSScriptRoot\build\build-stage.ps1" -Tfm:$Tfm -Rid:$Rid -Configuration:$Configuration -OutputDir:$Stage2Dir -RepoRoot:$RepoRoot -HostDir:$HostDir
|
||||
|
||||
# Crossgen Roslyn
|
||||
header "Crossgening Roslyn compiler ..."
|
||||
cmd /c "$PSScriptRoot\crossgen\crossgen_roslyn.cmd" "$Stage2Dir"
|
||||
|
||||
# Copy dnx into stage 2
|
||||
cp -rec "$DnxDir\*" "$Stage2Dir\bin\dnx\"
|
||||
|
||||
# Copy in the dotnet-restore script
|
||||
cp "$PSScriptRoot\dotnet-restore.cmd" "$Stage2Dir\bin\dotnet-restore.cmd"
|
||||
|
||||
# Smoke test stage2
|
||||
$env:PATH = "$Stage2Dir\bin;$StartPath"
|
||||
$env:DOTNET_HOME = "$Stage2Dir"
|
||||
& "$PSScriptRoot\test\smoke-test.ps1"
|
||||
} finally {
|
||||
$env:PATH = $StartPath
|
||||
$env:DOTNET_HOME = $StartDotNetHome
|
||||
}
|
111
scripts/compile.sh
Executable file
111
scripts/compile.sh
Executable file
|
@ -0,0 +1,111 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
|
||||
if ! type -p cmake >/dev/null; then
|
||||
error "cmake is required to build the native host 'corehost'"
|
||||
error "OS X w/Homebrew: 'brew install cmake'"
|
||||
error "Ubuntu: 'sudo apt-get install cmake'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -z "$CONFIGURATION" ] && export CONFIGURATION=Debug
|
||||
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
# Ensure the latest stage0 is installed
|
||||
$DIR/install.sh
|
||||
|
||||
# And put the stage0 on the PATH
|
||||
export PATH=$REPOROOT/artifacts/$RID/stage0/bin:$PATH
|
||||
|
||||
# Intentionally clear the DOTNET_TOOLS path, we want to use the default installed version
|
||||
unset DOTNET_TOOLS
|
||||
|
||||
DOTNET_PATH=$(which dotnet)
|
||||
PREFIX="$(cd -P "$(dirname "$DOTNET_PATH")/.." && pwd)"
|
||||
DNX_ROOT="$PREFIX/share/dotnet/cli/bin/dnx"
|
||||
if [ ! -d "$DNX_ROOT" ]; then
|
||||
echo "warning: your stage0 is using the old layout" 1>&2
|
||||
DNX_ROOT="$PREFIX/share/dotnet/cli/dnx"
|
||||
fi
|
||||
|
||||
if [ ! -d "$DNX_ROOT" ] || [ ! -e "$DNX_ROOT/dnx" ]; then
|
||||
echo "error: could not find DNX in $DNX_ROOT" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
header "Restoring packages"
|
||||
dotnet restore "$REPOROOT" --quiet --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
|
||||
header "Building corehost"
|
||||
|
||||
# Set up the environment to be used for building with clang.
|
||||
if which "clang-3.5" > /dev/null 2>&1; then
|
||||
export CC="$(which clang-3.5)"
|
||||
export CXX="$(which clang++-3.5)"
|
||||
elif which "clang-3.6" > /dev/null 2>&1; then
|
||||
export CC="$(which clang-3.6)"
|
||||
export CXX="$(which clang++-3.6)"
|
||||
elif which clang > /dev/null 2>&1; then
|
||||
export CC="$(which clang)"
|
||||
export CXX="$(which clang++)"
|
||||
else
|
||||
error "Unable to find Clang Compiler"
|
||||
error "Install clang-3.5 or clang3.6"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$REPOROOT/src/corehost" 2>&1 >/dev/null
|
||||
[ -d "cmake/$RID" ] || mkdir -p "cmake/$RID"
|
||||
cd "cmake/$RID"
|
||||
cmake ../.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=$CONFIGURATION
|
||||
make
|
||||
|
||||
# Publish to artifacts
|
||||
[ -d "$HOST_DIR" ] || mkdir -p $HOST_DIR
|
||||
cp "$REPOROOT/src/corehost/cmake/$RID/corehost" $HOST_DIR
|
||||
popd 2>&1 >/dev/null
|
||||
|
||||
# Build Stage 1
|
||||
header "Building stage1 dotnet using downloaded stage0 ..."
|
||||
OUTPUT_DIR=$STAGE1_DIR $DIR/build/build-stage.sh
|
||||
|
||||
# Use stage1 tools
|
||||
export DOTNET_TOOLS=$STAGE1_DIR
|
||||
|
||||
# Build Stage 2
|
||||
header "Building stage2 dotnet using just-built stage1 ..."
|
||||
OUTPUT_DIR=$STAGE2_DIR $DIR/build/build-stage.sh
|
||||
|
||||
echo "Crossgenning Roslyn compiler ..."
|
||||
$REPOROOT/scripts/crossgen/crossgen_roslyn.sh "$STAGE2_DIR/bin"
|
||||
|
||||
# Make Stage 2 Folder Accessible
|
||||
chmod -R a+r $REPOROOT
|
||||
|
||||
# Copy DNX in to stage2
|
||||
cp -R $DNX_ROOT $STAGE2_DIR/bin/dnx
|
||||
|
||||
# Copy and CHMOD the dotnet-restore script
|
||||
cp $DIR/dotnet-restore.sh $STAGE2_DIR/bin/dotnet-restore
|
||||
chmod a+x $STAGE2_DIR/bin/dotnet-restore
|
||||
|
||||
# Stamp the output with the commit metadata
|
||||
COMMIT_ID=$(git rev-parse HEAD)
|
||||
echo $COMMIT_ID > $STAGE2_DIR/.commit
|
||||
|
||||
# Smoke-test the output
|
||||
header "Testing stage2 ..."
|
||||
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/smoke-test.sh
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
REM Get absolute path
|
||||
pushd %1
|
||||
set BIN_DIR=%CD%
|
||||
set BIN_DIR=%CD%\bin
|
||||
popd
|
||||
|
||||
REM Replace with a robust method for finding the right crossgen.exe
|
||||
|
|
|
@ -20,25 +20,26 @@ fi
|
|||
# Replace with a robust method for finding the right crossgen.exe
|
||||
CROSSGEN_UTIL=~/.dnx/packages/runtime.$RID.Microsoft.NETCore.Runtime.CoreCLR/1.0.1-beta-23504/tools/crossgen
|
||||
|
||||
pushd $BIN_DIR
|
||||
cd $BIN_DIR
|
||||
|
||||
# Crossgen currently requires itself to be next to mscorlib
|
||||
cp $CROSSGEN_UTIL $BIN_DIR
|
||||
chmod +x crossgen
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR mscorlib.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR mscorlib.dll
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR System.Collections.Immutable.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR System.Collections.Immutable.dll
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR System.Reflection.Metadata.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR System.Reflection.Metadata.dll
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.dll
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.CSharp.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.CSharp.dll
|
||||
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.VisualBasic.dll
|
||||
./crossgen -nologo -platform_assemblies_paths $BIN_DIR Microsoft.CodeAnalysis.VisualBasic.dll
|
||||
|
||||
./crossgen -MissingDependenciesOK -nologo -platform_assemblies_paths $BIN_DIR csc.exe
|
||||
|
||||
./crossgen -MissingDependenciesOK -nologo -platform_assemblies_paths $BIN_DIR vbc.exe
|
||||
./crossgen -MissingDependenciesOK -nologo -platform_assemblies_paths $BIN_DIR csc.dll
|
||||
[ -e csc.ni.exe ] && [ ! -e csc.ni.dll ] && mv csc.ni.exe csc.ni.dll
|
||||
|
||||
./crossgen -MissingDependenciesOK -nologo -platform_assemblies_paths $BIN_DIR vbc.dll
|
||||
[ -e vbc.ni.exe ] && [ ! -e vbc.ni.dll ] && mv vbc.ni.exe vbc.ni.dll
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
@echo off
|
||||
|
||||
REM This trick gets the absolute path from a relative path
|
||||
pushd %~dp0..
|
||||
set REPOROOT=%CD%
|
||||
popd
|
||||
|
||||
set RID=win7-x64
|
||||
set STAGE2_DIR=%REPOROOT%\artifacts\%RID%\stage2
|
||||
set DESTINATION=%USERPROFILE%\.dotnet\sdks\dotnet-win-x64.0.0.1-dev
|
||||
|
||||
echo Junctioning %STAGE2_DIR% to %DESTINATION%
|
||||
|
||||
if not exist %DESTINATION% goto link
|
||||
echo Removing old junction %DESTINATION%
|
||||
rd /s /q %DESTINATION%
|
||||
|
||||
:link
|
||||
mklink /J %DESTINATION% %STAGE2_DIR%
|
|
@ -1,10 +0,0 @@
|
|||
@Echo off
|
||||
|
||||
set DNVM_CMD_PATH_FILE="%DOTNET_HOME%\.dotnet\temp-set-envvars.cmd"
|
||||
|
||||
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm2.ps1' %*"
|
||||
|
||||
IF EXIST %DNVM_CMD_PATH_FILE% (
|
||||
CALL %DNVM_CMD_PATH_FILE%
|
||||
DEL %DNVM_CMD_PATH_FILE%
|
||||
)
|
1659
scripts/dnvm2.ps1
1659
scripts/dnvm2.ps1
File diff suppressed because it is too large
Load diff
873
scripts/dnvm2.sh
873
scripts/dnvm2.sh
|
@ -1,873 +0,0 @@
|
|||
# dnvm.sh
|
||||
# Source this file from your .bash-profile or script to use
|
||||
|
||||
# "Constants"
|
||||
_DNVM_BUILDNUMBER="{{BUILD_VERSION}}"
|
||||
_DNVM_AUTHORS="{{AUTHORS}}"
|
||||
_DNVM_RUNTIME_PACKAGE_NAME="dotnet"
|
||||
_DNVM_RUNTIME_FRIENDLY_NAME=".NET CLI"
|
||||
_DNVM_RUNTIME_SHORT_NAME="dotnet"
|
||||
_DNVM_RUNTIME_FOLDER_NAME=".dotnet"
|
||||
_DNVM_COMMAND_NAME="dnvm"
|
||||
_DNVM_PACKAGE_MANAGER_NAME="dnu"
|
||||
_DNVM_VERSION_MANAGER_NAME=".NET Version Manager"
|
||||
_DNVM_DEFAULT_FEED="https://dotnetcli.blob.core.windows.net/dotnet"
|
||||
_DNVM_DEFAULT_CHANNEL="dev"
|
||||
_DNVM_DEFAULT_UNSTABLE_CHANNEL="dev"
|
||||
_DNVM_UPDATE_LOCATION="https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh"
|
||||
_DNVM_INSTALL_SUBFOLDER="sdks"
|
||||
|
||||
if [ "$NO_COLOR" != "1" ]; then
|
||||
# ANSI Colors
|
||||
RCol='\e[0m' # Text Reset
|
||||
|
||||
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
|
||||
Bla='\e[0;30m'; BBla='\e[1;30m'; UBla='\e[4;30m'; IBla='\e[0;90m'; BIBla='\e[1;90m'; On_Bla='\e[40m'; On_IBla='\e[0;100m';
|
||||
Red='\e[0;31m'; BRed='\e[1;31m'; URed='\e[4;31m'; IRed='\e[0;91m'; BIRed='\e[1;91m'; On_Red='\e[41m'; On_IRed='\e[0;101m';
|
||||
Gre='\e[0;32m'; BGre='\e[1;32m'; UGre='\e[4;32m'; IGre='\e[0;92m'; BIGre='\e[1;92m'; On_Gre='\e[42m'; On_IGre='\e[0;102m';
|
||||
Yel='\e[0;33m'; BYel='\e[1;33m'; UYel='\e[4;33m'; IYel='\e[0;93m'; BIYel='\e[1;93m'; On_Yel='\e[43m'; On_IYel='\e[0;103m';
|
||||
Blu='\e[0;34m'; BBlu='\e[1;34m'; UBlu='\e[4;34m'; IBlu='\e[0;94m'; BIBlu='\e[1;94m'; On_Blu='\e[44m'; On_IBlu='\e[0;104m';
|
||||
Pur='\e[0;35m'; BPur='\e[1;35m'; UPur='\e[4;35m'; IPur='\e[0;95m'; BIPur='\e[1;95m'; On_Pur='\e[45m'; On_IPur='\e[0;105m';
|
||||
Cya='\e[0;36m'; BCya='\e[1;36m'; UCya='\e[4;36m'; ICya='\e[0;96m'; BICya='\e[1;96m'; On_Cya='\e[46m'; On_ICya='\e[0;106m';
|
||||
Whi='\e[0;37m'; BWhi='\e[1;37m'; UWhi='\e[4;37m'; IWhi='\e[0;97m'; BIWhi='\e[1;97m'; On_Whi='\e[47m'; On_IWhi='\e[0;107m';
|
||||
fi
|
||||
|
||||
|
||||
[[ "$_DNVM_BUILDNUMBER" = {{* ]] && _DNVM_BUILDNUMBER="HEAD"
|
||||
|
||||
__dnvm_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
if __dnvm_has "unsetopt"; then
|
||||
unsetopt nomatch 2>/dev/null
|
||||
fi
|
||||
|
||||
if [ -z "$DOTNET_USER_HOME" ]; then
|
||||
eval DOTNET_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME"
|
||||
fi
|
||||
|
||||
if [ -z "$DOTNET_GLOBAL_HOME" ]; then
|
||||
eval DOTNET_GLOBAL_HOME="/usr/local/lib/dotnet"
|
||||
fi
|
||||
|
||||
if [ -z "$DOTNET_HOME" ]; then
|
||||
# Set to the user home value
|
||||
eval DOTNET_HOME="$DOTNET_USER_HOME:$DOTNET_GLOBAL_HOME"
|
||||
elif [[ $DOTNET_HOME != *"$DOTNET_GLOBAL_HOME"* ]]; then
|
||||
eval DOTNET_HOME="$DOTNET_HOME:$DOTNET_GLOBAL_HOME"
|
||||
fi
|
||||
|
||||
_DNVM_USER_PACKAGES="$DOTNET_USER_HOME/$_DNVM_INSTALL_SUBFOLDER"
|
||||
_DNVM_GLOBAL_PACKAGES="$DOTNET_GLOBAL_HOME/$_DNVM_INSTALL_SUBFOLDER"
|
||||
_DNVM_ALIAS_DIR="$DOTNET_USER_HOME/alias"
|
||||
_DNVM_DNVM_DIR="$DOTNET_USER_HOME/dnvm"
|
||||
|
||||
DNX_ACTIVE_FEED=""
|
||||
DNX_ACTIVE_CHANNEL=""
|
||||
|
||||
__dnvm_current_os()
|
||||
{
|
||||
local uname=$(uname)
|
||||
if [[ $uname == "Darwin" ]]; then
|
||||
echo "osx"
|
||||
else
|
||||
echo "linux"
|
||||
fi
|
||||
}
|
||||
|
||||
__dnvm_find_latest() {
|
||||
local arch=$1
|
||||
local os=$2
|
||||
|
||||
if ! __dnvm_has "curl"; then
|
||||
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
|
||||
return 1
|
||||
fi
|
||||
|
||||
#dnx-coreclr-linux-x64
|
||||
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$os-$arch"
|
||||
|
||||
local url="$DNX_ACTIVE_FEED/$DNX_ACTIVE_CHANNEL/dnvm/latest.$os.index"
|
||||
local index="$(curl $url 2>/dev/null)"
|
||||
|
||||
local version="$(export IFS=; echo $index | sed -n "s/^.*$packageId\.\(.*\)\.tar\.gz$/\1/p")"
|
||||
|
||||
local downloadUrl="$DNX_ACTIVE_FEED/$DNX_ACTIVE_CHANNEL/$index"
|
||||
|
||||
echo $version $downloadUrl
|
||||
}
|
||||
|
||||
__dnvm_find_package() {
|
||||
local arch=$1
|
||||
local os=$2
|
||||
local version=$3
|
||||
|
||||
#dnx-coreclr-linux-x64
|
||||
local packageId="$_DNVM_RUNTIME_PACKAGE_NAME-$os-$arch"
|
||||
|
||||
local url="$DNX_ACTIVE_FEED/$DNX_ACTIVE_CHANNEL/dnvm/index"
|
||||
local index="$(curl $url 2>/dev/null)"
|
||||
|
||||
local filename="$(export IFS=; echo $index | sed -n "s/Filename: \(.*$packageId.$version\)/\1/p")"
|
||||
local packageUrl="$DNX_ACTIVE_FEED/$DNX_ACTIVE_CHANNEL/$filename"
|
||||
echo $packageUrl
|
||||
}
|
||||
|
||||
__dnvm_strip_path() {
|
||||
echo "$1" | sed -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" | sed -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g"
|
||||
}
|
||||
|
||||
__dnvm_prepend_path() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "$2"
|
||||
else
|
||||
echo "$2:$1"
|
||||
fi
|
||||
}
|
||||
|
||||
__dnvm_package_version() {
|
||||
local runtimeFullName="$1"
|
||||
echo "$runtimeFullName" | sed "s/[^.]*.\(.*\)/\1/"
|
||||
}
|
||||
|
||||
__dnvm_package_name() {
|
||||
local runtimeFullName="$1"
|
||||
echo "$runtimeFullName" | sed "s/\([^.]*\).*/\1/"
|
||||
}
|
||||
|
||||
__dnvm_package_arch() {
|
||||
local runtimeFullName="$1"
|
||||
echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-[^-.]*-\([^-.]*\)\..*/\1/"
|
||||
}
|
||||
|
||||
__dnvm_package_os() {
|
||||
local runtimeFullName="$1"
|
||||
echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-\([^.-]*\).*/\1/"
|
||||
}
|
||||
|
||||
__dnvm_update_self() {
|
||||
local dnvmFileLocation="$_DNVM_DNVM_DIR/dnvm.sh"
|
||||
if [ ! -e $dnvmFileLocation ]; then
|
||||
local formattedDnvmFileLocation=`(echo $dnvmFileLocation | sed s=$HOME=~=g)`
|
||||
local formattedDnvmHome=`(echo $_DNVM_DNVM_DIR | sed s=$HOME=~=g)`
|
||||
local bashSourceLocation=${BASH_SOURCE}
|
||||
local scriptLocation=$bashSourceLocation
|
||||
if [ -z "${bashSourceLocation}" ]; then
|
||||
local scriptLocation=${(%):-%x}
|
||||
fi
|
||||
printf "%b\n" "${Red}$formattedDnvmFileLocation doesn't exist. This command assumes you have installed dnvm in the usual location and are trying to update it. If you want to use update-self then dnvm.sh should be sourced from $formattedDnvmHome. dnvm is currently sourced from $scriptLocation ${RCol}"
|
||||
return 1
|
||||
fi
|
||||
printf "%b\n" "${Cya}Downloading dnvm.sh from $_DNVM_UPDATE_LOCATION ${RCol}"
|
||||
local httpResult=$(curl -L -D - "$_DNVM_UPDATE_LOCATION" -o "$dnvmFileLocation" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||
|
||||
[[ $httpResult == "404" ]] &&printf "%b\n" "${Red}404. Unable to download DNVM from $_DNVM_UPDATE_LOCATION ${RCol}" && return 1
|
||||
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching DNVM from $_DNVM_UPDATE_LOCATION ${RCol}" && return 1
|
||||
|
||||
source "$dnvmFileLocation"
|
||||
}
|
||||
|
||||
__dnvm_promptSudo() {
|
||||
local acceptSudo="$1"
|
||||
|
||||
local answer=
|
||||
if [ "$acceptSudo" == "0" ]; then
|
||||
echo "In order to install dnx globally, dnvm will have to temporarily run as root."
|
||||
read -p "You may be prompted for your password via 'sudo' during this process. Is this Ok? (y/N) " answer
|
||||
else
|
||||
answer="y"
|
||||
fi
|
||||
if echo $answer | grep -iq "^y" ; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
__dnvm_download() {
|
||||
local runtimeFullName="$1"
|
||||
local downloadUrl="$2"
|
||||
local runtimeFolder="$3"
|
||||
local acceptSudo="$4"
|
||||
|
||||
#todo: This will need to change to be whatever the filename in the index is.
|
||||
local runtimeFile="$runtimeFolder/$runtimeFullName.tar.gz"
|
||||
|
||||
if [ -e "$runtimeFolder" ]; then
|
||||
printf "%b\n" "${Gre}$runtimeFullName already installed. ${RCol}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! __dnvm_has "curl"; then
|
||||
printf "%b\n" "${Red}$_DNVM_COMMAND_NAME needs curl to proceed. ${RCol}" >&2;
|
||||
return 1
|
||||
fi
|
||||
|
||||
local useSudo=
|
||||
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
||||
if [ ! -d $runtimeFolder ]; then
|
||||
if ! __dnvm_promptSudo $acceptSudo ; then
|
||||
useSudo=sudo
|
||||
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
echo "Downloading $runtimeFullName from $DNX_ACTIVE_FEED"
|
||||
echo "Download: $downloadUrl to $runtimeFile"
|
||||
|
||||
local httpResult=$($useSudo curl -L -D - "$downloadUrl" -o "$runtimeFile" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||
|
||||
if [[ $httpResult == "404" ]]; then
|
||||
printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}"
|
||||
printf "%b\n" "${Cya}This is most likely caused by the feed not having the version that you typed. Check that you typed the right version and try again. Other possible causes are the feed doesn't have a $_DNVM_RUNTIME_SHORT_NAME of the right name format or some other error caused a 404 on the server.${RCol}"
|
||||
return 1
|
||||
fi
|
||||
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1
|
||||
|
||||
__dnvm_unpack $runtimeFile $runtimeFolder $useSudo
|
||||
return $?
|
||||
}
|
||||
|
||||
__dnvm_unpack() {
|
||||
local runtimeFile="$1"
|
||||
local runtimeFolder="$2"
|
||||
local useSudo=$3
|
||||
|
||||
echo "Installing to $runtimeFolder"
|
||||
|
||||
if ! __dnvm_has "unzip"; then
|
||||
echo "$_DNVM_COMMAND_NAME needs unzip to proceed." >&2;
|
||||
return 1
|
||||
fi
|
||||
|
||||
$useSudo tar -xzf $runtimeFile -C $runtimeFolder > /dev/null 2>&1
|
||||
}
|
||||
|
||||
__dnvm_requested_version_or_alias() {
|
||||
local versionOrAlias="$1"
|
||||
local arch="$2"
|
||||
local os="$3"
|
||||
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$versionOrAlias")
|
||||
|
||||
# If the name specified is an existing package, just use it as is
|
||||
if [ -n "$runtimeBin" ]; then
|
||||
echo "$versionOrAlias"
|
||||
else
|
||||
if [ -e "$_DNVM_ALIAS_DIR/$versionOrAlias.alias" ]; then
|
||||
local runtimeFullName=$(cat "$_DNVM_ALIAS_DIR/$versionOrAlias.alias")
|
||||
if [[ ! -n "$arch" ]]; then
|
||||
echo "$runtimeFullName"
|
||||
return
|
||||
fi
|
||||
local pkgVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||
fi
|
||||
|
||||
if [[ ! -n "$pkgVersion" ]]; then
|
||||
local pkgVersion=$versionOrAlias
|
||||
fi
|
||||
local pkgArchitecture="x64"
|
||||
local pkgSystem=$os
|
||||
|
||||
if [ "$arch" != "" ]; then
|
||||
local pkgArchitecture="$arch"
|
||||
fi
|
||||
if [ "$os" == "" ]; then
|
||||
local pkgSystem=$(__dnvm_current_os)
|
||||
fi
|
||||
|
||||
echo "$_DNVM_RUNTIME_PACKAGE_NAME-$pkgSystem-$pkgArchitecture.$pkgVersion"
|
||||
fi
|
||||
}
|
||||
|
||||
# This will be more relevant if we support global installs
|
||||
__dnvm_locate_runtime_bin_from_full_name() {
|
||||
local runtimeFullName=$1
|
||||
for v in `echo $DOTNET_HOME | tr ":" "\n"`; do
|
||||
if [ -e "$v/$_DNVM_INSTALL_SUBFOLDER/$runtimeFullName" ]; then
|
||||
echo "$v/$_DNVM_INSTALL_SUBFOLDER/$runtimeFullName" && return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
__echo_art() {
|
||||
printf "%b" "${Cya}"
|
||||
echo " ___ _ ___ ____ ___"
|
||||
echo " / _ \/ |/ / | / / |/ /"
|
||||
echo " / // / /| |/ / /|_/ / "
|
||||
echo " /____/_/|_/ |___/_/ /_/ "
|
||||
printf "%b" "${RCol}"
|
||||
}
|
||||
|
||||
__dnvm_description() {
|
||||
__echo_art
|
||||
echo ""
|
||||
echo "$_DNVM_VERSION_MANAGER_NAME - Version 1.0.0-$_DNVM_BUILDNUMBER"
|
||||
[[ "$_DNVM_AUTHORS" != {{* ]] && echo "By $_DNVM_AUTHORS"
|
||||
echo ""
|
||||
echo "DNVM can be used to download versions of the $_DNVM_RUNTIME_FRIENDLY_NAME and manage which version you are using."
|
||||
echo "You can control the URL of the stable and unstable channel by setting the DOTNET_FEED and DNX_UNSTABLE_FEED variables."
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}Current feed settings:${RCol}"
|
||||
printf "%b\n" "${Cya}Feed:${Yel} $_DNVM_DEFAULT_FEED"
|
||||
printf "%b\n" "${Cya}Default Channel:${Yel} $_DNVM_DEFAULT_CHANNEL"
|
||||
printf "%b\n" "${Cya}Unstable Channel:${Yel} $_DNVM_DEFAULT_UNSTABLE_CHANNEL"
|
||||
|
||||
local dnxStableOverride="<none>"
|
||||
[[ -n $DOTNET_FEED ]] && dnxStableOverride="$DOTNET_FEED"
|
||||
|
||||
printf "%b\n" "${Cya}Current Override Feed:${Yel} $dnxStableOverride"
|
||||
|
||||
local dnxUnstableOverride="<none>"
|
||||
[[ -n $DNX_UNSTABLE_FEED ]] && dnxUnstableOverride="$DNX_UNSTABLE_FEED"
|
||||
|
||||
#printf "%b\n" "${Cya}Current Unstable Override:${Yel} $dnxUnstableOverride${RCol}"
|
||||
echo ""
|
||||
|
||||
}
|
||||
|
||||
__dnvm_version() {
|
||||
echo "1.0.0-$_DNVM_BUILDNUMBER"
|
||||
}
|
||||
|
||||
__dnvm_help() {
|
||||
__dnvm_description
|
||||
printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}"
|
||||
echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
||||
echo " set installed version as default"
|
||||
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
||||
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
||||
echo " -g|global Installs the latest $_DNVM_RUNTIME_SHORT_NAME in the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DOTNET_GLOBAL_HOME)"
|
||||
echo " -y Assume Yes to all queries and do not prompt"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-OS <OS>] [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}"
|
||||
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
|
||||
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||
echo " -OS the operating system that the runtime targets (default:$(__dnvm_current_os)"
|
||||
echo " -a|-alias <alias> set alias <alias> for requested $_DNVM_RUNTIME_SHORT_NAME on install"
|
||||
echo " -p|-persistent set installed version as default"
|
||||
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
||||
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
||||
echo " -g|global Installs to the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DOTNET_GLOBAL_HOME)"
|
||||
echo " -y Assume Yes to all queries and do not prompt"
|
||||
echo ""
|
||||
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME use <semver>|<alias>|<package>|none [-p|-persistent] [-a|-arch <architecture>] ${RCol}"
|
||||
echo " <semver>|<alias>|<package> add $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line "
|
||||
echo " none remove $_DNVM_RUNTIME_SHORT_NAME bin from path of current command line"
|
||||
echo " -p|-persistent set selected version as default"
|
||||
echo " -a|-arch architecture to use (x64)"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME run <semver>|<alias> <args...> ${RCol}"
|
||||
echo " <semver>|<alias> the version or alias to run"
|
||||
echo " <args...> arguments to be passed to $_DNVM_RUNTIME_SHORT_NAME"
|
||||
echo ""
|
||||
echo " runs the $_DNVM_RUNTIME_SHORT_NAME command from the specified version of the runtime without affecting the current PATH"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME exec <semver>|<alias> <command> <args...> ${RCol}"
|
||||
echo " <semver>|<alias> the version or alias to execute in"
|
||||
echo " <command> the command to run"
|
||||
echo " <args...> arguments to be passed to the command"
|
||||
echo ""
|
||||
echo " runs the specified command in the context of the specified version of the runtime without affecting the current PATH"
|
||||
echo " example: $_DNVM_COMMAND_NAME exec 1.0.0-beta4 $_DNVM_PACKAGE_MANAGER_NAME build"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME list [-detailed]${RCol}"
|
||||
echo " -detailed display more detailed information on each runtime"
|
||||
echo ""
|
||||
echo " list $_DNVM_RUNTIME_SHORT_NAME versions installed "
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias ${RCol}"
|
||||
echo " list $_DNVM_RUNTIME_SHORT_NAME aliases which have been defined"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias <alias> ${RCol}"
|
||||
echo " display value of the specified alias"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME alias <alias> <semver>|<alias>|<package> ${RCol}"
|
||||
echo " <alias> the name of the alias to set"
|
||||
echo " <semver>|<alias>|<package> the $_DNVM_RUNTIME_SHORT_NAME version to set the alias to. Alternatively use the version of the specified alias"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME unalias <alias> ${RCol}"
|
||||
echo " remove the specified alias"
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol}"
|
||||
echo " displays this help text."
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME [version|-v|-version|--version] ${RCol}"
|
||||
echo " print the dnvm version."
|
||||
echo ""
|
||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME update-self ${RCol}"
|
||||
echo " updates dnvm itself."
|
||||
}
|
||||
|
||||
dnvm()
|
||||
{
|
||||
if [ $# -lt 1 ]; then
|
||||
__dnvm_description
|
||||
|
||||
printf "%b\n" "Use ${Yel}$_DNVM_COMMAND_NAME [help|-h|-help|--help] ${RCol} to display help text."
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
"help"|"-h"|"-help"|"--help" )
|
||||
__dnvm_help
|
||||
;;
|
||||
|
||||
"version"|"-v"|"-version"|"--version" )
|
||||
__dnvm_version
|
||||
;;
|
||||
|
||||
"update-self" )
|
||||
__dnvm_update_self
|
||||
;;
|
||||
|
||||
"upgrade" )
|
||||
shift
|
||||
$_DNVM_COMMAND_NAME install latest -p $@
|
||||
;;
|
||||
|
||||
"install" )
|
||||
[ $# -lt 2 ] && __dnvm_help && return
|
||||
shift
|
||||
local persistent=
|
||||
local versionOrAlias=
|
||||
local alias=
|
||||
local force=
|
||||
local unstable=
|
||||
local os=
|
||||
local arch=
|
||||
local global=0
|
||||
local acceptSudo=0
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
||||
local persistent="-p"
|
||||
elif [[ $1 == "-a" || $1 == "-alias" ]]; then
|
||||
local alias=$2
|
||||
shift
|
||||
elif [[ $1 == "-f" || $1 == "-force" ]]; then
|
||||
local force="-f"
|
||||
elif [[ $1 == "-u" || $1 == "-unstable" ]]; then
|
||||
local unstable="-u"
|
||||
elif [[ $1 == "-OS" ]]; then
|
||||
local os=$2
|
||||
shift
|
||||
elif [[ $1 == "-y" ]]; then
|
||||
local acceptSudo=1
|
||||
elif [[ $1 == "-arch" ]]; then
|
||||
local arch=$2
|
||||
shift
|
||||
|
||||
if [[ $arch != "x86" && $arch != "x64" ]]; then
|
||||
printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}"
|
||||
return 1
|
||||
fi
|
||||
elif [[ $1 == "-g" || $1 == "-global" ]]; then
|
||||
local global=1
|
||||
elif [[ -n $1 ]]; then
|
||||
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
||||
local versionOrAlias=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ $arch == "x86" ]]; then
|
||||
printf "%b\n" "${Red}$_DNVM_RUNTIME_FRIENDLY_NAME doesn't currently have a 32 bit build. You must use x64.${RCol}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
#This will be temporary whilst a more first class channels feature is added. There needs to be 3 values.
|
||||
if [ -z $unstable ]; then
|
||||
DNX_ACTIVE_CHANNEL="$_DNVM_DEFAULT_CHANNEL"
|
||||
else
|
||||
DNX_ACTIVE_CHANNEL="$_DNVM_DEFAULT_UNSTABLE_CHANNEL"
|
||||
fi
|
||||
|
||||
echo "Using Channel: $DNX_ACTIVE_CHANNEL"
|
||||
|
||||
DNX_ACTIVE_FEED="$DOTNET_FEED"
|
||||
if [ -z "$DNX_ACTIVE_FEED" ]; then
|
||||
DNX_ACTIVE_FEED="$_DNVM_DEFAULT_FEED"
|
||||
else
|
||||
printf "%b\n" "${Yel}Default feed ($_DNVM_DEFAULT_FEED) is being overridden by the value of the DOTNET_FEED variable ($DOTNET_FEED). ${RCol}"
|
||||
fi
|
||||
|
||||
if [[ -z $os ]]; then
|
||||
os=$(__dnvm_current_os)
|
||||
fi
|
||||
if [[ $os == "darwin" ]]; then
|
||||
os="osx"
|
||||
fi
|
||||
|
||||
if [[ -z $arch ]]; then
|
||||
arch="x64"
|
||||
fi
|
||||
|
||||
local runtimeDir=$_DNVM_USER_PACKAGES
|
||||
if [ $global == 1 ]; then
|
||||
runtimeDir=$_DNVM_GLOBAL_PACKAGES
|
||||
fi
|
||||
|
||||
if [[ "$versionOrAlias" != *.nupkg ]]; then
|
||||
if [[ "$versionOrAlias" == "latest" ]]; then
|
||||
echo "Determining latest version"
|
||||
read versionOrAlias downloadUrl < <(__dnvm_find_latest "$arch" "$os")
|
||||
echo "DownloadURL: $downloadUrl"
|
||||
[[ $? == 1 ]] && echo "Error: Could not find latest version from feed $DNX_ACTIVE_FEED" && return 1
|
||||
printf "%b\n" "Latest version is ${Cya}$versionOrAlias located at $downloadUrl${RCol}"
|
||||
else
|
||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$arch" "$os")
|
||||
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||
local versionOrAlias=$runtimeVersion
|
||||
local downloadUrl=$(__dnvm_find_package "$arch" "$os" "$runtimeVersion")
|
||||
echo "DownloadURL: $downloadUrl"
|
||||
[[ $? == 1 ]] && echo "Error: Could not find version $runtimeVersion in feed $DNX_ACTIVE_FEED" && return 1
|
||||
fi
|
||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$arch" "$os")
|
||||
local runtimeFolder="$runtimeDir/$runtimeFullName"
|
||||
|
||||
#check all runtime homes for the runtime being installed.
|
||||
#we can force install a DNX if it exists in the user or global folder, but not anywhere else.
|
||||
#The installed dnx could be global, so if we are forcing it here we will remove it since we have the
|
||||
#global path handy.
|
||||
local exist=0
|
||||
for folder in `echo $DOTNET_HOME | tr ":" "\n"`; do
|
||||
if [ -e "$folder/$_DNVM_INSTALL_SUBFOLDER/$runtimeFullName" ]; then
|
||||
local useSudo=
|
||||
if [[ ("$folder" == "$DOTNET_USER_HOME" || "$folder" == "$DOTNET_GLOBAL_HOME") && -n "$force" ]]; then
|
||||
if [[ "$folder" == "$DOTNET_GLOBAL_HOME" ]]; then
|
||||
useSudo=sudo
|
||||
fi
|
||||
printf "%b\n" "${Yel}Forcing download by deleting $folder/$_DNVM_INSTALL_SUBFOLDER/$runtimeFullName directory ${RCol}"
|
||||
$useSudo rm -rf "$folder/$_DNVM_INSTALL_SUBFOLDER/$runtimeFullName"
|
||||
continue
|
||||
fi
|
||||
echo "$runtimeFullName already installed in $folder $DNVM_USER_HOME"
|
||||
exist=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $exist != 1 ]]; then
|
||||
__dnvm_download "$runtimeFullName" "$downloadUrl" "$runtimeFolder" "$acceptSudo"
|
||||
fi
|
||||
[[ $? == 1 ]] && return 1
|
||||
if [[ "$os" == $(__dnvm_current_os) ]]; then
|
||||
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-arch" "$arch"
|
||||
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$versionOrAlias"
|
||||
fi
|
||||
else
|
||||
local runtimeFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/")
|
||||
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||
local runtimeFolder="$runtimeDir/$runtimeFullName"
|
||||
local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg"
|
||||
local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName")
|
||||
|
||||
if [ -n "$force" ]; then
|
||||
printf "%b\n" "${Yel}Forcing download by deleting $runtimeFolder directory ${RCol}"
|
||||
rm -rf "$runtimeFolder"
|
||||
fi
|
||||
|
||||
if [ -e "$runtimeFolder" ]; then
|
||||
echo "$runtimeFullName already installed"
|
||||
else
|
||||
local useSudo=
|
||||
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
||||
if [ ! -d $runtimeFolder ]; then
|
||||
if ! __dnvm_promptSudo $acceptSudo ; then
|
||||
useSudo=sudo
|
||||
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
cp -a "$versionOrAlias" "$runtimeFile"
|
||||
__dnvm_unpack "$runtimeFile" "$runtimeFolder" $useSudo
|
||||
[[ $? == 1 ]] && return 1
|
||||
fi
|
||||
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent"
|
||||
[[ -n $alias ]] && $_DNVM_COMMAND_NAME alias "$alias" "$runtimeVersion"
|
||||
fi
|
||||
;;
|
||||
|
||||
"use"|"run"|"exec" )
|
||||
[[ $1 == "use" && $# -lt 2 ]] && __dnvm_help && return
|
||||
|
||||
local cmd=$1
|
||||
local persistent=
|
||||
local arch=
|
||||
local versionOrAlias=
|
||||
|
||||
shift
|
||||
if [ $cmd == "use" ]; then
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
||||
local persistent="true"
|
||||
elif [[ $1 == "-a" || $1 == "-arch" ]]; then
|
||||
local arch=$2
|
||||
shift
|
||||
elif [[ $1 == -* ]]; then
|
||||
echo "Invalid option $1" && __dnvm_help && return 1
|
||||
elif [[ -n $1 ]]; then
|
||||
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
||||
local versionOrAlias=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
else
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [[ $1 == "-a" || $1 == "-arch" ]]; then
|
||||
local arch=$2
|
||||
shift
|
||||
elif [[ -n $1 ]]; then
|
||||
[[ -n $versionOrAlias ]] && break
|
||||
local versionOrAlias=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $cmd == "use" && $versionOrAlias == "none" ]]; then
|
||||
echo "Removing $_DNVM_RUNTIME_SHORT_NAME from process PATH"
|
||||
# Strip other version from PATH
|
||||
PATH=$(__dnvm_strip_path "$PATH")
|
||||
|
||||
if [[ -n $persistent && -e "$_DNVM_ALIAS_DIR/default.alias" ]]; then
|
||||
echo "Setting default $_DNVM_RUNTIME_SHORT_NAME to none"
|
||||
rm "$_DNVM_ALIAS_DIR/default.alias"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$arch" "$(__dnvm_current_os)")
|
||||
local runtimeBin=$(__dnvm_locate_runtime_bin_from_full_name "$runtimeFullName")
|
||||
|
||||
if [[ -z $runtimeBin ]]; then
|
||||
echo "Cannot find $runtimeFullName, do you need to run '$_DNVM_COMMAND_NAME install $versionOrAlias'?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
case $cmd in
|
||||
"run")
|
||||
local hostpath="$runtimeBin/dotnet"
|
||||
if [[ -e $hostpath ]]; then
|
||||
$hostpath $@
|
||||
return $?
|
||||
else
|
||||
echo "Cannot find $_DNVM_RUNTIME_SHORT_NAME in $runtimeBin. It may have been corrupted. Use '$_DNVM_COMMAND_NAME install $versionOrAlias -f' to attempt to reinstall it"
|
||||
fi
|
||||
;;
|
||||
"exec")
|
||||
(
|
||||
PATH=$(__dnvm_strip_path "$PATH")
|
||||
PATH=$(__dnvm_prepend_path "$PATH" "$runtimeBin")
|
||||
$@
|
||||
)
|
||||
return $?
|
||||
;;
|
||||
"use")
|
||||
echo "Adding" $runtimeBin "to process PATH"
|
||||
|
||||
PATH=$(__dnvm_strip_path "$PATH")
|
||||
PATH=$(__dnvm_prepend_path "$PATH" "$runtimeBin")
|
||||
|
||||
if [[ -n $persistent ]]; then
|
||||
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||
$_DNVM_COMMAND_NAME alias default "$runtimeVersion"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
"alias" )
|
||||
[[ $# -gt 7 ]] && __dnvm_help && return
|
||||
|
||||
[[ ! -e "$_DNVM_ALIAS_DIR/" ]] && mkdir "$_DNVM_ALIAS_DIR/" > /dev/null
|
||||
|
||||
if [[ $# == 1 ]]; then
|
||||
echo ""
|
||||
local format="%-25s %s\n"
|
||||
printf "$format" "Alias" "Name"
|
||||
printf "$format" "-----" "----"
|
||||
if [ -d "$_DNVM_ALIAS_DIR" ]; then
|
||||
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
|
||||
local alias="$(basename $__dnvm_file | sed 's/\.alias//')"
|
||||
local name="$(cat $__dnvm_file)"
|
||||
printf "$format" "$alias" "$name"
|
||||
done
|
||||
fi
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
shift
|
||||
local name="$1"
|
||||
|
||||
if [[ $# == 1 ]]; then
|
||||
[[ ! -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && echo "There is no alias called '$name'" && return 1
|
||||
cat "$_DNVM_ALIAS_DIR/$name.alias"
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
shift
|
||||
local versionOrAlias="$1"
|
||||
shift
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [[ $1 == "-a" || $1 == "-arch" ]]; then
|
||||
local arch=$2
|
||||
shift
|
||||
elif [[ $1 == "-OS" ]]; then
|
||||
local os=$2
|
||||
shift
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$arch" "$os")
|
||||
|
||||
([[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && [[ ! -d "$_DNVM_GLOBAL_PACKAGES/$runtimeFullName" ]]) && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
|
||||
|
||||
local action="Setting"
|
||||
[[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating"
|
||||
echo "$action alias '$name' to '$runtimeFullName'"
|
||||
echo "$runtimeFullName" >| "$_DNVM_ALIAS_DIR/$name.alias"
|
||||
;;
|
||||
|
||||
"unalias" )
|
||||
[[ $# -ne 2 ]] && __dnvm_help && return
|
||||
|
||||
local name=$2
|
||||
local aliasPath="$_DNVM_ALIAS_DIR/$name.alias"
|
||||
[[ ! -e "$aliasPath" ]] && echo "Cannot remove alias, '$name' is not a valid alias name" && return 1
|
||||
echo "Removing alias $name"
|
||||
rm "$aliasPath" >> /dev/null 2>&1
|
||||
;;
|
||||
|
||||
"list" )
|
||||
[[ $# -gt 2 ]] && __dnvm_help && return
|
||||
|
||||
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
|
||||
|
||||
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
|
||||
|
||||
local runtimes=""
|
||||
for location in `echo $DOTNET_HOME | tr ":" "\n"`; do
|
||||
location+="/$_DNVM_INSTALL_SUBFOLDER"
|
||||
if [ -d "$location" ]; then
|
||||
local oruntimes="$(find $location -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)"
|
||||
for v in `echo $oruntimes | tr "\n" " "`; do
|
||||
runtimes+="$v:$location"$'\n'
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return
|
||||
|
||||
echo ""
|
||||
|
||||
# Separate empty array declaration from initialization
|
||||
# to avoid potential ZSH error: local:217: maximum nested function level reached
|
||||
local arr
|
||||
arr=()
|
||||
|
||||
# Z shell array-index starts at one.
|
||||
local i=1
|
||||
local format="%-20s %s\n"
|
||||
if [ -d "$_DNVM_ALIAS_DIR" ]; then
|
||||
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
|
||||
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ] && [ ! -d "$_DNVM_GLOBAL_PACKAGES/$(cat $__dnvm_file)" ]; then
|
||||
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)"
|
||||
runtimes="$runtimes $(cat $__dnvm_file)"
|
||||
else
|
||||
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/$(cat $__dnvm_file)"
|
||||
fi
|
||||
let i+=1
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $2 == "-detailed" ]]; then
|
||||
# Calculate widest alias
|
||||
local widestAlias=5
|
||||
for f in `echo $runtimes`; do
|
||||
local pkgName=$(__dnvm_package_name "$f")
|
||||
local pkgVersion=$(__dnvm_package_version "$f")
|
||||
local alias=""
|
||||
local delim=""
|
||||
for i in "${arr[@]}"; do
|
||||
if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
|
||||
alias+="$delim${i%%/*}"
|
||||
delim=", "
|
||||
if [[ "${i%/*}" =~ \/missing$ ]]; then
|
||||
alias+=" (missing)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "${#alias}" -gt "$widestAlias" ]; then
|
||||
widestAlias=${#alias}
|
||||
fi
|
||||
done
|
||||
local formatString="%-6s %-20s %-7s %-12s %-15s %-${widestAlias}s %s\n"
|
||||
printf "$formatString" "Active" "Version" "Alias" "Location"
|
||||
printf "$formatString" "------" "-------" "-----" "--------"
|
||||
else
|
||||
local formatString="%-6s %-20s %-7s %-12s %-15s %s\n"
|
||||
printf "$formatString" "Active" "Version" "Alias"
|
||||
printf "$formatString" "------" "-------" "-----"
|
||||
fi
|
||||
|
||||
for f in `echo -e "$runtimes" | sort -t. -k2 -k3 -k4 -k1`; do
|
||||
local location=`echo $f | sed 's/.*\([:]\)//'`
|
||||
f=`echo $f | sed 's/\([:]\).*//'`
|
||||
local formattedHome=`(echo $location | sed s=$HOME=~=g)`
|
||||
local active=""
|
||||
[[ $PATH == *"$location/$f"* ]] && local active=" *"
|
||||
local pkgName=$(__dnvm_package_name "$f")
|
||||
local pkgVersion=$(__dnvm_package_version "$f")
|
||||
|
||||
local alias=""
|
||||
local delim=""
|
||||
for i in "${arr[@]}"; do
|
||||
if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
|
||||
alias+="$delim${i%%/*}"
|
||||
delim=", "
|
||||
if [[ "${i%/*}" =~ \/missing$ ]]; then
|
||||
alias+=" (missing)"
|
||||
formattedHome=""
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $2 == "-detailed" ]]; then
|
||||
printf "$formatString" "$active" "$pkgVersion" "$alias" "$formattedHome"
|
||||
else
|
||||
printf "$formatString" "$active" "$pkgVersion" "$alias"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown command $1"
|
||||
return 1
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Add the home location's bin directory to the path if it doesn't exist
|
||||
[[ ":$PATH:" != *":$DOTNET_USER_HOME:"* ]] && export PATH="$DOTNET_USER_HOME:$PATH"
|
||||
|
||||
# Generate the command function using the constant defined above.
|
||||
$_DNVM_COMMAND_NAME alias default >/dev/null && $_DNVM_COMMAND_NAME use default >/dev/null || true
|
|
@ -8,9 +8,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source $DIR/_common.sh
|
||||
source $DIR/../_common.sh
|
||||
|
||||
cd $DIR/..
|
||||
cd $DIR/../..
|
||||
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build"
|
||||
[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container"
|
||||
|
@ -18,11 +18,11 @@ cd $DIR/..
|
|||
[ -z "$BUILD_COMMAND" ] && BUILD_COMMAND="/opt/code/build.sh"
|
||||
|
||||
# Build the docker container (will be fast if it is already built)
|
||||
banner "Building Docker Container"
|
||||
header "Building Docker Container"
|
||||
docker build -t $DOTNET_BUILD_CONTAINER_TAG scripts/docker/
|
||||
|
||||
# Run the build in the container
|
||||
banner "Launching build in Docker Container"
|
||||
header "Launching build in Docker Container"
|
||||
info "Using code from: $DOCKER_HOST_SHARE_DIR"
|
||||
docker run -t --rm --sig-proxy=true \
|
||||
--name $DOTNET_BUILD_CONTAINER_NAME \
|
|
@ -25,7 +25,7 @@ _convert_path(){
|
|||
}
|
||||
|
||||
# Bypass Msys path conversion
|
||||
REPO_ROOT=$(readlink -f $DIR/..)
|
||||
REPO_ROOT=$(readlink -f $DIR/../..)
|
||||
REPO_ROOT=$(_convert_path $REPO_ROOT)
|
||||
|
||||
VM_NAME="dotnet"
|
||||
|
@ -88,7 +88,7 @@ run_build(){
|
|||
export DOCKER_HOST_SHARE_DIR="$(_convert_path $VM_CODE_DIR)"
|
||||
export BUILD_COMMAND="//opt\\code\\build.sh"
|
||||
|
||||
$DIR/dockerbuild.sh debian
|
||||
$DIR/../dockerbuild.sh debian
|
||||
}
|
||||
|
||||
# This will duplicate the entire repo + any side effects from
|
|
@ -2,7 +2,7 @@
|
|||
SETLOCAL
|
||||
SET ERRORLEVEL=
|
||||
|
||||
"%~dp0dnx\dnx" "%~dp0dnx\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore %*
|
||||
"%~dp0dnx\dnx" "%~dp0dnx\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" restore %*
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
ENDLOCAL
|
||||
|
|
29
scripts/dev-install.sh → scripts/enable-dev.sh
Executable file → Normal file
29
scripts/dev-install.sh → scripts/enable-dev.sh
Executable file → Normal file
|
@ -1,6 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
# This script is NOT executable. It MUST be sourced!
|
||||
|
||||
if [ ! -z "$BASH_SOURCE" ]; then
|
||||
SOURCE="${BASH_SOURCE}"
|
||||
elif [ ! -z "$ZSH_VERSION" ]; then
|
||||
SOURCE="$0"
|
||||
else
|
||||
echo "Unsupported shell, this requires bash or zsh" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
|
@ -9,10 +17,9 @@ done
|
|||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
UNAME=$(uname)
|
||||
|
||||
if [ -z "$RID" ]; then
|
||||
UNAME=$(uname)
|
||||
if [ "$UNAME" == "Darwin" ]; then
|
||||
OSNAME=osx
|
||||
RID=osx.10.10-x64
|
||||
|
@ -21,19 +28,9 @@ if [ -z "$RID" ]; then
|
|||
OSNAME=linux
|
||||
RID=ubuntu.14.04-x64
|
||||
else
|
||||
echo "Unknown OS: $UNAME" 1>&2
|
||||
error "unknown OS: $UNAME" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||
DNX_DIR=$OUTPUT_ROOT/dnx
|
||||
HOST_DIR=$OUTPUT_ROOT/clrhost
|
||||
STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||
STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||
|
||||
DESTINATION=$(eval echo "~/.dotnet/sdks/dotnet-${OSNAME}-x64.0.0.1-dev")
|
||||
|
||||
info "Symlinking $STAGE2_DIR to $DESTINATION"
|
||||
rm -f $DESTINATION
|
||||
ln -s $STAGE2_DIR $DESTINATION
|
||||
export DOTNET_TOOLS=$REPOROOT/artifacts/$RID/stage2
|
92
scripts/install.ps1
Normal file
92
scripts/install.ps1
Normal file
|
@ -0,0 +1,92 @@
|
|||
$ErrorActionPreference="Stop"
|
||||
$ProgressPreference="SilentlyContinue"
|
||||
|
||||
$Feed="https://dotnetcli.blob.core.windows.net/dotnet"
|
||||
$Channel="dev"
|
||||
$DotNetFileName="dotnet-win-x64.latest.zip"
|
||||
$DotNetUrl="$Feed/$Channel/Binaries/Latest"
|
||||
|
||||
function say($str)
|
||||
{
|
||||
Write-Host "dotnet_install: $str"
|
||||
}
|
||||
|
||||
$InstallDir = $env:DOTNET_INSTALL_DIR
|
||||
if (!$InstallDir) {
|
||||
$InstallDir = "$env:LocalAppData\Microsoft\dotnet"
|
||||
}
|
||||
|
||||
say "Preparing to install .NET Tools to $InstallDir"
|
||||
|
||||
# Check if we need to bother
|
||||
$LocalFile = "$InstallDir\cli\.version"
|
||||
if (Test-Path $LocalFile)
|
||||
{
|
||||
$LocalData = @(cat $LocalFile)
|
||||
$LocalHash = $LocalData[0].Trim()
|
||||
$LocalVersion = $LocalData[1].Trim()
|
||||
if ($LocalVersion -and $LocalHash)
|
||||
{
|
||||
$RemoteResponse = Invoke-WebRequest -UseBasicParsing "$Feed/$Channel/dnvm/latest.win.version"
|
||||
$RemoteData = @([Text.Encoding]::UTF8.GetString($RemoteResponse.Content).Split());
|
||||
$RemoteHash = $RemoteData[0].Trim()
|
||||
$RemoteVersion = $RemoteData[1].Trim()
|
||||
|
||||
if (!$RemoteVersion -or !$RemoteHash) {
|
||||
throw "Invalid response from feed"
|
||||
}
|
||||
|
||||
say "Latest version: $RemoteVersion"
|
||||
say "Local Version: $LocalVersion"
|
||||
|
||||
if($LocalHash -eq $RemoteHash)
|
||||
{
|
||||
say "You already have the latest version"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Set up the install location
|
||||
if (!(Test-Path $InstallDir)) {
|
||||
mkdir $InstallDir | Out-Null
|
||||
}
|
||||
|
||||
# De-powershell the path before passing to .NET APIs
|
||||
$InstallDir = Convert-Path $InstallDir
|
||||
|
||||
say "Downloading $DotNetFileName from $DotNetUrl"
|
||||
$resp = Invoke-WebRequest -UseBasicParsing "$DotNetUrl/$DotNetFileName" -OutFile "$InstallDir\$DotNetFileName"
|
||||
|
||||
say "Extracting zip"
|
||||
|
||||
# Create the destination
|
||||
if (Test-Path "$InstallDir\cli_new") {
|
||||
del -rec -for "$InstallDir\cli_new"
|
||||
}
|
||||
mkdir "$InstallDir\cli_new" | Out-Null
|
||||
|
||||
Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$InstallDir\$DotNetFileName", "$InstallDir\cli_new")
|
||||
|
||||
# Replace the old installation (if any)
|
||||
if (Test-Path "$InstallPath\cli") {
|
||||
del -rec -for "$InstallPath\cli"
|
||||
}
|
||||
mv "$InstallDir\cli_new" "$InstallDir\cli"
|
||||
|
||||
# Clean the zip
|
||||
if (Test-Path "$InstallDir\$DotNetFileName") {
|
||||
del -for "$InstallDir\$DotNetFileName"
|
||||
}
|
||||
|
||||
say "The .NET Tools have been installed to $InstallDir!"
|
||||
|
||||
$binPath = "$InstallDir\bin"
|
||||
if (Test-Path $binPath) {
|
||||
# New layout
|
||||
say "Add '$InstallDir\bin' to your PATH to use dotnet"
|
||||
} else {
|
||||
# Old layout (temporary)
|
||||
say "Add '$InstallDir' to your PATH to use dotnet"
|
||||
}
|
234
scripts/install.sh
Normal file → Executable file
234
scripts/install.sh
Normal file → Executable file
|
@ -1,5 +1,67 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Note: This script should be compatible with the dash shell used in Ubuntu. So avoid bashisms! See https://wiki.ubuntu.com/DashAsBinSh for more info
|
||||
|
||||
# This is a herestring Everything from the line AFTER the "read" until the line containing ONLY "EOF" is part of the string
|
||||
# The quotes around "EOF" ensure that $ is not interpreted as a variable expansion. The indentation of the herestring must be
|
||||
# kept exactly consistent
|
||||
LINK_SCRIPT_CONTENT=$(cat <<-"EOF"
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
if [ -z "$DOTNET_TOOLS" ]; then
|
||||
# We should be in $PREFIX/bin, so just get the directory above us.
|
||||
PREFIX="$( cd -P "$DIR/.." && pwd)"
|
||||
|
||||
# The tools are in $PREFIX/share/dotnet/cli by default
|
||||
DOTNET_TOOLS_DEFAULT=$PREFIX/share/dotnet/cli
|
||||
|
||||
# Check the default location
|
||||
if [ -d "$DOTNET_TOOLS_DEFAULT" ]; then
|
||||
export DOTNET_TOOLS=$DOTNET_TOOLS_DEFAULT
|
||||
else
|
||||
echo "error: the .NET tools installation appears to be corrupt!" 1>&2
|
||||
echo "error: specifically, the tools could not be located in the $DOTNET_TOOLS_DEFAULT directory" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MY_NAME=$(basename ${BASH_SOURCE[0]})
|
||||
MY_TARGET=$DOTNET_TOOLS/bin/$MY_NAME
|
||||
|
||||
if [ ! -e "$MY_TARGET" ]; then
|
||||
# try the old layout
|
||||
MY_TARGET=$DOTNET_TOOLS/$MY_NAME
|
||||
if [ ! -e "$MY_TARGET" ]; then
|
||||
echo "error: the tool $MY_TARGET cannot be found" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo "warning: this version of the dotnet tools is using the old layout!" 1>&2
|
||||
fi
|
||||
|
||||
if [ ! -x "$MY_TARGET" ]; then
|
||||
echo "error: the tool $MY_TARGET is not executable" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$MY_TARGET" "$@"
|
||||
EOF
|
||||
)
|
||||
|
||||
#set default prefix (PREFIX is a fairly standard env-var, but we also want to allow the use the specific "DOTNET_INSTALL_DIR" one)
|
||||
if [ ! -z "$DOTNET_INSTALL_DIR" ]; then
|
||||
PREFIX=$DOTNET_INSTALL_DIR
|
||||
elif [ -z "$PREFIX" ]; then
|
||||
PREFIX=/usr/local
|
||||
fi
|
||||
|
||||
#setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
|
||||
#See if stdout is a terminal
|
||||
if [ -t 1 ]; then
|
||||
|
@ -20,7 +82,7 @@ if [ -t 1 ]; then
|
|||
fi
|
||||
|
||||
#Standardise OS name to what is put into filenames of the tarballs.
|
||||
__current_os()
|
||||
current_os()
|
||||
{
|
||||
local uname=$(uname)
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
|
@ -30,7 +92,7 @@ __current_os()
|
|||
fi
|
||||
}
|
||||
|
||||
__machine_has() {
|
||||
machine_has() {
|
||||
type "$1" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
@ -38,9 +100,14 @@ __machine_has() {
|
|||
#Not 100% sure at the moment that these checks are enough. We might need to take version into account or do something
|
||||
#more complicated. This seemed like a good beginning though as it should catch the default "clean" machine case and give
|
||||
#people an appropriate hint.
|
||||
__check_pre_reqs() {
|
||||
local os=$(__current_os)
|
||||
check_pre_reqs() {
|
||||
local os=$(current_os)
|
||||
local _failing=false;
|
||||
|
||||
if [ "$DOTNET_INSTALL_SKIP_PREREQS" = "1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$os" = "linux" ]; then
|
||||
[ -z "$(ldconfig -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true
|
||||
|
@ -48,7 +115,7 @@ __check_pre_reqs() {
|
|||
[ -z "$(ldconfig -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true
|
||||
[ -z "$(ldconfig -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$_failing" = true ]; then
|
||||
return 1
|
||||
fi
|
||||
|
@ -62,90 +129,135 @@ say() {
|
|||
printf "%b\n" "dotnet_install: $1"
|
||||
}
|
||||
|
||||
_install_dotnet()
|
||||
make_link() {
|
||||
local target_name=$1
|
||||
local dest=$PREFIX/bin/$target_name
|
||||
say "Linking $dest -> $PREFIX/share/dotnet/cli/$target_name"
|
||||
if [ -e $dest ]; then
|
||||
rm $dest
|
||||
fi
|
||||
|
||||
[ -d "$PREFIX/bin" ] || mkdir -p $PREFIX/bin
|
||||
|
||||
echo "$LINK_SCRIPT_CONTENT" > $dest
|
||||
|
||||
# Make mode: rwxr-xr-x
|
||||
chmod 755 $dest
|
||||
}
|
||||
|
||||
install_dotnet()
|
||||
{
|
||||
if ! __machine_has "curl"; then
|
||||
if ! machine_has "curl"; then
|
||||
printf "%b\n" "${red}curl is required to download dotnet. Install curl to proceed. ${normal}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -e "/usr/local/share/dotnet/cli/dotnet" ] && [ ! -w "/usr/local/share/dotnet/cli/dotnet" ]; then
|
||||
say "Preparing to install .NET Tools to $PREFIX"
|
||||
|
||||
if [ -e "$PREFIX/share/dotnet/cli/dotnet" ] && [ ! -w "$PREFIX/share/dotnet/cli/dotnet" ]; then
|
||||
say_err "dotnet cli is already installed and not writeable. Use 'curl -sSL <url> | sudo sh' to force install."
|
||||
say_err "If you have previously installed the cli using a pkg then that is why it is write protected, and you need to run sudo to install the new version."
|
||||
say_err "Alternatively, removing the '/usr/local/share/dotnet' directory completely before running the script will also resolve the issue."
|
||||
say_err "If you have previously installed the cli using a package manager or installer then that is why it is write protected, and you need to run sudo to install the new version."
|
||||
say_err "Alternatively, removing the '$PREFIX/share/dotnet' directory completely before running the script will also resolve the issue."
|
||||
return 1
|
||||
fi
|
||||
|
||||
__check_pre_reqs
|
||||
if [ $? != 0 ]; then
|
||||
if ! check_pre_reqs; then
|
||||
say_err "Ending install due to missing pre-reqs"
|
||||
return 1;
|
||||
fi
|
||||
local os=$(__current_os)
|
||||
local installLocation="/usr/local/share/dotnet"
|
||||
local os=$(current_os)
|
||||
local installLocation="$PREFIX/share/dotnet"
|
||||
local dotnet_url="https://dotnetcli.blob.core.windows.net/dotnet/dev/Binaries/Latest"
|
||||
local dotnet_filename="dotnet-$os-x64.latest.tar.gz"
|
||||
|
||||
local remoteData="$(curl -s https://dotnetcli.blob.core.windows.net/dotnet/dev/dnvm/latest.$os.version)"
|
||||
[ $? != 0 ] && say_err "Unable to determine latest version." && return 1
|
||||
if [ "$RELINK" = "0" ]; then
|
||||
if [ "$FORCE" = "0" ]; then
|
||||
# Check if we need to bother
|
||||
local remoteData="$(curl -s https://dotnetcli.blob.core.windows.net/dotnet/dev/dnvm/latest.$os.version)"
|
||||
[ $? != 0 ] && say_err "Unable to determine latest version." && return 1
|
||||
|
||||
local remoteVersion=$(IFS="\n" && echo $remoteData | tail -n 1)
|
||||
local remoteHash=$(IFS="\n" && echo $remoteData | head -n 1)
|
||||
local remoteVersion=$(IFS="\n" && echo $remoteData | tail -n 1)
|
||||
local remoteHash=$(IFS="\n" && echo $remoteData | head -n 1)
|
||||
|
||||
local localVersion=$(tail -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
[ -z $localVersion ] && localVersion='<none>'
|
||||
local localHash=$(head -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
local localVersion=$(tail -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
[ -z $localVersion ] && localVersion='<none>'
|
||||
local localHash=$(head -n 1 "$installLocation/cli/.version" 2>/dev/null)
|
||||
|
||||
say "Latest Version: $remoteVersion"
|
||||
say "Local Version: $localVersion"
|
||||
|
||||
[ "$remoteHash" = "$localHash" ] && say "${green}You already have the latest version.${normal}" && return 0
|
||||
say "Latest Version: $remoteVersion"
|
||||
say "Local Version: $localVersion"
|
||||
|
||||
#This should noop if the directory already exists.
|
||||
mkdir -p $installLocation
|
||||
[ "$remoteHash" = "$localHash" ] && say "${green}You already have the latest version.${normal}" && return 0
|
||||
fi
|
||||
|
||||
say "Downloading $dotnet_filename from $dotnet_url"
|
||||
#This should noop if the directory already exists.
|
||||
mkdir -p $installLocation
|
||||
|
||||
#Download file and check status code, error and return if we cannot download a cli tar.
|
||||
local httpResult=$(curl -L -D - "$dotnet_url/$dotnet_filename" -o "$installLocation/$dotnet_filename" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||
[ $httpResult -ne "302" ] && [ $httpResult -ne "200" ] && echo "${Red}HTTP Error $httpResult fetching the dotnet cli from $dotnet_url ${RCol}" && return 1
|
||||
say "Downloading $dotnet_filename from $dotnet_url"
|
||||
|
||||
say "Extracting tarball"
|
||||
#Any of these could fail for various reasons so we will check each one and end the script there if it fails.
|
||||
rm -rf "$installLocation/cli_new"
|
||||
mkdir "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to clean and create temporary cli directory to extract into" && return 1
|
||||
|
||||
tar -xzf "$installLocation/$dotnet_filename" -C "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to extract tar" && return 1
|
||||
|
||||
say "Moving new CLI into install location and symlinking"
|
||||
#Download file and check status code, error and return if we cannot download a cli tar.
|
||||
local httpResult=$(curl -L -D - "$dotnet_url/$dotnet_filename" -o "$installLocation/$dotnet_filename" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||
[ $httpResult -ne "302" ] && [ $httpResult -ne "200" ] && echo "${Red}HTTP Error $httpResult fetching the dotnet cli from $dotnet_url ${RCol}" && return 1
|
||||
|
||||
rm -rf "$installLocation/cli"
|
||||
[ $? != 0 ] && say_err "Failed to clean current dotnet install" && return 1
|
||||
say "Extracting tarball"
|
||||
#Any of these could fail for various reasons so we will check each one and end the script there if it fails.
|
||||
rm -rf "$installLocation/cli_new"
|
||||
mkdir "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to clean and create temporary cli directory to extract into" && return 1
|
||||
|
||||
mv "$installLocation/cli_new" "$installLocation/cli"
|
||||
tar -xzf "$installLocation/$dotnet_filename" -C "$installLocation/cli_new"
|
||||
[ $? != 0 ] && say_err "failed to extract tar" && return 1
|
||||
|
||||
say "Moving new CLI into install location and symlinking"
|
||||
|
||||
rm -rf "$installLocation/cli"
|
||||
[ $? != 0 ] && say_err "Failed to clean current dotnet install" && return 1
|
||||
|
||||
mv "$installLocation/cli_new" "$installLocation/cli"
|
||||
elif [ ! -e "$installLocation/cli" ]; then
|
||||
say_err "${red}cannot relink dotnet, it is not installed in $PREFIX!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
for f in $(find "$installLocation/cli" -regex ".*/dotnet[a-z\-]*$")
|
||||
do
|
||||
local baseFile=$(basename $f)
|
||||
local symlinkFile="/usr/local/bin/$baseFile"
|
||||
say "Linking $symlinkFile -> $f"
|
||||
if [ -e $symlinkFile ]; then
|
||||
if [ -h $symlinkFile ]; then
|
||||
ln -sf $f /usr/local/bin/
|
||||
else
|
||||
say "${yellow}$symlinkFile is a file rather than a symlink. We are overwriting it with a symlink.${normal}"
|
||||
rm $symlinkFile
|
||||
ln -s $f /usr/local/bin/
|
||||
fi
|
||||
else
|
||||
ln -s $f /usr/local/bin/
|
||||
fi
|
||||
make_link $baseFile
|
||||
done
|
||||
|
||||
say "Cleaning $dotnet_filename"
|
||||
rm "$installLocation/$dotnet_filename"
|
||||
[ $? != 0 ] && say_err "Failed to delete tar after extracting." && return 1
|
||||
if [ -e "$installLocation/$dotnet_filename" ]; then
|
||||
say "Cleaning $dotnet_filename"
|
||||
if ! rm "$installLocation/$dotnet_filename"; then
|
||||
say_err "Failed to delete tar after extracting."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
_install_dotnet
|
||||
|
||||
FORCE=0
|
||||
RELINK=0
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
if [ $1 = "-f" ] || [ $1 = "--force" ]; then
|
||||
FORCE=1
|
||||
elif [ $1 = "-r" ] || [ $1 = "--relink" ]; then
|
||||
RELINK=1
|
||||
elif [ $1 = "-?" ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then
|
||||
echo ".NET Tools Installer"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " $0 [-f]"
|
||||
echo " $0 -r"
|
||||
echo " $0 -h"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f Force reinstallation even if you have the most recent version installed"
|
||||
echo " -r Don't re-download, just recreate the links in $PREFIX/bin"
|
||||
echo " -h Show this help message"
|
||||
echo ""
|
||||
echo "The PREFIX environment variable can be used to affect the root installation directory"
|
||||
exit 0
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
install_dotnet
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
@echo off
|
||||
|
||||
REM PowerShell has access to Zipping tools
|
||||
@powershell -NoLogo -NoProfile -ExecutionPolicy unrestricted -File "%~dp0package.ps1"
|
|
@ -11,14 +11,14 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
if [ "$UNAME" != "Linux" ]; then
|
||||
error "Debian Package build only supported on Linux"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_ROOT=$(readlink -f $DIR/..)
|
||||
REPO_ROOT=$(readlink -f $DIR/../..)
|
||||
|
||||
OUTPUT_DIR="$REPO_ROOT/artifacts"
|
||||
PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/deb_intermediate"
|
||||
|
@ -33,7 +33,7 @@ execute(){
|
|||
}
|
||||
|
||||
create_empty_debian_layout(){
|
||||
banner "Creating empty debian package layout"
|
||||
header "Creating empty debian package layout"
|
||||
|
||||
rm -rf $PACKAGE_LAYOUT_DIR
|
||||
mkdir -p $PACKAGE_LAYOUT_DIR
|
||||
|
@ -45,7 +45,7 @@ create_empty_debian_layout(){
|
|||
}
|
||||
|
||||
copy_files_to_debian_layout(){
|
||||
banner "Copying files to debian layout"
|
||||
header "Copying files to debian layout"
|
||||
|
||||
# Copy Built Binaries
|
||||
cp -a "$REPO_BINARIES_DIR/." "$PACKAGE_LAYOUT_DIR/package_root"
|
||||
|
@ -55,7 +55,7 @@ copy_files_to_debian_layout(){
|
|||
}
|
||||
|
||||
create_debian_package(){
|
||||
banner "Packing .deb"
|
||||
header "Packing .deb"
|
||||
|
||||
mkdir -p $PACKAGE_OUTPUT_DIR
|
||||
|
||||
|
@ -63,7 +63,7 @@ create_debian_package(){
|
|||
}
|
||||
|
||||
test_debian_package(){
|
||||
banner "Testing debian package"
|
||||
header "Testing debian package"
|
||||
|
||||
git clone https://github.com/sstephenson/bats.git /tmp/bats
|
||||
pushd /tmp/bats
|
||||
|
@ -76,4 +76,4 @@ test_debian_package(){
|
|||
execute
|
||||
|
||||
DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb")
|
||||
$DIR/publish.sh $DEBIAN_FILE
|
||||
$DIR/../publish/publish.sh $DEBIAN_FILE
|
|
@ -8,9 +8,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/../.." && pwd )"
|
||||
|
||||
if [ -z "$DOTNET_BUILD_VERSION" ]; then
|
||||
TIMESTAMP=$(date "+%Y%m%d%H%M%S")
|
||||
|
@ -32,22 +32,7 @@ PACKAGE_NAME=$PACKAGE_DIR/${PACKAGE_SHORT_NAME}.tar.gz
|
|||
|
||||
cd $STAGE2_DIR
|
||||
|
||||
# Correct all the mode flags
|
||||
banner "Packaging $PACKAGE_SHORT_NAME"
|
||||
|
||||
# Managed code doesn't need 'x'
|
||||
find . -type f -name "*.dll" | xargs chmod 644
|
||||
find . -type f -name "*.exe" | xargs chmod 644
|
||||
|
||||
# Generally, dylibs and sos have 'x' (no idea if it's required ;))
|
||||
if [ "$OSNAME" == "osx" ]; then
|
||||
find . -type f -name "*.dylib" | xargs chmod 744
|
||||
else
|
||||
find . -type f -name "*.so" | xargs chmod 744
|
||||
fi
|
||||
|
||||
# Executables (those without dots) are executable :)
|
||||
find . -type f ! -name "*.*" | xargs chmod 755
|
||||
header "Packaging $PACKAGE_SHORT_NAME"
|
||||
|
||||
# Tar up the stage2 artifacts
|
||||
# We need both "*" and ".version" to ensure we pick up that file
|
||||
|
@ -55,4 +40,4 @@ tar -czf $PACKAGE_NAME * .version
|
|||
|
||||
info "Packaged stage2 to $PACKAGE_NAME"
|
||||
|
||||
$DIR/publish.sh $PACKAGE_NAME
|
||||
$DIR/../publish/publish.sh $PACKAGE_NAME
|
|
@ -1,7 +1,4 @@
|
|||
$Rid = "win7-x64"
|
||||
$RepoRoot = Convert-Path (Split-Path -Parent $PSScriptRoot)
|
||||
$Stage2Dir = Join-Path $RepoRoot "artifacts\$RID\stage2"
|
||||
$PackageDir = Join-Path $RepoRoot "artifacts\packages\dnvm"
|
||||
. "$PSScriptRoot\..\_common.ps1"
|
||||
|
||||
if(!(Test-Path $PackageDir)) {
|
||||
mkdir $PackageDir | Out-Null
|
||||
|
@ -17,10 +14,12 @@ if(![string]::IsNullOrEmpty($env:DOTNET_BUILD_VERSION)) {
|
|||
# Stamp the output with the commit metadata and version number
|
||||
$Commit = git rev-parse HEAD
|
||||
|
||||
@"
|
||||
$VersionContent = @"
|
||||
$Commit
|
||||
$PackageVersion
|
||||
"@.Trim() | Out-File -Encoding UTF8 "$Stage2Dir/.version"
|
||||
"@
|
||||
|
||||
$VersionContent | Out-File -Encoding UTF8 "$Stage2Dir\.version"
|
||||
|
||||
$PackageName = Join-Path $PackageDir "dotnet-win-x64.$PackageVersion.zip"
|
||||
|
||||
|
@ -34,7 +33,7 @@ Add-Type -Assembly System.IO.Compression.FileSystem
|
|||
|
||||
Write-Host "Packaged stage2 to $PackageName"
|
||||
|
||||
$PublishScript = Join-Path $PSScriptRoot "publish.ps1"
|
||||
$PublishScript = Join-Path $PSScriptRoot "..\publish\publish.ps1"
|
||||
& $PublishScript -file $PackageName
|
||||
|
||||
exit $LastExitCode
|
|
@ -7,12 +7,9 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/../.." && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
|
||||
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||
STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
echo "Starting packaging"
|
||||
|
||||
|
@ -29,9 +26,11 @@ echo $DOTNET_BUILD_VERSION >> $STAGE2_DIR/.version
|
|||
# Create Dnvm Package
|
||||
$DIR/package-dnvm.sh
|
||||
|
||||
if [[ "$(uname)" == "Linux" ]]; then
|
||||
if [[ "$UNAME" == "Linux" ]]; then
|
||||
# Create Debian package
|
||||
$DIR/package-debian.sh
|
||||
elif [[ "$UNAME" == "Darwin" ]]; then
|
||||
# Create OSX PKG
|
||||
$DIR/../../packaging/osx/package-osx.sh
|
||||
fi
|
||||
|
||||
$DIR/../packaging/osx/package-osx.sh
|
|
@ -88,7 +88,7 @@ function UploadBinaries($zipFile)
|
|||
}
|
||||
|
||||
# update the version file
|
||||
$versionFile = Convert-Path $PSScriptRoot\..\artifacts\win7-x64\stage2\.version
|
||||
$versionFile = Convert-Path $PSScriptRoot\..\..\artifacts\win7-x64\stage2\.version
|
||||
$Version_URI = "https://$env:STORAGE_ACCOUNT.blob.core.windows.net/$env:STORAGE_CONTAINER/$env:CHANNEL/dnvm/latest.win.version$env:SASTOKEN"
|
||||
|
||||
if(-Not (UploadFile $Version_URI $versionFile))
|
|
@ -15,14 +15,14 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
[[ $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
|
||||
done
|
||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$SCRIPT_DIR/.." && pwd )"
|
||||
REPOROOT="$( cd -P "$SCRIPT_DIR/../.." && pwd )"
|
||||
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
source "$SCRIPT_DIR/../_common.sh"
|
||||
|
||||
UPLOAD_FILE=$1
|
||||
UPLOAD_JSON_FILE="package_upload.json"
|
||||
|
||||
banner "Publishing package"
|
||||
header "Publishing package"
|
||||
|
||||
execute(){
|
||||
if ! validate_env_variables; then
|
||||
|
@ -86,7 +86,7 @@ upload_file_to_blob_storage_azure_cli(){
|
|||
local blob=$1
|
||||
local file=$2
|
||||
|
||||
banner "Uploading $file to blob storage"
|
||||
header "Uploading $file to blob storage"
|
||||
|
||||
# use azure cli to upload to blob storage. We cannot use curl to do this becuase azure has a max limit of 64mb that can be uploaded using REST
|
||||
# statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $upload_URL -T $file)
|
||||
|
@ -107,7 +107,7 @@ update_file_in_blob_storage(){
|
|||
local file=$2
|
||||
local filecontent=$3
|
||||
|
||||
banner "Updating $file in blob storage"
|
||||
header "Updating $file in blob storage"
|
||||
|
||||
statusCode=$(curl -s -w "%{http_code}" -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" -H "Content-Type: text/plain" $update_URL --data-binary $filecontent --request PUT )
|
||||
|
0
scripts/repoapi_client.sh → scripts/publish/repoapi_client.sh
Executable file → Normal file
0
scripts/repoapi_client.sh → scripts/publish/repoapi_client.sh
Executable file → Normal file
20
scripts/test/smoke-test.ps1
Normal file
20
scripts/test/smoke-test.ps1
Normal file
|
@ -0,0 +1,20 @@
|
|||
. "$PSScriptRoot\..\_common.ps1"
|
||||
|
||||
# Restore and compile the test app
|
||||
dotnet restore "$RepoRoot\test\TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
dotnet compile "$RepoRoot\test\TestApp" --output "$RepoRoot\artifacts\$Rid\smoketest"
|
||||
|
||||
# Run the app and check the exit code
|
||||
& "$RepoRoot\artifacts\$Rid\smoketest\TestApp.exe"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Test App failed to run"
|
||||
}
|
||||
|
||||
# Check that a compiler error is reported
|
||||
$oldErrorAction = $ErrorActionPreference
|
||||
$ErrorActionPreference="SilentlyContinue"
|
||||
dotnet compile "$RepoRoot\test\compile\failing\SimpleCompilerError" --framework "$Tfm" 2>$null >$null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
throw "Compiler error didn't cause non-zero exit code!"
|
||||
}
|
||||
$ErrorActionPreference = $oldErrorAction
|
31
scripts/test/smoke-test.sh
Executable file
31
scripts/test/smoke-test.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $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
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/../.." && pwd )"
|
||||
|
||||
source "$DIR/../_common.sh"
|
||||
|
||||
rm "$REPOROOT/test/TestApp/project.lock.json"
|
||||
dotnet restore "$REPOROOT/test/TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64"
|
||||
dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest"
|
||||
|
||||
# set -e will abort if the exit code of this is non-zero
|
||||
$REPOROOT/artifacts/$RID/smoketest/TestApp
|
||||
|
||||
# Check that a compiler error is reported
|
||||
set +e
|
||||
dotnet compile "$REPOROOT/test/compile/failing/SimpleCompilerError" --framework "$TFM" 2>/dev/null >/dev/null
|
||||
rc=$?
|
||||
if [ $rc == 0 ]; then
|
||||
error "Compiler failure test failed! The compiler did not fail to compile!"
|
||||
exit 1
|
||||
fi
|
||||
set -e
|
|
@ -13,7 +13,9 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
public static readonly string DefaultConfiguration = "Debug";
|
||||
public static readonly string BinDirectoryName = "bin";
|
||||
public static readonly string ObjDirectoryName = "obj";
|
||||
|
||||
|
||||
public static readonly string LibCoreClrName = (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "coreclr" : "libcoreclr") + DynamicLibSuffix;
|
||||
|
||||
public static readonly string DynamicLibSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".dll" :
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
|
||||
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
"dependencies": {
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
"System.Threading": "4.0.11-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-beta-23504",
|
||||
|
||||
"Microsoft.NETCore.ConsoleHost": "1.0.0-beta-23504",
|
||||
"Microsoft.NETCore.TestHost": "1.0.0-beta-23504"
|
||||
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-beta-23504"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
11
src/Microsoft.DotNet.Runtime/Program.cs
Normal file
11
src/Microsoft.DotNet.Runtime/Program.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
namespace Microsoft.DotNet.Runtime
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
// Temporary and bogus. Just needed so we can publish this
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
3
src/Microsoft.DotNet.Runtime/README.md
Normal file
3
src/Microsoft.DotNet.Runtime/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Microsoft.DotNet.Runtime
|
||||
|
||||
This is a utility project that brings the CoreCLR down and lets us publish it as though it were an app. Do NOT add any C# code to it! It is not designed to actually be compiled as an assembly, it's just used for its dependencies.
|
13
src/Microsoft.DotNet.Runtime/project.json
Normal file
13
src/Microsoft.DotNet.Runtime/project.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
|
@ -172,16 +172,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
private static Command RunCsc(string cscArgs)
|
||||
{
|
||||
// Locate CoreRun
|
||||
string hostRoot = Environment.GetEnvironmentVariable("DOTNET_CSC_PATH");
|
||||
if (string.IsNullOrEmpty(hostRoot))
|
||||
{
|
||||
hostRoot = AppContext.BaseDirectory;
|
||||
}
|
||||
var corerun = Path.Combine(hostRoot, Constants.HostExecutableName);
|
||||
var cscExe = Path.Combine(hostRoot, "csc.exe");
|
||||
return File.Exists(corerun) && File.Exists(cscExe)
|
||||
? Command.Create(corerun, $@"""{cscExe}"" {cscArgs}")
|
||||
: Command.Create("csc", cscArgs);
|
||||
return Command.Create("csc", cscArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
var framework = app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||
var configuration = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||
var preserveTemporaryOutput = app.Option("-t|--preserve-temporary", "Keep the output's temporary directory around", CommandOptionType.NoValue);
|
||||
|
||||
// This is required to be an option because otherwise we can't tell if the first argument is a project or the first argument to pass to an application
|
||||
var project = app.Option("-p|--project <PROJECT_PATH>", "The path to the project to run (defaults to the current directory). Can be a path to a project.json or a project directory.", CommandOptionType.SingleValue);
|
||||
|
||||
app.OnExecute(() =>
|
||||
|
@ -108,10 +110,22 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
}
|
||||
}
|
||||
|
||||
// Locate the runtime
|
||||
string runtime = Environment.GetEnvironmentVariable("DOTNET_HOME");
|
||||
if (string.IsNullOrEmpty(runtime))
|
||||
{
|
||||
// Use the runtime deployed with the tools, if present
|
||||
var candidate = Path.Combine(AppContext.BaseDirectory, "..", "runtime");
|
||||
if (File.Exists(Path.Combine(candidate, Constants.LibCoreClrName)))
|
||||
{
|
||||
runtime = Path.GetFullPath(candidate);
|
||||
}
|
||||
}
|
||||
|
||||
result = Command.Create(outputName, string.Join(" ", remainingArguments))
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.EnvironmentVariable("CLRHOST_CLR_PATH", AppContext.BaseDirectory)
|
||||
.EnvironmentVariable("DOTNET_HOME", runtime)
|
||||
.Execute();
|
||||
|
||||
// Clean up
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
{
|
||||
"name": "dotnet-run",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
{
|
||||
"name": "dotnet-run",
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
"System.Diagnostics.Process": "4.1.0-beta-23504",
|
||||
"System.IO.FileSystem": "4.0.1-beta-23504",
|
||||
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Net.Compilers.netcore": "1.2.0-beta-20151111-02"
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.Net.Compilers.netcore": "1.2.0-beta-20151111-02"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ bool ends_with(const pal::string_t& value, const pal::string_t& suffix);
|
|||
pal::string_t get_executable(const pal::string_t& filename);
|
||||
pal::string_t get_directory(const pal::string_t& path);
|
||||
pal::string_t get_filename(const pal::string_t& path);
|
||||
bool find_coreclr(const pal::string_t& appbase, pal::string_t& recv);
|
||||
void append_path(pal::string_t& path1, const pal::char_t* path2);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,7 +16,7 @@ void display_help()
|
|||
_X("Usage: " HOST_EXE_NAME " [ASSEMBLY] [ARGUMENTS]\n")
|
||||
_X("Execute the specified managed assembly with the passed in arguments\n\n")
|
||||
_X("The Host's behavior can be altered using the following environment variables:\n")
|
||||
_X(" CLRHOST_CLR_PATH Set the directory which contains the CoreCLR runtime. Overrides all other values for CLR search paths\n")
|
||||
_X(" DOTNET_HOME Set the dotnet home directory. The CLR is expected to be in the runtime subdirectory of this directory. Overrides all other values for CLR search paths\n")
|
||||
_X(" CLRHOST_TRACE Set to affect trace levels (0 = Errors only (default), 1 = Warnings, 2 = Info, 3 = Verbose)\n");
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,14 @@ bool parse_arguments(const int argc, const pal::char_t* argv[], arguments_t& arg
|
|||
}
|
||||
|
||||
// Read CLR path from environment variable
|
||||
pal::getenv(_X("CLRHOST_CLR_PATH"), args.clr_path);
|
||||
pal::string_t home_str;
|
||||
pal::getenv(_X("DOTNET_HOME"), home_str);
|
||||
if (!home_str.empty())
|
||||
{
|
||||
append_path(home_str, _X("runtime"));
|
||||
append_path(home_str, _X("coreclr"));
|
||||
args.clr_path.assign(home_str);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -183,14 +183,22 @@ int main(const int argc, const pal::char_t* argv[])
|
|||
auto app_base = get_directory(args.managed_application);
|
||||
auto app_name = get_filename(args.managed_application);
|
||||
|
||||
// App-local coreclr wins
|
||||
{
|
||||
pal::string_t candidate;
|
||||
candidate.assign(app_base);
|
||||
append_path(candidate, LIBCORECLR_NAME);
|
||||
|
||||
if (pal::file_exists(candidate))
|
||||
{
|
||||
args.clr_path.assign(app_base);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.clr_path.empty())
|
||||
{
|
||||
// Use the directory containing the managed assembly
|
||||
if (!find_coreclr(app_base, args.clr_path))
|
||||
{
|
||||
trace::error(_X("failed to locate CLR files"));
|
||||
return 1;
|
||||
}
|
||||
trace::error(_X("failed to locate CLR files, set the DOTNET_HOME environment variable"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!pal::realpath(args.clr_path))
|
||||
|
|
|
@ -2,41 +2,8 @@
|
|||
|
||||
bool ends_with(const pal::string_t& value, const pal::string_t& suffix)
|
||||
{
|
||||
return (0 == value.compare(value.length() - suffix.length(), suffix.length(), suffix));
|
||||
}
|
||||
|
||||
bool find_coreclr(const pal::string_t& appbase, pal::string_t& recv)
|
||||
{
|
||||
pal::string_t candidate;
|
||||
// Check if it exists in the appbase
|
||||
candidate.assign(appbase);
|
||||
append_path(candidate, LIBCORECLR_NAME);
|
||||
if (pal::file_exists(candidate))
|
||||
{
|
||||
recv.assign(appbase);
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Have a cleaner search strategy that supports multiple versions
|
||||
// Search the PATH
|
||||
pal::string_t path;
|
||||
if (!pal::getenv(_X("PATH"), path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pal::stringstream_t path_stream(path);
|
||||
pal::string_t entry;
|
||||
while (std::getline(path_stream, entry, PATH_SEPARATOR))
|
||||
{
|
||||
candidate.assign(entry);
|
||||
append_path(candidate, LIBCORECLR_NAME);
|
||||
if (pal::file_exists(candidate))
|
||||
{
|
||||
recv.assign(entry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return suffix.length() <= value.length() &&
|
||||
(0 == value.compare(value.length() - suffix.length(), suffix.length(), suffix));
|
||||
}
|
||||
|
||||
void append_path(pal::string_t& path1, const pal::char_t* path2)
|
||||
|
|
Loading…
Reference in a new issue