Pulling in BuildTools into CLI via the build

This commit is contained in:
Jonathan Miller 2016-07-07 17:48:25 -07:00
parent 36c9a04153
commit ea9a41b81c
4 changed files with 85 additions and 2 deletions

3
.gitignore vendored
View file

@ -37,6 +37,9 @@ cmake/
# stage0 install directory
.dotnet_stage0
# build tools directory
build_tools
# `dotnet new` template zip files are generated by a pre-build step.
/src/dotnet/commands/dotnet-new/*.zip

1
BuildToolsVersion.txt Normal file
View file

@ -0,0 +1 @@
1.0.26-prerelease-00607-01

View file

@ -12,4 +12,52 @@ $RepoRoot = "$PSScriptRoot"
Write-Host "Installing .NET Core CLI Stage 0 from branchinfo channel"
& "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel $env:CHANNEL -Architecture $Architecture -Verbose
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Setup BuildTools vars
$BUILD_TOOLS_VERSION = Get-Content "$RepoRoot\BuildToolsVersion.txt"
$BUILD_TOOLS_PATH=$RepoRoot + "\build_tools"
$BUILD_TOOLS_SOURCE='https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json'
$BUILD_TOOLS_SEMAPHORE=$BUILD_TOOLS_PATH + "\init-tools.completed"
$INIT_TOOLS_LOG=$RepoRoot + "\init-tools.log"
$PROJECT_JSON_FILE=$BUILD_TOOLS_PATH + "\project.json"
$PROJECT_JSON_CONTENTS="{ `"dependencies`": { `"Microsoft.DotNet.BuildTools`": `"" + $BUILD_TOOLS_VERSION + "`" }, `"frameworks`": { `"netcoreapp1.0`": { } } }"
$PACKAGES_DIR=$RepoRoot + "\.nuget\packages"
$BUILD_TOOLS_PACKAGE_PATH=$PACKAGES_DIR + "\Microsoft.DotNet.BuildTools\" + $BUILD_TOOLS_VERSION + "\lib"
$DOTNET_EXE_CMD=$env:DOTNET_INSTALL_DIR + "\dotnet.exe"
# If build tools are already installed, escape
if (Test-Path "$BUILD_TOOLS_SEMAPHORE")
{
Write-Host "Tools are already initialized"
exit 0
}
# Check for build tools
if (!(Test-Path "$BUILD_TOOLS_PATH"))
{
mkdir "$BUILD_TOOLS_PATH" | Out-Null
}
# Write the build tools project.json file
"$PROJECT_JSON_CONTENTS" | Set-Content "$PROJECT_JSON_FILE"
# Restore build tools
$args="restore $PROJECT_JSON_FILE --packages $PACKAGES_DIR --source $BUILD_TOOLS_SOURCE"
Start-Process -FilePath $DOTNET_EXE_CMD -ArgumentList $args -Wait -RedirectStandardOutput $INIT_TOOLS_LOG -NoNewWindow
if (!(Test-Path "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd"))
{
Write-Host "ERROR: Could not restore build tools correctly. See '$INIT_TOOLS_LOG' for more details"
exit 1
}
# Initialize build tools
cmd /c "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd $RepoRoot $env:DOTNET_INSTALL_DIR\dotnet.exe $BUILD_TOOLS_PATH" >> "$INIT_TOOLS_LOG"
Write-Host "Done initializing tools."
Write-Host "Init-Tools completed for BuildTools Version: $BUILD_TOOLS_VERSION" > $BUILD_TOOLS_SEMAPHORE

View file

@ -14,4 +14,35 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
$DIR/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose
$DIR/scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose
__init_tools_log=$DIR/init-tools.log
__DOTNET_CMD=$DOTNET_INSTALL_DIR/dotnet
__BUILD_TOOLS_DIR=$DIR/build_tools
__BUILD_TOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
__BUILD_TOOLS_PACKAGE_VERSION=$(cat $DIR/BuildToolsVersion.txt)
__BUILD_TOOLS_PATH=$NUGET_PACKAGES/Microsoft.DotNet.BuildTools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
__BUILD_TOOLS_SEMAPHORE=$__BUILD_TOOLS_DIR/init-tools.completed
__PROJECT_JSON_PATH=$__BUILD_TOOLS_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
__PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json
__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }"
if [ ! -e "$__PROJECT_JSON_FILE" ]; then
mkdir -p "$__PROJECT_JSON_PATH"
echo "$__PROJECT_JSON_CONTENTS" > "$__PROJECT_JSON_FILE"
if [ ! -d "$__BUILD_TOOLS_PATH" ]; then
echo "Restoring build tools version $__BUILD_TOOLS_PACKAGE_VERSION..."
"$__DOTNET_CMD" restore "$__PROJECT_JSON_FILE" --packages "$NUGET_PACKAGES" --source "$__BUILD_TOOLS_SOURCE" >> "$__init_tools_log" 2>&1
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."; fi
fi
echo "Initializing build tools..."
"$__BUILD_TOOLS_PATH/init-tools.sh" "$DIR" "$__DOTNET_CMD" "$__BUILD_TOOLS_DIR" >> "$__init_tools_log" 2>&1
echo "Init-Tools completed for BuildTools Version: $__BUILD_TOOLS_PACKAGE_VERSION" > "$__BUILD_TOOLS_SEMAPHORE"
echo "Done initializing tools"
else
echo "Tools are already initialized"
fi