diff --git a/.azure-pipelines/build-job.yml b/.azure-pipelines/build-job.yml index 76d4b4977f..fbe90d833f 100644 --- a/.azure-pipelines/build-job.yml +++ b/.azure-pipelines/build-job.yml @@ -84,10 +84,10 @@ jobs: ${{ if eq(parameters.targetFramework, 'all') }}: strategy: matrix: - NET6.0: - targetFramework: 'net6.0' NET8.0: targetFramework: 'net8.0' + NET10.0: + targetFramework: 'net10.0' ${{ if ne(parameters.container, '') }}: diff --git a/.azure-pipelines/pipeline.yml b/.azure-pipelines/pipeline.yml index 533c4d1cea..5ec3b57b8f 100644 --- a/.azure-pipelines/pipeline.yml +++ b/.azure-pipelines/pipeline.yml @@ -113,10 +113,10 @@ extends: ${{ if eq(parameters.targetFramework, 'all') }}: strategy: matrix: - NET6.0: - targetFramework: 'net6.0' NET8.0: targetFramework: 'net8.0' + NET10.0: + targetFramework: 'net10.0' pool: name: 1ES-ABTT-Shared-Pool image: abtt-ubuntu-2404 diff --git a/.vsts.ci.yml b/.vsts.ci.yml index db5383ee84..fc146f0f9f 100644 --- a/.vsts.ci.yml +++ b/.vsts.ci.yml @@ -61,7 +61,7 @@ extends: publishArtifacts: ${{ ne(variables['Build.Reason'], 'PullRequest') }} buildAlternatePackage: false testProxyAgent: ${{ parameters.testProxyAgent }} - targetFramework: 'net8.0' + targetFramework: 'all' win_x64: ${{ parameters.win_x64 }} win_x86: ${{ parameters.win_x86 }} win_arm64: ${{ parameters.win_arm64 }} diff --git a/.vsts.release.yml b/.vsts.release.yml index 8a0a4fba98..c22f740607 100644 --- a/.vsts.release.yml +++ b/.vsts.release.yml @@ -27,9 +27,10 @@ parameters: - name: targetFramework displayName: Target framework type: string - default: net8.0 + default: net10.0 values: - net8.0 + - net10.0 - name: derivedFrom type: string @@ -145,9 +146,9 @@ extends: ## 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 (("${{ parameters.targetFramework }}" -eq "net8.0" -and $majorVersion -ne "4") -or + ("${{ parameters.targetFramework }}" -eq "net10.0" -and $majorVersion -ne "5")) { + Write-Error "The major version should be 4 for net8.0 and 5 for net10.0" -ErrorAction Stop } } if ($isTestRun) { diff --git a/src/Agent.Listener/Agent.Listener.csproj b/src/Agent.Listener/Agent.Listener.csproj index 2ba302e683..054af5d767 100644 --- a/src/Agent.Listener/Agent.Listener.csproj +++ b/src/Agent.Listener/Agent.Listener.csproj @@ -17,15 +17,15 @@ - + - - - + + + diff --git a/src/Agent.PluginHost/Agent.PluginHost.csproj b/src/Agent.PluginHost/Agent.PluginHost.csproj index a1f399343b..82ed710e7c 100644 --- a/src/Agent.PluginHost/Agent.PluginHost.csproj +++ b/src/Agent.PluginHost/Agent.PluginHost.csproj @@ -11,12 +11,12 @@ - + - - - + + + diff --git a/src/Agent.Plugins/Agent.Plugins.csproj b/src/Agent.Plugins/Agent.Plugins.csproj index 1d88f68007..a6ff5413af 100644 --- a/src/Agent.Plugins/Agent.Plugins.csproj +++ b/src/Agent.Plugins/Agent.Plugins.csproj @@ -17,8 +17,8 @@ - - - + + + diff --git a/src/Agent.Sdk/Agent.Sdk.csproj b/src/Agent.Sdk/Agent.Sdk.csproj index dd8f45e512..1b8c808421 100644 --- a/src/Agent.Sdk/Agent.Sdk.csproj +++ b/src/Agent.Sdk/Agent.Sdk.csproj @@ -8,21 +8,21 @@ - + - + - - - + + + - + \ No newline at end of file diff --git a/src/Agent.Worker/Agent.Worker.csproj b/src/Agent.Worker/Agent.Worker.csproj index 1beec9b6c7..8838dea66e 100644 --- a/src/Agent.Worker/Agent.Worker.csproj +++ b/src/Agent.Worker/Agent.Worker.csproj @@ -18,8 +18,8 @@ - - - + + + diff --git a/src/Common.props b/src/Common.props index 19c298e182..d91a621ce8 100644 --- a/src/Common.props +++ b/src/Common.props @@ -1,7 +1,10 @@ 10.0 - net8.0;net6.0 + $(NetTargetFramework) + net10.0 + $(NetRuntimeFrameworkVersion) + 10.0.1 $(PackageRuntime) true true diff --git a/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj b/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj index a48413526f..c582c3edd1 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj +++ b/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj @@ -12,17 +12,18 @@ - + - - + + - - + + + diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index 855520ce47..eefe3aa47b 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -16,9 +16,13 @@ - - - + + + + + build + diff --git a/src/dev.sh b/src/dev.sh index 6895eae56c..7c5ae80355 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -20,7 +20,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/.helpers.sh" -REPO_ROOT="${SCRIPT_DIR}/.." +# Resolve REPO_ROOT to absolute path without '..' for proper runtime resolution +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" AGENT_VERSION=$(cat "$SCRIPT_DIR/agentversion" | head -n 1 | tr -d "\n\r") DOTNET_ERROR_PREFIX="##vso[task.logissue type=error]" @@ -34,25 +35,32 @@ fi pushd "$SCRIPT_DIR" -DEFAULT_TARGET_FRAMEWORK="net8.0" +DEFAULT_TARGET_FRAMEWORK="net10.0" if [[ $TARGET_FRAMEWORK == "" ]]; then TARGET_FRAMEWORK=$DEFAULT_TARGET_FRAMEWORK fi +# Validate target framework - only allow known values +ALLOWED_FRAMEWORKS=("net8.0" "net10.0") +if [[ ! " ${ALLOWED_FRAMEWORKS[*]} " =~ " ${TARGET_FRAMEWORK} " ]]; then + failed "Invalid target framework '${TARGET_FRAMEWORK}'. Allowed values: ${ALLOWED_FRAMEWORKS[*]}" +fi + function get_net_version() { local dotnet_versions=" - net6.0-sdk=6.0.424 - net6.0-runtime=6.0.32 - + net8.0-sdk=8.0.416 net8.0-runtime=8.0.22 + + net10.0-sdk=10.0.101 + net10.0-runtime=10.0.1 " echo "$dotnet_versions" | grep -o "$1=[^ ]*" | cut -d '=' -f2 } -DOTNET_SDK_VERSION=$(get_net_version "net8.0-sdk") +DOTNET_SDK_VERSION=$(get_net_version "${TARGET_FRAMEWORK}-sdk") DOTNET_RUNTIME_VERSION=$(get_net_version "${TARGET_FRAMEWORK}-runtime") if [[ ($DOTNET_SDK_VERSION == "") || ($DOTNET_RUNTIME_VERSION == "") ]]; then @@ -115,23 +123,26 @@ function restore_sdk_and_runtime() { function warn_about_newer_versions() { echo "" + # Extract major version from TARGET_FRAMEWORK (e.g., net10.0 -> 10.0, net8.0 -> 8.0) + local dotnet_major_version="${TARGET_FRAMEWORK#net}" + # Use official .NET APIs to get latest versions local latest_sdk latest_runtime local sdk_outdated=false local runtime_outdated=false # Get latest SDK version from official .NET feed - latest_sdk=$(curl -s "https://builds.dotnet.microsoft.com/dotnet/Sdk/8.0/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "") + latest_sdk=$(curl -s "https://builds.dotnet.microsoft.com/dotnet/Sdk/${dotnet_major_version}/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "") if [[ -z "$latest_sdk" ]]; then # Fallback to backup feed - latest_sdk=$(curl -s "https://ci.dot.net/public/Sdk/8.0/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "$DOTNET_SDK_VERSION") + latest_sdk=$(curl -s "https://ci.dot.net/public/Sdk/${dotnet_major_version}/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "$DOTNET_SDK_VERSION") fi # Get latest Runtime version from official .NET feed - latest_runtime=$(curl -s "https://builds.dotnet.microsoft.com/dotnet/Runtime/8.0/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "") + latest_runtime=$(curl -s "https://builds.dotnet.microsoft.com/dotnet/Runtime/${dotnet_major_version}/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "") if [[ -z "$latest_runtime" ]]; then # Fallback to backup feed - latest_runtime=$(curl -s "https://ci.dot.net/public/Runtime/8.0/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "$DOTNET_RUNTIME_VERSION") + latest_runtime=$(curl -s "https://ci.dot.net/public/Runtime/${dotnet_major_version}/latest.version" 2>/dev/null | tail -n 1 | tr -d '\r\n' || echo "$DOTNET_RUNTIME_VERSION") fi # Check SDK version @@ -145,7 +156,7 @@ function warn_about_newer_versions() { fi if [[ "$sdk_outdated" == "true" || "$runtime_outdated" == "true" ]]; then - echo "⚠️ WARNING: Newer .NET 8.0 versions available:" >&2 + echo "⚠️ WARNING: Newer .NET ${dotnet_major_version} versions available:" >&2 if [[ "$sdk_outdated" == "true" ]]; then echo " SDK: $latest_sdk (currently using $DOTNET_SDK_VERSION)" >&2 fi @@ -389,7 +400,7 @@ function cmd_report() { # for some reason CodeCoverage.exe will only write the output file in the current directory pushd $COVERAGE_REPORT_DIR >/dev/null - "${HOME}/.nuget/packages/microsoft.codecoverage/16.4.0/build/netstandard1.0/CodeCoverage/CodeCoverage.exe" analyze "/output:coverage.xml" "$LATEST_COVERAGE_FILE" + "${HOME}/.nuget/packages/microsoft.codecoverage/18.0.1/build/netstandard1.0/CodeCoverage/CodeCoverage.exe" analyze "/output:coverage.xml" "$LATEST_COVERAGE_FILE" popd >/dev/null if ! command -v reportgenerator.exe >/dev/null; then @@ -483,11 +494,25 @@ REPORT_DIR="${REPO_ROOT}/_reports/${RUNTIME_ID}" restore_dotnet_install_script restore_sdk_and_runtime + heading ".NET SDK to path" echo "Adding .NET SDK to PATH (${DOTNET_DIR})" -export PATH=${DOTNET_DIR}:$PATH +export PATH=${DOTNET_DIR}/sdk/${DOTNET_SDK_VERSION}:${DOTNET_DIR}:$PATH export PATH=${NUGET_DIR}:$PATH + +# Set DOTNET_ROOT - on Windows, convert to Windows-style path for native dotnet commands +if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then + # Convert /c/path to C:\path format for Windows + dotnet_root_windows=${DOTNET_DIR:1} + dotnet_root_windows=${dotnet_root_windows:0:1}:${dotnet_root_windows:1} + dotnet_root_windows=$(echo "$dotnet_root_windows" | sed 's|/|\\|g') + export DOTNET_ROOT="$dotnet_root_windows" +else + export DOTNET_ROOT=${DOTNET_DIR} +fi + echo "Path = $PATH" +echo "DOTNET_ROOT = $DOTNET_ROOT" echo ".NET Version = $(dotnet --version)" heading "Pre-caching external resources for $RUNTIME_ID" diff --git a/src/dir.proj b/src/dir.proj index d4368522f4..a70d81baf0 100644 --- a/src/dir.proj +++ b/src/dir.proj @@ -66,21 +66,22 @@ BuildInParallel="false" Projects="@(ProjectFiles)" SkipNonExistentProjects="false" - StopOnFirstFailure="true" /> + StopOnFirstFailure="true" + Properties="NetTargetFramework=$(TargetFramework);NetRuntimeFrameworkVersion=$(RuntimeFrameworkVersion)" /> + Properties="Configuration=$(BUILDCONFIG);PackageRuntime=$(PackageRuntime);Version=$(AgentVersion);RuntimeIdentifier=$(PackageRuntime);PublishDir=$(LayoutRoot)/bin;TreatWarningsAsErrors=$(TreatWarningsAsErrors);NetTargetFramework=$(TargetFramework);NetRuntimeFrameworkVersion=$(RuntimeFrameworkVersion)" /> - - - + + + @@ -91,18 +92,19 @@ BuildInParallel="false" Projects="@(ProjectFiles)" SkipNonExistentProjects="false" - StopOnFirstFailure="true" /> + StopOnFirstFailure="true" + Properties="NetTargetFramework=$(TargetFramework);NetRuntimeFrameworkVersion=$(RuntimeFrameworkVersion)" /> + Properties="Configuration=$(BUILDCONFIG);PackageRuntime=$(PackageRuntime);Version=1.0.0.0;RuntimeIdentifier=$(PackageRuntime);PublishDir=$(L1Root)/bin;NetTargetFramework=$(TargetFramework);NetRuntimeFrameworkVersion=$(RuntimeFrameworkVersion)" /> - - - + + +