dimonovdd / Xamarin.MediaGallery

This plugin is designed to picking and save images and video files from native gallery of Android and iOS devices and capture photos
MIT License
154 stars 19 forks source link

Documentation or any pointers for building the project #121

Closed beeradmoore closed 1 year ago

beeradmoore commented 1 year ago

Hey @dimonovdd , I'd like to make some changes to Xamarin.MediaGallery (see #122) regarding the differences between iOS and Android and how they handle albums. I think the changes should be quite simple, but currently I am unable to build the project.

I am using macOS + Visual Studio 2022. I am able to build and deploy both Xamarim.MediaGallery.Sample and Xamarim.MediaGallery.Sample.Maui but it appears that in both instances Xamarim.MediaGallery.targets is forcing those projects to use the nugets (see the _UseNuget here).

Changing _UseNuget to be false I would hope that it would then use the csproj files and build from source but there appears to be issues with it generating NativeMedia.dll. Poking around at this for an hour I was not able to find a resolution.

I then changed tactic and made a new Xamarin.Forms project and added source for Permission and MediaGallery to my solution and tried to get it to build from source that way to no avail.

Third tactic I tried was to build the project manually with msbuild, but building just resulted in compilation errors no matter how I tired to build and what I tried to target.

Is there any info you can provide on how you build it from source. I can see from your comment here that you were building from cli. I am more than happy to build on cli and manually dump dlls in my test project to test the new code out before I update the samples and send it all off as a PR.

dimonovdd commented 1 year ago

Thanks to Microsoft. It's really difficult.

The easiest way:

1) Open Xamarim.MediaGallery.sln 2) Delete all "*.Maui" projects (Sample.Common.Maui and etc.) 3) Remove all net6.0 TargetFrameworks in other projects 4) Clean projects 5) Close IDE 6) Open Xamarim.MediaGallery.sln

beeradmoore commented 1 year ago

Thanks for the quick reply. That got it working. Will get started on those changes.

beeradmoore commented 1 year ago

I spoke too soon. Appears the demo will compile and run. And appears it does not like it when I have errors in the MediaGallery project. But for some reason it does not like additional arguments added onto SaveAsync. Says SaveAsync with 4 arguments does not exist, but IDE seems to not only show me it exists it shows the comment I added to the doc tags about the new argument 😂

I'll keep fiddling and see what I can do.

beeradmoore commented 1 year ago

Got it. I reverted my csproj/sln/targets changes.

Leaving a list of things I did that worked for me here for the next person to find.

  1. From Finder, manually delete all the .Maui folders and .sln files.
  2. Open the entire project in VSCode.
  3. Search for anything containing maui and remove it (when removing from solution files)
  4. Change any netstandard2.0 to netstandard2.1. No idea why, IDE didn't like it.
  5. Remove _UseNuget from any csproj file (it's just in one)
  6. Remove any ItemGroup that seems to want to support _NET6.
  7. Force it to use csproj to build instead of nuget (in Xamarim.MediaGallery.targets
    <PackageReference Condition="'$(_UseNuget)'=='true'" Include="Xamarin.MediaGallery.Permision" Version="$(_PermissionLibVersion)" />
        <ProjectReference Condition="'$(_UseNuget)'!='true'" Include="$(MSBuildThisFileDirectory)\Permission\Xamarin\Permission.csproj" />

    should become

    <ProjectReference Include="$(MSBuildThisFileDirectory)\Permission\Xamarin\Permission.csproj" />
  8. Do the same for MediaGallery just below it as well.
  9. Open Xamarim.MediaGallery.sln in Visual Studio.
  10. Manually build Permissions and MediaGallery.
  11. Build and deploy Android/iOS sample.

For any changes made I needed to manually build MediaGallery again.