-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathsetup-environment.yml
More file actions
96 lines (86 loc) · 3.9 KB
/
setup-environment.yml
File metadata and controls
96 lines (86 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
parameters:
dotnetTools: []
runDotnetNextTest: false
installAndroidDependencies: false
androidSdkRoot: C:\Android\android-sdk
javaSdkRoot: $(Agent.ToolsDirectory)\jdk11
steps:
# before the build starts, make sure the tooling is as expected
- task: UseDotNet@2
displayName: 'Use dotnet $(dotnetVersion)'
inputs:
version: $(dotnetVersion)
performMultiLevelLookup: true
includePreviewVersions: true
condition: ne('$(dotnetVersion)', '')
- pwsh: |
dotnet workload install android --verbosity diag --from-rollback-file $(dotnetWorkloadRollbackFile) --source $(dotnetWorkloadSource) --source $(dotnetNuGetOrgSource)
dotnet workload install maui --verbosity diag --from-rollback-file $(dotnetWorkloadRollbackFile) --source $(dotnetWorkloadSource) --source $(dotnetNuGetOrgSource)
if ($LASTEXITCODE -ne 0) {
Write-Host "##vso[task.logissue type=error]Failed to install workloads."
Write-Host "##vso[task.complete result=Failed;]"
exit 0
}
displayName: Install .NET Workloads
- bash: |
if [[ "$(Agent.Name)" == *"Azure Pipelines"* ]]; then
echo "##vso[task.setvariable variable=JAVA_HOME]$(JAVA_HOME_11_X64)"
else
echo "##vso[task.setvariable variable=JAVA_HOME]/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home"
fi
displayName: Use Java 11 SDK (Mac)
condition: eq( variables['Agent.OS'], 'Darwin' )
- task: JavaToolInstaller@0
displayName: Use Java 11 SDK (Windows)
condition: and(eq( variables['Agent.OS'], 'Windows_NT' ), ne(${{ parameters.installAndroidDependencies }}, true))
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- ${{ if eq(parameters.installAndroidDependencies, true) }}:
- task: DotNetCoreCLI@2
displayName: Create android template
inputs:
command: custom
custom: new
arguments: android -o $(Agent.TempDirectory)/TempDroid
- task: DotNetCoreCLI@2
displayName: Install android dependencies
inputs:
command: build
projects: $(Agent.TempDirectory)/TempDroid/TempDroid.csproj
arguments: >-
-t:InstallAndroidDependencies -p:AcceptAndroidSdkLicenses=true
-p:AndroidSdkDirectory=${{ parameters.androidSdkRoot }}
-v:n -bl:output/install-android-dependencies.binlog
retryCountOnTaskFailure: 3
- pwsh: |
Write-Host "##vso[task.setvariable variable=ANDROID_SDK_ROOT]${{ parameters.androidSdkRoot }}"
displayName: Set ANDROID_SDK_ROOT to ${{ parameters.androidSdkRoot }}
- pwsh: |
if ($IsWindows) {
$env:JAVA_HOME = Get-ChildItem -Path "C:\Program Files (x86)\Android\openjdk" -Filter "*jdk*" | Select-Object -First 1
}
$sdkManager = Get-ChildItem -Path "${{ parameters.androidSdkRoot }}\cmdline-tools" -Filter "sdkmanager*" -Recurse | Select-Object -First 1
$yesInput = "y`n" * 10
$yesInput | & $sdkManager --licenses
& $sdkManager "build-tools;29.0.3" "platforms;android-29"
displayName: Install extra Android SDK packages
- pwsh: |
$url = "https://aka.ms/download-jdk/microsoft-jdk-11.0.26-windows-x64.zip"
if ($IsMacOS) {
$url = "https://aka.ms/download-jdk/microsoft-jdk-11.0.26-macos-x64.tar.gz"
}
$fileName = [System.IO.Path]::GetFileName($url)
Invoke-WebRequest -Uri $url -OutFile $fileName
Write-Host "##vso[task.setvariable variable=JDK_11_FILE_PATH]$(Build.StagingDirectory)/$fileName"
displayName: Download Java 11 SDK
workingDirectory: $(Build.StagingDirectory)
- task: JavaToolInstaller@0
displayName: Use Java 11 SDK
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: LocalDirectory
jdkFile: $(JDK_11_FILE_PATH)
jdkDestinationDirectory: ${{ parameters.javaSdkRoot }}