Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 09, 2023 @ 08:58
    Pieter Vanderheyden
    0

    Splitting core and web

    Hi everyone.

    In my Umbraco training for version 8, I learned that it's possible (and sometimes good) to split the VS project into a core project and a web project.

    I've tried doing the same in Umbraco 10, but can't get it working. Is this still possible for Umbraco 10/11? And if so, how?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 09, 2023 @ 09:10
    Huw Reddick
    0

    Hi Pieter,

    Yes it is still possible, what is not working for you exactly?

  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 09, 2023 @ 09:45
    Pieter Vanderheyden
    0

    Hi Huw

    Thanks for your answer :)

    I'm getting compilation errors because of missing references in the back-end project. As far as I can tell I have copied all relevant packages and files, but there are still errors.

    I followed this guide for a previous project (Umbraco 8): https://www.codecraftsman.us/my-umbraco-v8-project-setup-in-visual-studio/

    Now I tried to apply the same thing for Umbraco 10, as best I could. But it was not a success. Do you happen to know of a guide I can follow? I'm sure I missed something somewhere.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 09, 2023 @ 09:50
    Huw Reddick
    0

    Hi Pieter,

    What sort of missing references are you getting? Do they relate to your models or core umbraco stuff?

  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 09, 2023 @ 10:12
    Pieter Vanderheyden
    0

    Huw

    Unfortunately, I've been messing around with it so much already that I can now run the project but I'm getting the error: The migration plan does not support migrating from state "5d84fee1-388c-4e5f-b98c-1e66947278f1".

    So I think I have to start over from scratch again :(

    Does that guide seem applicable to Umbraco 10 to you? Aside from the fact that web.config is now a json file and the packages have a different name.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 09, 2023 @ 10:35
    Huw Reddick
    100

    Does that guide seem applicable to Umbraco 10 to you? Aside from the fact that web.config is now a json file and the packages have a different name.

    Yes, apart from the modelsbuilder stuff which now goes in appsettings.json

  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 09, 2023 @ 10:40
    Pieter Vanderheyden
    0

    Alright. I will give it another try then. Thanks for your help so far :)

  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 13, 2023 @ 14:04
    Pieter Vanderheyden
    0

    I managed to get it working on a new project. I did have to add a reference from the web project to the core project DLL. I tried by just copying to the folder, but that gave me an error.

    After adding the reference it worked as intended.

    Thanks again.

  • Roy Berris 89 posts 577 karma points c-trib
    Feb 09, 2023 @ 09:59
    Roy Berris
    0

    Hi,

    If your controllers are not in the Web project but in the Core, you might need to load the assembly part in the mvc builder with below code in your Startup Configure Services.

    var mvcBuilder = services.AddControllers();
    
    // This allows your Core to load controllers
    mvcBuilder.PartManager.ApplicationParts.Add(new AssemblyPart(Assembly.Load("MyProject.Web.Core")));
    
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Feb 09, 2023 @ 10:02
    Huw Reddick
    0

    I've never had to do that myself to access controllers from my core project

  • Pieter Vanderheyden 11 posts 91 karma points
    Feb 09, 2023 @ 10:13
    Pieter Vanderheyden
    0

    Hi Roy

    I will give it a try and see if it helps. Thanks for the suggestion!

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Feb 09, 2023 @ 10:42
    Dave Woestenborghs
    0

    Hi Roy,

    I don't think this is needed. I always have my controllers in a separate project and never needed this piece of code to get it working.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft