[Solved] iOS Content not found (new develop MGCB.Task)

I built all the nuget packages from the develop branch, and I’m using the new MonoGame.Content.Builder.Task, but I’m getting “The content file was not found” only on iOS. It works with DesktopGL, WindowsDX, and WindowsUniversal.

  • The inner exception shows it’s looking in the right place: Resources/Content/Assets/Textures/Sample.xnb (this is the same path CreateItem uses as the Link)
  • If I manually add a BundleResource to the csproj it works, so I’m wondering if somehow the Task doesn’t hook into the right place in the Xamarin deployment
  • I’m quite certain I tested the new MGCB.Task on iOS when it was first in development, and it also didn’t change the flow of BuildDependsOn -> Target -> CreateItem from how it worked in the old task, so I’m wondering if I’m doing something wrong or if something changed with new a version of Xamarin.

I think I found the problem. Now that MGCB.Task is a nuget package whose targets file is included automatically, it’s naturally ordered after Xamarin collects content:

1>Property reassignment: $(BuildDependsOn)="
1>			BuildOnlySettings;
1>			PrepareForBuild;
1>			_CollectBundleResources;      <-- Xamarin collects <BundleResource/>
1>			_OptimizePngImages;
1>			_OptimizePropertyLists;
1>			_OptimizeLocalizationFiles;
1>			_PackLibraryResources;
1>			_UnpackLibraryResources;
1>      IncludeContent;                   <-- MonoGame generates <BundleResource/>
1>      BeforeBuild;
1>      CoreBuild;
1>      AfterBuild
1>    ;
1>    ;
1>			_GenerateBundleName;
1>			_CleanUploaded;
1>			_CreateAppBundle;
1>			Codesign;
1>			CreateIpa;
1>			Archive;

I guess potential fixes are trying to find a way to enforce MGCB.Task’s targets file is run before Xamarin’s, or be more explicit with BeforeTargets or some *DependsOn

I tried several of these that didn’t seem to successfully reorder the targets. Maybe I’ll try manually importing the targets file from the nuget package just to validate that this is the issue.

Looks like this was fixed with this PR on April 24th. Thanks @harry-cpp!