umbraco / Umbraco.StorageProviders

MIT License
29 stars 21 forks source link

v12: Add support for ImageSharp 2 #57

Open ronaldbarendse opened 1 year ago

ronaldbarendse commented 1 year ago

Umbraco 12 uses ImageSharp 3 by default, but also provides an Umbraco.Cms.Imaging.ImageSharp2 package if you can't use this version and want to stick to ImageSharp 2, e.g. because of the license change or other dependencies (see PRs https://github.com/umbraco/Umbraco-CMS/pull/14216 and https://github.com/umbraco/Umbraco-CMS/pull/14223).

This package can be installed instead of Umbraco.Cms.Imaging.ImageSharp (that will be kept up to date with the latest ImageSharp version) by switching from Umbraco.Cms (that bundles all default/optional dependencies) to Umbraco.Cms.Targets and including any other required dependencies yourself.

We initially released Umbraco.StorageProviders 12 RC versions that had direct dependencies on the ImageSharp 2 packages and let the transitive dependency resolution pick the lowest compatible version. This however resulted in always using SixLabors.ImageSharp.Web.Providers.Azure v2, even when used together with SixLabors.ImageSharp.Web v3. This currently isn't an issue because of the lack of an upper version limit, but could be in a future update, besides always resolving to the lowest compatible version and not taking advantage of the latest v3 updates. However, we also failed to notice that Umbraco.StorageProviders.AzureBlob.ImageSharp had a direct dependency on Umbraco.Cms.Imaging.ImageSharp, which makes the dependency on ImageSharp require version 3 and thereby prevents you to use this package with v2 altogether 🙁

For the final v12 version, I bumped the ImageSharp dependency to the latest v3, resulting in not being able to use this package with v2... This PR adds that support by introducing a new Umbraco.StorageProviders.AzureBlob.ImageSharp2 package that you can install:

<Project Sdk="Microsoft.NET.Sdk.Web">
    <!-- Default CMS install using ImageSharp 3 -->
    <ItemGroup>
        <PackageReference Include="Umbraco.Cms" Version="12.0.0" />
        <PackageReference Include="Umbraco.StorageProviders.AzureBlob.ImageSharp" Version="12.0.0" />
    </ItemGroup>

    <!-- Custom CMS install using ImageSharp 2 -->
    <ItemGroup>
        <PackageReference Include="Umbraco.Cms.Targets" Version="12.0.0" />
        <PackageReference Include="Umbraco.Cms.Imaging.ImageSharp2" Version="12.0.0" />
        <PackageReference Include="Umbraco.Cms.Persistence.Sqlite" Version="12.0.0" />
        <PackageReference Include="Umbraco.Cms.Persistence.SqlServer" Version="12.0.0" />
        <PackageReference Include="Umbraco.Cms.Persistence.EFCore" Version="12.0.0" />
        <PackageReference Include="Umbraco.StorageProviders.AzureBlob.ImageSharp2" Version="12.*" />
    </ItemGroup>
</Project>
ronaldbarendse commented 1 year ago

One downside to having different packages to support ImageSharp 2 or 3, is that the Umbraco Cloud setup package will need to depend on different ones as well. We will need to consider this if we want to ensure both packages are included in automatic upgrades, but that's probably already the case when changing the package reference from Umbraco.Cms to Umbraco.Cms.Targets (and all default/optional dependencies)...