Skip to content

Commit 1fe03e2

Browse files
[main] Bump to .NET 10 RC 1 (#1278)
Updated: * .NET 9.0.305 * .NET 10.0.100-rc.1.25451.107 Other changes: * Added a new `install-java.yml` template to automate downloading and installing Microsoft JDK 21 on both Windows and macOS agents, setting environment variables for use in subsequent steps. * Updated `provision-android.csproj` to include installation of `build-tools/35.0.0` and `platforms/android-34` for Gradle projects, expanding the base dependencies for Android builds.
1 parent b6d8768 commit 1fe03e2

File tree

4 files changed

+112
-59
lines changed

4 files changed

+112
-59
lines changed

build/ci/install-java.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
parameters:
2+
jdkVersion: '21.0.8'
3+
jdkDestinationDirectory: $(Agent.ToolsDirectory)/jdk21
4+
5+
steps:
6+
- pwsh: |
7+
$ErrorActionPreference = 'Stop'
8+
$jdkVersion = "${{ parameters.jdkVersion }}"
9+
$destinationDir = "${{ parameters.jdkDestinationDirectory }}"
10+
11+
# Download JDK
12+
if ($IsWindows) {
13+
$url = "https://aka.ms/download-jdk/microsoft-jdk-$jdkVersion-windows-x64.zip"
14+
} else {
15+
$url = "https://aka.ms/download-jdk/microsoft-jdk-$jdkVersion-macos-x64.tar.gz"
16+
}
17+
18+
$fileName = [System.IO.Path]::GetFileName($url)
19+
Write-Host "Downloading JDK from: $url"
20+
Invoke-WebRequest -Uri $url -OutFile $fileName
21+
22+
# Clean and create destination directory
23+
if (Test-Path $destinationDir) {
24+
Write-Host "Cleaning existing directory: $destinationDir"
25+
Remove-Item $destinationDir -Recurse -Force
26+
}
27+
New-Item -ItemType Directory -Path $destinationDir -Force | Out-Null
28+
29+
# Extract archive
30+
Write-Host "Extracting JDK to: $destinationDir"
31+
if ($IsWindows) {
32+
Expand-Archive -Path $fileName -DestinationPath $destinationDir -Force
33+
} else {
34+
& tar -xzf $fileName -C $destinationDir
35+
if ($LASTEXITCODE -ne 0) {
36+
throw "Failed to extract JDK archive"
37+
}
38+
}
39+
40+
# Find JAVA_HOME - look for directory with bin folder or Contents/Home
41+
$jdkDir = Get-ChildItem -Path $destinationDir -Directory | Select-Object -First 1
42+
if (-not $jdkDir) {
43+
throw "No directory found in extracted JDK archive at: $destinationDir"
44+
}
45+
46+
# Check for macOS structure (jdk-version/Contents/Home)
47+
$contentsHome = Join-Path $jdkDir.FullName "Contents" "Home"
48+
if (Test-Path $contentsHome) {
49+
$javaHome = $contentsHome
50+
}
51+
# Check for directory with bin folder
52+
elseif (Test-Path (Join-Path $jdkDir.FullName "bin")) {
53+
$javaHome = $jdkDir.FullName
54+
}
55+
# Fallback to destination directory
56+
else {
57+
$javaHome = $destinationDir
58+
}
59+
60+
# Verify bin directory exists
61+
$binPath = Join-Path $javaHome "bin"
62+
if (-not (Test-Path $binPath)) {
63+
throw "JDK bin directory not found at: $binPath"
64+
}
65+
66+
Write-Host "JDK installed at: $javaHome"
67+
68+
# Set environment variables
69+
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$javaHome"
70+
Write-Host "##vso[task.setvariable variable=JAVA_HOME_21_X64]$javaHome"
71+
Write-Host "##vso[task.prependpath]$binPath"
72+
73+
# Verify installation by calling java directly with full path
74+
$javaExe = if ($IsWindows) { Join-Path $binPath "java.exe" } else { Join-Path $binPath "java" }
75+
76+
if (-not (Test-Path $javaExe)) {
77+
throw "Java executable not found at: $javaExe"
78+
}
79+
80+
Write-Host "Java version:"
81+
& $javaExe -version
82+
if ($LASTEXITCODE -ne 0) {
83+
throw "Failed to execute java -version"
84+
}
85+
displayName: Install Java ${{ parameters.jdkVersion }} SDK
86+
workingDirectory: $(Build.StagingDirectory)

build/ci/setup-environment.yml

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
22
installAndroidDependencies: false
33
androidSdkRoot: $(Agent.TempDirectory)/android-sdk
4-
javaSdkRoot: $(Agent.ToolsDirectory)\jdk21
4+
javaSdkRoot: $(Agent.ToolsDirectory)/jdk21
55

66
steps:
77
# before the build starts, make sure the tooling is as expected. Clear the cache on shared agents
@@ -44,31 +44,10 @@ steps:
4444
}
4545
displayName: Install .NET Workloads
4646
47-
- bash: |
48-
if [[ -n "$JAVA_HOME_21_X64" && -d "$JAVA_HOME_21_X64" ]]; then
49-
echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_21_X64"
50-
else
51-
JDK_DIR="$(Agent.ToolsDirectory)/jdk-21"
52-
TEMP_FILE="$(Agent.TempDirectory)/microsoft-jdk-21.tar.gz"
53-
if [[ ! -d "$JDK_DIR" || ! -f "$JDK_DIR/bin/java" ]]; then
54-
echo "Downloading Microsoft JDK 21 for macOS..."
55-
mkdir -p "$JDK_DIR"
56-
curl -L "https://aka.ms/download-jdk/microsoft-jdk-21.0.8-macos-x64.tar.gz" -o "$TEMP_FILE"
57-
tar -xzf "$TEMP_FILE" -C "$JDK_DIR" --strip-components=4
58-
rm "$TEMP_FILE"
59-
fi
60-
echo "##vso[task.setvariable variable=JAVA_HOME]$JDK_DIR"
61-
fi
62-
displayName: Use Java 21 SDK (Mac)
63-
condition: eq( variables['Agent.OS'], 'Darwin' )
64-
65-
- task: JavaToolInstaller@0
66-
displayName: Use Java 21 SDK (Windows)
67-
condition: and(eq( variables['Agent.OS'], 'Windows_NT' ), ne(${{ parameters.installAndroidDependencies }}, true))
68-
inputs:
69-
versionSpec: '21'
70-
jdkArchitectureOption: 'x64'
71-
jdkSourceOption: 'PreInstalled'
47+
- template: install-java.yml
48+
parameters:
49+
jdkVersion: '21.0.8'
50+
jdkDestinationDirectory: ${{ parameters.javaSdkRoot }}
7251

7352
- pwsh: |
7453
if (Test-Path "${{ parameters.androidSdkRoot }}") {
@@ -78,17 +57,6 @@ steps:
7857
displayName: Clean and create Android SDK directory
7958
condition: eq(${{ parameters.installAndroidDependencies }}, true)
8059
81-
- task: DotNetCoreCLI@2
82-
displayName: Install android dependencies GoogleV2
83-
inputs:
84-
command: build
85-
projects: build/scripts/provision-android/provision-android.csproj
86-
arguments: >-
87-
-t:InstallAndroidDependencies -p:AcceptAndroidSdkLicenses=true -p:AndroidManifestType=GoogleV2
88-
-p:AndroidSdkDirectory=${{ parameters.androidSdkRoot }}
89-
-v:n -bl:output/install-android-dependencies-GoogleV2.binlog
90-
retryCountOnTaskFailure: 3
91-
9260
- task: DotNetCoreCLI@2
9361
displayName: Install android dependencies Xamarin
9462
inputs:
@@ -100,30 +68,26 @@ steps:
10068
-v:n -bl:output/install-android-dependencies-Xamarin.binlog
10169
retryCountOnTaskFailure: 3
10270

71+
- pwsh: |
72+
$ErrorActionPreference = 'Stop'
73+
$sdkManager = Join-Path "${{ parameters.androidSdkRoot }}" "cmdline-tools" "latest" "bin" "sdkmanager"
74+
if ($IsWindows) {
75+
$sdkManager += ".bat"
76+
}
77+
78+
if (Test-Path $sdkManager) {
79+
Write-Host "Accepting Android SDK licenses..."
80+
Write-Host "y" | & $sdkManager --licenses --sdk_root="${{ parameters.androidSdkRoot }}"
81+
} else {
82+
Write-Host "SDK Manager not found at: $sdkManager"
83+
}
84+
displayName: Accept Android SDK licenses
85+
condition: eq(${{ parameters.installAndroidDependencies }}, true)
86+
10387
- pwsh: |
10488
Write-Host "##vso[task.setvariable variable=AndroidSdkDirectory]${{ parameters.androidSdkRoot }}"
10589
Write-Host "##vso[task.setvariable variable=ANDROID_SDK_ROOT]${{ parameters.androidSdkRoot }}"
10690
Write-Host "##vso[task.setvariable variable=ANDROID_HOME]${{ parameters.androidSdkRoot }}"
10791
displayName: Set ANDROID_SDK_ROOT and ANDROID_HOME to ${{ parameters.androidSdkRoot }}
10892
109-
- ${{ if eq(parameters.installAndroidDependencies, true) }}:
110-
- pwsh: |
111-
$url = "https://aka.ms/download-jdk/microsoft-jdk-21.0.8-windows-x64.zip"
112-
if ($IsMacOS) {
113-
$url = "https://aka.ms/download-jdk/microsoft-jdk-21.0.8-macos-x64.tar.gz"
114-
}
115-
$fileName = [System.IO.Path]::GetFileName($url)
116-
Invoke-WebRequest -Uri $url -OutFile $fileName
117-
Write-Host "##vso[task.setvariable variable=JDK_21_FILE_PATH]$(Build.StagingDirectory)/$fileName"
118-
displayName: Download Java 21 SDK
119-
workingDirectory: $(Build.StagingDirectory)
12093
121-
- task: JavaToolInstaller@0
122-
displayName: Use Java 21 SDK
123-
inputs:
124-
versionSpec: '21'
125-
jdkArchitectureOption: 'x64'
126-
jdkSourceOption: LocalDirectory
127-
jdkFile: $(JDK_21_FILE_PATH)
128-
jdkDestinationDirectory: ${{ parameters.javaSdkRoot }}
129-
cleanDestinationDirectory: true

build/ci/variables.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variables:
1919
macosAgentPoolName: VSEng-VSMac-Xamarin-Shared # macOS VM pool name
2020

2121
# Tool variables
22-
dotnetVersion: '9.0.303' # .NET version to install on agent
22+
dotnetVersion: '9.0.305' # .NET version to install on agent
2323
dotnetFrameworkVersion: 9 # The number to use for TF (eg: netX.0-android)
2424
dotnetNuGetOrgSource: 'https://api.nuget.org/v3/index.json' # NuGet.org URL to find workloads
2525

@@ -34,7 +34,7 @@ variables:
3434
extendedTestAssembly: tests/extended/bin/$(configuration)/net$(dotnetFrameworkVersion).0/ExtendedTests.dll # Extended tests compiled binary
3535

3636
# dotnet-next test variables
37-
dotnetNextVersion: 10.0.100-preview.6.25358.103 # .NET preview version to install
37+
dotnetNextVersion: 10.0.100-rc.1.25451.107 # .NET preview version to install
3838
dotnetNextFrameworkVersion: 10 # The number to use for TF (eg: netX.0-android)
3939

4040
# dnceng-public variables

build/scripts/provision-android/provision-android.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<TargetFramework>$(_DefaultTargetFrameworkNext)</TargetFramework>
55
</PropertyGroup>
66
<ItemGroup>
7+
<!-- Used by gradle projects -->
8+
<AndroidDependency Include="build-tools/35.0.0" />
9+
<AndroidDependency Include="platforms/android-34" />
710
<!-- But also install the base -->
811
<AndroidDependency Include="platforms/android-$(_DefaultPlatformVersionBase)" />
912
</ItemGroup>

0 commit comments

Comments
 (0)