Skip to content

Commit

Permalink
Add .NET 8 target framework for building the agent (#4943)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisNikulin5 committed Sep 9, 2024
1 parent 1a3d532 commit 5f97177
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 26 deletions.
23 changes: 18 additions & 5 deletions .azure-pipelines/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ parameters:
- name: container
type: string

- name: targetFramework
type: string

- name: timeoutInMinutes
type: number

Expand Down Expand Up @@ -78,6 +81,14 @@ jobs:
displayName: ${{ parameters.displayName }}
pool: ${{ parameters.pool }}
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
${{ if eq(parameters.targetFramework, 'all') }}:
strategy:
matrix:
NET6.0:
targetFramework: 'net6.0'
NET8.0:
targetFramework: 'net8.0'


${{ if ne(parameters.container, '') }}:
container: ${{ parameters.container }}
Expand All @@ -100,6 +111,8 @@ jobs:
DisableDockerDetector: true
nugetMultiFeedWarnLevel: none
CheckoutBranch: ${{ parameters.branch }}
${{ if ne(parameters.targetFramework, 'all') }}:
targetFramework: ${{ parameters.targetFramework }}
templateContext:
outputs:
- ${{ if or(parameters.unitTests, parameters.functionalTests) }}:
Expand Down Expand Up @@ -150,7 +163,7 @@ jobs:
- task: NuGetAuthenticate@1

# Build agent layout
- script: ${{ variables.devCommand }} layout Release ${{ parameters.os }}-${{ parameters.arch }}
- script: ${{ variables.devCommand }} layout $(targetFramework) Release ${{ parameters.os }}-${{ parameters.arch }}
workingDirectory: src
displayName: Build & Layout Release
retryCountOnTaskFailure: 5
Expand All @@ -175,7 +188,7 @@ jobs:
installationPath: 'C:\Program Files (x86)\dotnet'
env:
PROCESSOR_ARCHITECTURE: x86
- script: ${{ variables.devCommand }} testl0 Debug ${{ parameters.os }}-${{ parameters.arch }}
- script: ${{ variables.devCommand }} testl0 $(targetFramework) Debug ${{ parameters.os }}-${{ parameters.arch }}
workingDirectory: src
displayName: Unit tests
timeoutInMinutes: 5
Expand All @@ -189,7 +202,7 @@ jobs:
version: '6.0.424'
packageType: sdk
performMultiLevelLookup: true
- script: ${{ variables.devCommand }} testl1 Debug ${{ parameters.os }}-${{ parameters.arch }}
- script: ${{ variables.devCommand }} testl1 $(targetFramework) Debug ${{ parameters.os }}-${{ parameters.arch }}
workingDirectory: src
displayName: Functional tests

Expand Down Expand Up @@ -242,11 +255,11 @@ jobs:
flavor: ${{ parameters.arch }}

# Create agent package zip
- script: "${{ variables.devCommand }} package Release ${{ parameters.os }}-${{ parameters.arch }}"
- script: "${{ variables.devCommand }} package $(targetFramework) Release ${{ parameters.os }}-${{ parameters.arch }}"
workingDirectory: src
displayName: Package Release

- script: "${{ variables.devCommand }} hash Release ${{ parameters.os }}-${{ parameters.arch }}"
- script: "${{ variables.devCommand }} hash $(targetFramework) Release ${{ parameters.os }}-${{ parameters.arch }}"
workingDirectory: src
displayName: Hash Package

Expand Down
7 changes: 6 additions & 1 deletion .azure-pipelines/build-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ parameters:
type: string
default: ''

- name: targetFramework
type: string

- name: timeoutInMinutes
type: number
default: 120
Expand Down Expand Up @@ -81,6 +84,7 @@ jobs:
verifySigning: ${{ parameters.verifySigning }}
publishArtifact: ${{ parameters.publishArtifacts }}
packageType: agent
targetFramework: ${{ parameters.targetFramework }}

- ${{ if parameters.buildAlternatePackage }}:
- template: /.azure-pipelines/build-job.yml@self
Expand All @@ -99,4 +103,5 @@ jobs:
sign: ${{ parameters.sign }}
verifySigning: ${{ parameters.verifySigning }}
publishArtifact: ${{ parameters.publishArtifacts }}
packageType: pipelines-agent
packageType: pipelines-agent
targetFramework: ${{ parameters.targetFramework }}
24 changes: 23 additions & 1 deletion .azure-pipelines/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
# This pipeline will be extended to the OneESPT template
parameters:
- name: targetFramework
type: string
default: all
- name: preBuildStages
type: stageList
default: []
Expand Down Expand Up @@ -102,13 +105,22 @@ extends:
- ${{ if parameters.testProxyAgent }}:
- job: test_proxy_agent
displayName: Test Proxy Agent
${{ if eq(parameters.targetFramework, 'all') }}:
strategy:
matrix:
NET6.0:
targetFramework: 'net6.0'
NET8.0:
targetFramework: 'net8.0'
pool:
name: 1ES-ABTT-Shared-Pool
image: abtt-ubuntu-2204
os: linux
variables:
DisableDockerDetector: true
nugetMultiFeedWarnLevel: none
${{ if ne(parameters.targetFramework, 'all') }}:
targetFramework: ${{ parameters.targetFramework }}
timeoutInMinutes: 300
steps:
- template: /.azure-pipelines/get-pat.yml@self
Expand All @@ -120,12 +132,13 @@ extends:
sourceBranch="$(Build.SourceBranch)"
branch="${releaseBranch:-"${sourceBranch}"}"
echo "Canary \"branch\" parameter: \"${branch}\""
echo "Canary \"target_framework\" parameter: \"$(targetFramework)\""
node ./run-and-verify.js \
--projectUrl "$(CANARY_PROJECT_URL)" \
--pipelineId "$(CANARY_PIPELINE_ID)" \
--token "$(ACCESS_TOKEN)" \
--templateParameters "{ \"branch\": \"${branch}\" }"
--templateParameters "{ \"branch\": \"${branch}\", \"target_framework\": \"$(targetFramework)\"}"
displayName: Test Proxy Agent
# Windows (x64)
Expand All @@ -148,6 +161,7 @@ extends:
verifySigning: ${{ parameters.sign }}
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# Windows (x86)
- ${{ if parameters.win_x86 }}:
Expand All @@ -167,6 +181,7 @@ extends:
sign: ${{ parameters.sign }}
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# Linux (x64)
- ${{ if parameters.linux_x64 }}:
Expand All @@ -186,6 +201,7 @@ extends:
sign: ${{ parameters.sign }}
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# Linux (ARM)
- ${{ if parameters.linux_arm }}:
Expand All @@ -206,6 +222,7 @@ extends:
sign: false
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# Linux (ARM64)
- ${{ if parameters.linux_arm64 }}:
Expand All @@ -226,6 +243,7 @@ extends:
sign: false
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# Alpine (x64)
- ${{ if parameters.alpine_x64 }}:
Expand All @@ -246,6 +264,7 @@ extends:
sign: false
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: false
targetFramework: ${{ parameters.targetFramework }}

# Alpine (ARM64)
- ${{ if parameters.alpine_arm64 }}:
Expand All @@ -266,6 +285,7 @@ extends:
sign: false
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: false
targetFramework: ${{ parameters.targetFramework }}

# macOS (x64)
- ${{ if parameters.macOS_x64 }}:
Expand All @@ -286,6 +306,7 @@ extends:
sign: ${{ parameters.sign }}
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}

# macOS (ARM64)
- ${{ if parameters.macOS_arm64 }}:
Expand All @@ -306,4 +327,5 @@ extends:
sign: ${{ parameters.sign }}
publishArtifacts: ${{ parameters.publishArtifacts }}
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}
targetFramework: ${{ parameters.targetFramework }}
- ${{ parameters.postBuildStages }}
15 changes: 15 additions & 0 deletions .vsts.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ parameters:
type: string
displayName: Version
default: 'NotSet'
- name: targetFramework
displayName: Target framework
type: string
default: net6.0
values:
- net6.0
- net8.0
- name: derivedFrom
type: string
displayName: Derived From Version
Expand Down Expand Up @@ -73,6 +80,7 @@ extends:
test: ${{ not(parameters.skipTests) }}
sign: true
publishArtifacts: true
targetFramework: ${{ parameters.targetFramework }}
testProxyAgent: ${{ parameters.testProxyAgent }}
stageDependencies:
- Verify_release
Expand Down Expand Up @@ -138,6 +146,13 @@ extends:
if ($agentVersion -eq 'NotSet') {
Write-Error "Version parameter is required for manual release." -ErrorAction Stop
}
## Verify target framework for specified version
$majorVersion = $agentVersion.Split('.')[0]
if ((${{ parameters.targetFramework }} -eq "net6.0" -and $majorVersion -ne "3") -or
(${{ parameters.targetFramework }} -eq "net8.0" -and $majorVersion -ne "4")) {
Write-Error "The major version should be 3 for net6.0 and 4 for net8.0" -ErrorAction Stop
}
}
if ($isTestRun) {
$agentVersion = '3.000.999'
Expand Down
2 changes: 2 additions & 0 deletions src/Agent.Listener/ValidationHelper/VerificationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public VerificationException(string message, Exception ex)
{
}

#if NET6_0
protected VerificationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
}
4 changes: 2 additions & 2 deletions src/Common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
<RuntimeFrameworkVersion>6.0.32</RuntimeFrameworkVersion>
<TargetFramework>$(NetTargetFramework)</TargetFramework>
<RuntimeFrameworkVersion>$(RuntimeVersion)</RuntimeFrameworkVersion>
<RuntimeIdentifier Condition="'$(BuildingInsideVisualStudio)' != 'true'">$(PackageRuntime)</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
Expand Down
49 changes: 38 additions & 11 deletions src/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@

set -eo pipefail

# .NET version for agent build.
NET_VERSIONS="
net6.0-sdk=6.0.424
net6.0-runtime=6.0.32
net8.0-sdk=8.0.401
net8.0-runtime=8.0.8"

ALL_ARGS=("$@")
DEV_CMD=$1
DEV_CONFIG=$2
DEV_RUNTIME_ID=$3
DEV_TEST_FILTERS=$4
DEV_ARGS=("${ALL_ARGS[@]:4}")
TARGET_FRAMEWORK=$2
DEV_CONFIG=$3
DEV_RUNTIME_ID=$4
DEV_TEST_FILTERS=$5
DEV_ARGS=("${ALL_ARGS[@]:5}")

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "$SCRIPT_DIR/.helpers.sh"

REPO_ROOT="${SCRIPT_DIR}/.."
DOTNETSDK_ROOT="${REPO_ROOT}/_dotnetsdk"
DOTNETSDK_VERSION="6.0.424"
DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION"
AGENT_VERSION=$(cat "$SCRIPT_DIR/agentversion" | head -n 1 | tr -d "\n\r")

DOTNET_ERROR_PREFIX="##vso[task.logissue type=error]"
Expand All @@ -36,6 +42,27 @@ fi

pushd "$SCRIPT_DIR"

DEFAULT_TARGET_FRAMEWORK="net6.0"

if [[ $TARGET_FRAMEWORK == "" ]]; then
TARGET_FRAMEWORK=$DEFAULT_TARGET_FRAMEWORK
fi

function get_net_version ()
{
echo "$NET_VERSIONS" | grep -o "$1=[^ ]*" | cut -d '=' -f2
}

DOTNETSDK_VERSION=$(get_net_version "${TARGET_FRAMEWORK}-sdk")
DOTNETRUNTIME_VERSION=$(get_net_version "${TARGET_FRAMEWORK}-runtime")

if [[ ($DOTNETSDK_VERSION == "") || ($DOTNETRUNTIME_VERSION == "") ]]; then
failed "Incorrect target framework is specified"
fi

DOTNETSDK_ROOT="${REPO_ROOT}/_dotnetsdk"
DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION"

BUILD_CONFIG="Debug"
if [[ "$DEV_CONFIG" == "Release" ]]; then
BUILD_CONFIG="Release"
Expand Down Expand Up @@ -97,12 +124,12 @@ function make_build (){

if [[ "$ADO_ENABLE_LOGISSUE" == "true" ]]; then

dotnet msbuild -t:"${TARGET}" -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:CodeAnalysis="true" \
dotnet msbuild -t:"${TARGET}" -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:CodeAnalysis="true" -p:NetTargetFramework="${TARGET_FRAMEWORK}" -p:RuntimeVersion="${DOTNETRUNTIME_VERSION}" \
| sed -e "/\: warning /s/^/${DOTNET_WARNING_PREFIX} /;" \
| sed -e "/\: error /s/^/${DOTNET_ERROR_PREFIX} /;" \
|| failed build
else
dotnet msbuild -t:"${TARGET}" -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:CodeAnalysis="true" \
dotnet msbuild -t:"${TARGET}" -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:CodeAnalysis="true" -p:NetTargetFramework="${TARGET_FRAMEWORK}" -p:RuntimeVersion="${DOTNETRUNTIME_VERSION}" \
|| failed build
fi

Expand Down Expand Up @@ -149,7 +176,7 @@ function cmd_test_l0 ()
TestFilters="$TestFilters&$DEV_TEST_FILTERS"
fi

dotnet msbuild -t:testl0 -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:TestFilters="${TestFilters}" "${DEV_ARGS[@]}" || failed "failed tests"
dotnet msbuild -t:testl0 -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:TestFilters="${TestFilters}" -p:NetTargetFramework="${TARGET_FRAMEWORK}" "${DEV_ARGS[@]}" || failed "failed tests"
}

function cmd_test_l1 ()
Expand All @@ -171,7 +198,7 @@ function cmd_test_l1 ()
TestFilters="$TestFilters&$DEV_TEST_FILTERS"
fi

dotnet msbuild -t:testl1 -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:TestFilters="${TestFilters}" "${DEV_ARGS[@]}" || failed "failed tests"
dotnet msbuild -t:testl1 -p:PackageRuntime="${RUNTIME_ID}" -p:PackageType="${PACKAGE_TYPE}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:AgentVersion="${AGENT_VERSION}" -p:LayoutRoot="${LAYOUT_DIR}" -p:TestFilters="${TestFilters}" -p:NetTargetFramework="${TARGET_FRAMEWORK}" -p:RuntimeVersion="${DOTNETRUNTIME_VERSION}" "${DEV_ARGS[@]}" || failed "failed tests"
}

function cmd_test ()
Expand Down
Loading

0 comments on commit 5f97177

Please sign in to comment.