I'm encountering this error when my pipeline script for generating an apk runs(It builds and runs fine in Visual Studio 2022):
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Legacy.targets(660,5): Error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Threading.Tasks.Task
1<Sharpnado.HorizontalListView.Services.PageResult
1> Sharpnado.HorizontalListView.Paging.Paginator1::LoadPage(System.Int32,System.Boolean)' in assembly: 'Sharpnado.HorizontalListView.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Threading.Tasks.Task
1<!0> Sharpnado.Tasks.TaskMonitor1<Sharpnado.HorizontalListView.Services.PageResult
1>::get_Task()
My yml script:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin
pool:
vmImage: 'windows-2019' # For Mac, use 'macOS-10.13'
variables:
- group: 'AndroidAppVariables'
- name: 'buildConfiguration'
value: 'Release'
- name: 'outputDirectory'
value: '$(build.binariesDirectory)/$(buildConfiguration)'
- name: 'NugetVersion'
value: 5.8.0
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet $(NugetVersion)'
inputs:
versionSpec: $(NugetVersion)
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: 'src\AndroidApp.sln'
feedsToUse: 'select'
vstsFeed: '/a3sb3q3s-ab12-2020-0202-0202020202'
- task: XamarinAndroid@1
inputs:
projectFile: 'src\AndroidApp.Android\AndroidApp.csproj'
outputDirectory: '$(outputDirectory)'
configuration: '$(buildConfiguration)'
jdkVersionOption: 1.11
createAppPackage: true
msbuildVersionOption: latest
What I've tried so far:
<GenerateSerializationAssembles>Auto</GenerateSerializationAssemblies>
from Android.csproj fileAfter reading some similar errors in StackOverflow that happened in their Visual Studio(when building in release configuration mode), I also encountered that issue in VS2022. Like what others did in this problem, I also have to install Sharpnado.HorizontalListView 1.8.2 even though the app is not using anymore, as we wanted to keep the changes to a minimum (because we are also migrating to .Net MAUI, while doing that just have to make sure current Xamarin project is still maintained): Mono.Linker.MarkException: Error processing method: 'System.Void AndroidX.RecyclerView.Widget.RecyclerView/LayoutManager
and then it worked also for the pipeline, without changing anything in the script.