-
Notifications
You must be signed in to change notification settings - Fork 7
/
azure-pipelines.yml
151 lines (125 loc) · 5.65 KB
/
azure-pipelines.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Don't forget to add these secrets/build pipeline variables in your Azure Pipeline:
# - P12_PASSWORD: iOS only. The password for the P12 certificate file to sign the ipa file.
# - APPCENTER_TOKEN_ANDROID: App Center API key that can access the App Center Android app definition.
# - APPCENTER_TOKEN_IOS: App Center API key that can access the App Center iOS app definition.
# More information on the App Center API tokens can be found here: https://learn.microsoft.com/appcenter/api-docs/
# Replace these variables to match your project
variables:
BuildConfiguration: Release
DotNetVersion: 7.0.x
MauiCsprojToBuild: MauiUITestSample/MauiUITestSample.csproj
UITestCsprojToBuild: MyAppTests/MyAppTests.csproj
# Should match the values for the TargetFrameworks node in the .NET MAUI csproj file. Also make sure this matches DotNetVersion.
TfmPrefix: net7.0
# Find this in the ApplicationId node in the .NET MAUI csproj file
AppId: com.companyname.mauiuitestsample
# App Center configuration
AndroidTestDevices: ff8f571c
AndroidAppDefinition: xtc-Xamarin-Forms/MauiTest
AndroidTestSeries: master
iOSTestDevices: 1f1515d2
iOSAppDefinition: xtc-Xamarin-Forms/MauiTest-iOS
iOSTestSeries: master
# These values correspond to files that are uploaded to the Azure Pipeline secure files. Make sure the filenames match here with the uploaded files.
# More information about using secure files can be found here: https://learn.microsoft.com/azure/devops/pipelines/library/secure-files
# More information about obtaining a P12 and provisioning profile file can be found here: https://learn.microsoft.com/dotnet/maui/ios/deployment/publish-app-store
P12_SECURE_FILENAME: Certificates.p12
PROVISIONING_PROFILE_SECURE_FILENAME: MauiUITest.mobileprovision
trigger: none
stages:
- stage: Build_And_UITest_Android
jobs:
- job: Build_And_UITest_Android
displayName: Build .NET MAUI Android App
pool:
vmImage: 'windows-latest'
demands:
- MSBuild
steps:
- task: UseDotNet@2
displayName: Install .NET
inputs:
packageType: 'sdk'
version: '$(DotNetVersion)'
# Setup JDK Paths
- bash: |
echo "##vso[task.setvariable variable=JI_JAVA_HOME]$(JAVA_HOME_11_X64)"
displayName: 'Setup JDK Paths'
- task: CmdLine@2
displayName: Install .NET MAUI Workload
inputs:
script: dotnet workload install maui
- task: CmdLine@2
displayName: Restore NuGet Packages
inputs:
script: dotnet restore
- task: CmdLine@2
displayName: Publish .NET MAUI App
inputs:
script: dotnet publish $(MauiCsprojToBuild) -c $(BuildConfiguration) -f $(TfmPrefix)-android -o $(Build.ArtifactStagingDirectory)
- task: CmdLine@2
displayName: Build UI Test Project
inputs:
script: dotnet build $(UITestCsprojToBuild) -c $(BuildConfiguration)
- task: CmdLine@2
displayName: Install App Center CLI
inputs:
script: npm install --location=global appcenter-cli
- task: CmdLine@2
displayName: Upload App to Test Cloud
inputs:
script: appcenter test run uitest --app "$(AndroidAppDefinition)" --devices $(AndroidTestDevices) --app-path "$(Build.ArtifactStagingDirectory)\\$(AppId)-Signed.apk" --test-series "$(AndroidTestSeries)" --build-dir "MyAppTests/bin/$(BuildConfiguration)/net48/" --uitest-tools-dir "MyAppTests/bin/$(BuildConfiguration)/net48/" --token "$(APPCENTER_TOKEN_ANDROID)" --async
- stage: Build_And_UITest_iOS
dependsOn: []
jobs:
- job: Build_And_UITest_iOS
displayName: Build .NET MAUI iOS App
pool:
vmImage: 'macos-latest'
steps:
- task: InstallAppleCertificate@2
displayName: Install iOS App P12 Certificate
inputs:
certSecureFile: '$(P12_SECURE_FILENAME)'
certPwd: '$(P12_PASSWORD)'
keychain: 'temp'
- task: InstallAppleProvisioningProfile@1
displayName: Install iOS App Provisioning Profile
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '$(PROVISIONING_PROFILE_SECURE_FILENAME)'
- task: UseDotNet@2
displayName: Install .NET
inputs:
packageType: 'sdk'
version: '$(DotNetVersion)'
- task: Bash@3
displayName: Install .NET MAUI Workload
inputs:
targetType: 'inline'
script: dotnet workload install maui
- task: Bash@3
displayName: Restore NuGet Packages
inputs:
targetType: 'inline'
script: dotnet restore
- task: Bash@3
displayName: Publish .NET MAUI iOS App
inputs:
targetType: 'inline'
script: dotnet publish $(MauiCsprojToBuild) -c $(BuildConfiguration) -f $(TfmPrefix)-ios -o $(Build.ArtifactStagingDirectory)
- task: Bash@3
displayName: Build UI Test Project
inputs:
targetType: 'inline'
script: dotnet build $(UITestCsprojToBuild) -c $(BuildConfiguration)
- task: Bash@3
displayName: Install App Center CLI
inputs:
targetType: 'inline'
script: npm install --location=global appcenter-cli
- task: Bash@3
displayName: Upload App to Test Cloud
inputs:
targetType: 'inline'
script: appcenter test run uitest --app "$(iOSAppDefinition)" --devices $(iOSTestDevices) --app-path "$(Build.ArtifactStagingDirectory)/MauiUITestSample.ipa" --test-series "$(iOSTestSeries)" --build-dir "MyAppTests/bin/$(BuildConfiguration)/net48/" --uitest-tools-dir "MyAppTests/bin/$(BuildConfiguration)/net48/" --token "$(APPCENTER_TOKEN_IOS)" --async