Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Xamarin.Build.Download package id validation causes build errors #1293

@AdamEssenmacher

Description

@AdamEssenmacher

I upgraded my Xamarin.Android project to Xamarin.Firebase.Storage to v120.x.x.x to take advantage of the newer firebase emulator APIs, which caused the build error "Invalid item ID firebaseappcheckinterop-16.0.0-beta01".

Related issues reported on StackOverflow:
https://stackoverflow.com/questions/68599578/xamarin-build-download-targets-invalid-id
https://stackoverflow.com/questions/69458719/i-get-the-error-invalid-item-id-firebaseappcheckinterop-16-0-0-beta01-during-b

Digging in, I've determined that the root cause is in Xamarin.Build.Download.DownloadUtils.ParseDownloadItems(..), which is highly opinionated on what should be considered a valid package id. Specifically, it expects that the version component of a package id (in this case, 16.0.0-beta01) should only use periods as separators. Since this version component uses a dash - before the beta01 postfix, the id check fails.

To confirm this, I cloned the XamarinComponents repo and modified the offending method to exclude the id check:

public IEnumerable<XamarinBuildDownload> ParseDownloadItems (ITaskItem[] items, bool allowUnsecureUrls)
		{
			if (items == null || items.Length <= 0)
				return new List<XamarinBuildDownload> ();
			
			var results = new List<XamarinBuildDownload> ();

			foreach (var item in items) {
				var xbd = new XamarinBuildDownload ();

				xbd.Id = item.ItemSpec;
				// !!!! THIS IS CAUSING BUILDS TO FAIL
				//if (!ValidateId (xbd.Id)) {
				//	Log.LogCodedError (ErrorCodes.XbdInvalidItemId, "Invalid item ID {0}", xbd.Id);
				//	continue;
				//}
				xbd.Url = item.GetMetadata ("Url");
......

After packing the modified code and copying the output to my local nuget cache (replacing xamarin.build.download v0.10.0), my Xamarin.Android project compiled and ran without issue.

My recommendations for options to fix:

  1. Convince Google to stop including preview dependencies in non-preview packages 🙄
  2. Modify the id-checking logic in DownloadUtils to permit dash - delimiters OR
  3. Remove the id-checking logic in DownloadUtils entirely. Unless there's a good reason for this that isn't apparent to me (which is totally possible likely), it seems odd that Xamarin.Build.Download would assume responsibility for enforcing any specific package id/version format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions