GeekInTheNorth / Stott.Security.Optimizely

A CMS Administration interface for managing security headers for Optimizely CMS Traditional and Hybrid builds.
MIT License
4 stars 1 forks source link

Support for .net 8 #179

Closed lunchin closed 9 months ago

lunchin commented 9 months ago

Facing an issue with migration step when trying to run with Microsoft.EntityFrameworkCore.SqlServer vrsion 8.0.1

GeekInTheNorth commented 9 months ago

Hello @lunchin

Can you give me a run down of the following please:

If you have any exception information, please provide a copy here once you've sanitized any client specific information.

GeekInTheNorth commented 9 months ago

Hello @lunchin

Is this the error you are encountering?

Method not found: 'Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1 Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder.CreateIndex(System.String, System.String, System.String[], System.String, Boolean, System.String)'.

lunchin commented 9 months ago

Yes exactly. sorry meant to respond but did not have time earlier today. I am using all the latest Opti and Microsoft packages

GeekInTheNorth commented 9 months ago

The challenge I have is that Optimizely CMS is compiled at .NET 6 and a number of installations are running .NET 6 or .NET 7 and in order to get that version I'll need to bump the project to .NET 8. So feasibly I'll need to manage two versions of the package.

I'm going to investigate if there is a work around or whether I'll have to regenerate all the migrations. I'll get back to you soon.

lunchin commented 9 months ago

i think you can just update the csproj to target both and then in the nuspec file create different dependencies by version.

`

</group>
 <group targetFramework="net8.0">
    <dependency id="PackageA" version="4.5.6" />
</group>`
GeekInTheNorth commented 9 months ago

I've just run a test and with the updated packages the migrations work fine for .NET 8. I'm not using a Nuspec file specifically but I'm modifying the CSProj targets to the same thing.

lunchin commented 9 months ago

if you try adding net8.0,net6.0 in target framework in csproj may just work.

GeekInTheNorth commented 9 months ago

That's what I've done, I've also split the dependencies in the main csproj file to set different versions per framework:

    <ItemGroup>
        <PackageReference Include="EPiServer.CMS.UI.Core" Version="12.23.0" />
    </ItemGroup>

    <ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
    </ItemGroup>

    <ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
    </ItemGroup>

2.4.0 has been pushed up to nuget.org. fortunately I have a few local solutions to test against.

lunchin commented 9 months ago

Thanks I appreciate it. If only Opti would come out with 8.0 compiled versions.

GeekInTheNorth commented 9 months ago

For me that's a little behind 'nonce' support on the CMS Editor and Admin interfaces :)

Give me a shout and let me know if that works for you. My Azure test server for my modules are running .NET 7.0 right now. So I've only been able to test by pulling it into another solution I have on .NET 8 locally and starting with a fresh DB to ensure the migrations work and then done tests on my local solution.

lunchin commented 9 months ago

Can confirm all is working on the project I was trying to use it on. Thanks again for you help and quick turn around time.

GeekInTheNorth commented 9 months ago

Thank you for the confirmation and for help :)