Odd error when testing my CSP nuget package from GitHub Actions

Hey,

The project is now working in v17 well at least in the project…

The resulting articfact from - Merge pull request #75 from Matthew-Wise/feature/v17 · Matthew-Wise/Umbraco-CSP-manager@40b45c7 · GitHub results in 2 errors in both v17 and v17.0.1.

I have no direct dependencies on either of the failing types

Migration

System.TypeLoadException: Could not load type 'NPoco.IAsyncDatabase' from assembly 'NPoco, Version=6.1.0.0, Culture=neutral, PublicKeyToken=null'.
   at Umbraco.Community.CSPManager.Migrations.InitialCspManagerMigration.MigrateAsync()
   at Umbraco.Community.CSPManager.Migrations.InitialCspManagerMigration.MigrateAsync()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Umbraco.Community.CSPManager.Migrations.InitialCspManagerMigration.MigrateAsync()
   at Umbraco.Cms.Infrastructure.Migrations.AsyncMigrationBase.RunAsync()
   at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigrationAsync(Type migrationType, MigrationContext context)
   at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunScopedMigrationAsync(Transition transition, MigrationPlan plan)
   at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigrationPlanAsync(MigrationPlan plan, String fromState)

Post Migrations on startup

Unhandled exception. System.TypeLoadException: 
Could not load type 'Microsoft.OpenApi.Models.OpenApiInfo' from
assembly 'Microsoft.OpenApi, 
Version=2.3.0.0, Culture=neutral, PublicKeyToken=3f5743946376f042'.

Thanks for any help

Matt

I’ve been having “funny” dependency issues with the upgrade to the new Swashbuckle/OpenApi where I think this is coming from. The NPoco error is likely a red herring.

So I can see that for some reason in your solution - the implicit usings of the OpenApi package is of the wrong version, which is throwing the whole thing off:

The trick is now to figure out which of your NuGet packages is asking for the older version of OpenApi.. the solution unfortunately might have to be that you need to take a dependency on the newest version for now.

With a bit of help from ChatGPT:

Umbraco.Cms.Api.Management 17.0.0
 └─ Microsoft.Extensions.ApiDescription.Server 10.0.0
     └─ Swashbuckle.AspNetCore 10.0.1
         └─ Swashbuckle.AspNetCore.Swagger 10.0.1
             └─ Microsoft.OpenApi 2.3.0   ← your problem

However, this seems very strange since Umbraco itself updated to Swashbuckle.AspNetCore 10 for this very reason, to get the new OpenApi version :thinking:

Its odd that the repo’s test site is working… I found the same Microsoft.OpenApi 2.3.0 reference in both the package and v17 as well. Which is why I am lost :smiley:

I would test it out, if you (in the non-working site) install OpenApi 3, does it then work?

Running the risk of confusing this discussion…

Umbraco 17 depends on Swashbuckle.AspNetCore v10.0.1, which (via Swashbuckle.AspNetCore.Swagger) depends on Microsoft.OpenApi v2.3 or higher.

Now, when reading the “Branches and support policy” for MS OpenAPI, it kind of hints at Swashbuckle v10 not supporting MS OpenApi v3.

It could be that the Swashbuckle peeps neglected to add a hard upper version boundary on their dependency. Maybe it should have been “v2.3 or higher, but less than v3”. Or, in other words, if you’re using MS OpenApi v3, perhaps you need to downgrade to v2.3 for it to work?

I don’t have a direct dependency, so not sure why I am getting this error.

Project refs:

<ItemGroup>
    <PackageReference Include="Umbraco.Cms.Web.Website" />
    <PackageReference Include="Umbraco.Cms.Api.Management" />
    <InternalsVisibleTo Include="Umbraco.Community.CSPManager.Tests" />
</ItemGroup>

Directory Deps:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
    <NoWarn>$(NoWarn);NU1507</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="SystemTextJson.JsonDiffPatch.NUnit" Version="2.0.0" />
    <PackageVersion Include="Umbraco.Cms" Version="17.0.0" />
    <PackageVersion Include="Umbraco.Cms.Api.Management" Version="17.0.0" />
    <PackageVersion Include="Umbraco.Cms.Web.Website" Version="17.0.0" />
    <PackageVersion Include="uSync" Version="17.0.0" />
    <PackageVersion Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" />
  </ItemGroup>
  <ItemGroup>
    <PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
    <PackageVersion Include="coverlet.collector" Version="6.0.4" />
    <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
    <PackageVersion Include="NUnit" Version="3.14.0" />
    <PackageVersion Include="NUnit.Analyzers" Version="4.4.0" />
    <PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
    <PackageVersion Include="Umbraco.Cms.Tests.Integration" Version="17.0.0" />
  </ItemGroup>
</Project>

Seb suggested I clear my nuget caches so Ill give that ago later on this evening, This version is not on nuget, as I wanted to make sure it worked before creating the release so its only an artifact linked in my post.

Matt

Cleared my local NuGet Cache and its working, don’t you just love computers!

Thanks both

1 Like

Oh that’s good to know.. sorry you ran into this as well.. I am usually really strict in not allowing pre-release feeds on my machine, but sometimes I have to :sweat_smile:

But in any case, this is great to know in case other people have this problem!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.