diff --git a/.gitignore b/.gitignore index abf7674560..1f91a11604 100644 --- a/.gitignore +++ b/.gitignore @@ -210,3 +210,4 @@ obj-Skia/ coc-settings.json .ccls-cache .ccls +sdk diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 11ef36d43f..bc60f84107 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,19 +4,18 @@ jobs: vmImage: 'ubuntu-20.04' steps: - task: CmdLine@2 - displayName: 'Install Nuke' + displayName: 'Download SDK' inputs: script: | - dotnet tool install --global Nuke.GlobalTool --version 0.24.0 + ./get-sdk.sh - task: CmdLine@2 - displayName: 'Run Nuke' + displayName: 'Run Build' inputs: script: | - export PATH="$PATH:$HOME/.dotnet/tools" + export PATH="`pwd`/sdk:$PATH" dotnet --info printenv - nuke --target CiAzureLinux --configuration=Release - + ./build.sh --target CiAzureLinux --configuration=Release - task: PublishTestResults@2 inputs: testResultsFormat: 'VSTest' @@ -29,11 +28,11 @@ jobs: pool: vmImage: 'macOS-10.15' steps: - - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 3.1.401' + - task: CmdLine@2 + displayName: 'Download SDK' inputs: - version: 3.1.401 - + script: | + ./get-sdk.sh - task: CmdLine@2 displayName: 'Install Mono 5.18' inputs: @@ -45,6 +44,7 @@ jobs: displayName: 'Generate avalonia-native' inputs: script: | + export PATH="`pwd`/sdk:$PATH" cd src/tools/MicroComGenerator; dotnet run -i ../../Avalonia.Native/avn.idl --cpp ../../../native/Avalonia.Native/inc/avalonia-native.h - task: Xcode@5 @@ -58,13 +58,7 @@ jobs: args: '-derivedDataPath ./' - task: CmdLine@2 - displayName: 'Install Nuke' - inputs: - script: | - dotnet tool install --global Nuke.GlobalTool --version 0.24.0 - - - task: CmdLine@2 - displayName: 'Run Nuke' + displayName: 'Run Build' inputs: script: | export COREHOST_TRACE=0 @@ -72,10 +66,10 @@ jobs: export DOTNET_CLI_TELEMETRY_OPTOUT=1 which dotnet dotnet --info - export PATH="$PATH:$HOME/.dotnet/tools" + export PATH="`pwd`/sdk:$PATH" dotnet --info printenv - nuke --target CiAzureOSX --configuration Release --skip-previewer + ./build.sh --target CiAzureOSX --configuration Release --skip-previewer - task: PublishTestResults@2 inputs: diff --git a/build.sh b/build.sh index 7703e90a78..9532b4fbe0 100755 --- a/build.sh +++ b/build.sh @@ -20,57 +20,11 @@ SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) ########################################################################### BUILD_PROJECT_FILE="$SCRIPT_DIR/nukebuild/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR//.tmp" - -DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" -DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" -DOTNET_CHANNEL="Current" export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export NUGET_XMLDOC_MODE="skip" -########################################################################### -# EXECUTION -########################################################################### - -function FirstJsonValue { - perl -nle 'print $1 if m{"'$1'": "([^"\-]+)",?}' <<< ${@:2} -} - -# If global.json exists, load expected version -if [ -f "$DOTNET_GLOBAL_FILE" ]; then - DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) - if [ "$DOTNET_VERSION" == "" ]; then - unset DOTNET_VERSION - fi -fi - -# If dotnet is installed locally, and expected version is not set or installation matches the expected version -if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") || "$SKIP_DOTNET_DOWNLOAD" == "1" ]]; then - export DOTNET_EXE="$(command -v dotnet)" -else - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" - - # Download install script - DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" - mkdir -p "$TEMP_DIRECTORY" - curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" - chmod +x "$DOTNET_INSTALL_FILE" - - # Install by channel or version - if [ -z ${DOTNET_VERSION+x} ]; then - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path - else - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path - fi - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version 3.1.20 --runtime dotnet - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version 3.1.20 --runtime aspnetcore -fi - -export PATH=$DOTNET_DIRECTORY:$PATH - -echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" +dotnet --info -"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]} +dotnet run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]} diff --git a/get-sdk.sh b/get-sdk.sh new file mode 100755 index 0000000000..4427948864 --- /dev/null +++ b/get-sdk.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +SDK_DIR=$SCRIPT_DIR/sdk + +DOTNET_INSTALL_FILE="$SDK_DIR/dotnet-install.sh" +DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" + +DOTNET_VERSION=5.0.302 + +mkdir -p "$SDK_DIR" + +if [ ! -f "$DOTNET_INSTALL_FILE" ]; then + curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" + chmod +x "$DOTNET_INSTALL_FILE" +fi + +"$DOTNET_INSTALL_FILE" --install-dir "$SDK_DIR" --version 5.0.302 +"$DOTNET_INSTALL_FILE" --install-dir "$SDK_DIR" --version 3.1.20 --runtime dotnet +"$DOTNET_INSTALL_FILE" --install-dir "$SDK_DIR" --version 3.1.20 --runtime aspnetcore + +