Copied to clipboard

Flag this post as spam?

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

  • Ian Robinson 79 posts 143 karma points
    Jul 29, 2021 @ 10:57
    Ian Robinson

    Document and data types in Packages

    I'm trying to get my head around creating packages in Umbraco and what's best practice, and I'm struggling when it comes to document and data types.

    Can anyone offer any advice or point me in the right direction?

    I've got an umbraco site and then a seperate project in my solution, containing my package css, business logic, js etc. Either using a post build script in visual studio (e.g. a bunch of calls to xcopy) or using NPM and a grunt or gulp task I can copy my package files into my umbraco site, while I'm developing it, then eventually I create the package by running the umbraco site to create the zip.

    Looking at various tutorials, I think this is generally the process most people follow and it allows me to add my package project to git source control. Happy days.

    The bit I'm struggling with is how to source control the document types and how to make these part of my package project? I can use ModelsBuilder to serialise the models, so I can reference them in views etc, but they can be used to recreate the models from scratch can they?

    I could manually export the doc types to xml udt files, or pull them out the zipped package package.xml file, but is there a way to automate this or a better approach I should take?

    The blogs posts I've read on the subject and the Umbraco documentation, seems to stop short of explaining this, so perhaps I'm missing something obvious?

    If I need to write a process to pull the types out of the package.xml and then create them as part of a package action or a startup method, I could, but I wanted to check if there was a better way first?

  • Paul Seal 519 posts 2844 karma points MVP 5x c-trib
    Jul 29, 2021 @ 11:20
    Paul Seal

    Hi Ian I suppose it depends on how the package is to be used. Is it for internal projects or is it to be shared publicly?

    If it is for an internal project. I would probably create a nuget package for the dlls, with static files to be included as content in the nuspec. And I would manage the document types and other database related settings using uSync and import them in at the start of the project.

    If it is an external package, you could create a dashboard that gets installed with your nuget package and on it have a install content and settings button which will do what it says. There might be a way to use the uSync CLI to run at that point and add all of the doc types and other related database settings, or you might want to write your own code to do it using the documenttype service etc when the button is clicked.

    I've not had to do this myself yet. Any packages I've made which include doc types and content have all been created manually in the backoffice and all install via the backoffice too, not nuget.

    Hope this helps a bit


Please Sign in or register to post replies

Write your reply to: