2

I have created a multi-target project that targets netstandard, xamarin.ios and monodroid10. Everything works fine with Debug and Release modes for both platforms when I build it myself. However, when our pipeline builds in Release mode, custom renderers in Android app is ignored, and the controls are using the default renderers.

What I'm wondering is that are there any factors in MSBuild that might cause renderers to be not compiled or ignored at runtime due to the build configuration?

Unfortunately, I can't share any small project to reproduce or the build log, but I might share some info in the multi-target solution:

  • AssemblyInfo folder has ExportRenderer imports for all platforms. Also, each custom renderer has ExportRenderer implemented.

enter image description here

  • Static initializer for the library is called before Xamarin.Forms.Init() call.
  • Linker in the application is set to SDK Assemblies only (<AndroidLinkMode>SdkOnly</AndroidLinkMode>)
  • Linker is ignoring the multi-target assembly (<AndroidLinkSkip>MultiTargetAssemblyName</AndroidLinkSkip>)
  • Controls are using default Xamarin renderers for their corresponding base classes. There is no crash, just unexpected UX behavior due to the missing renderers.
  • Library is working completely fine in iOS, both debug/release modes and when CI builds it. Issue is only happening on Android side.
  • Multitarget project is built with MSBuild.Sdk.Extras/3.0.44 SDK.

Further investigation showed that Android project is using the netstandard2.0 version of the multi-target dll during msbuild.

and I started to see this missing namespace errors

/Users/runner/work/1/s/Test.Test.Mobile/Test.Test.Mobile.Android/Renderers/ControlLibrary/LibraryButtonRenderer.cs(3,38): error CS0234: The type or namespace name 'Android' does not exist in the namespace 'Test.Test.Mobile.Controls' (are you missing an assembly reference?) [/Users/runner/work/1/s/Test.Test.Mobile/Test.Test.Mobile.Android/Test.Test.Mobile.Android.csproj]

Why on earth build agent takes the one for the shared library and uses in MonoDroid10.0 project?

Burak Kaan Köse
  • 821
  • 1
  • 7
  • 18
  • I don't use a build pipeline, but are there any settings you can change, to make it more like the Debug build? Probably moot, since Release works when you build manually, but maybe some change would help isolate the cause. (If this was for iOS, I'd suspect a difference between Release and AppStore/Archive building; but AFAIK there is no Android equivalent to that subtle iOS build distinction.) – ToolmakerSteve Oct 27 '22 at 23:41
  • Well on Build pipelines it's not necessary that the VS(version) and Mac/Windows(os) are the same which means that there could be stuff that is installed on your PC but not there on the Pipelines. You need to show the error that you are facing on pipelines for me to help you with this. – FreakyAli Oct 28 '22 at 10:22
  • I did more investigation on the issue and realized that incorrect version of the multi-target library was referenced during agent build. I updated my question with the details. How is it possible that Xamarin.Android project is using netstandard2.0 DLL instead of MonoDroid10.0 DLL from the artifacts? – Burak Kaan Köse Oct 30 '22 at 21:51

0 Answers0