Copied to clipboard

Flag this post as spam?

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


  • Ruder Pratap 6 posts 91 karma points
    Jan 24, 2021 @ 20:36
    Ruder Pratap
    0

    How to make macro as a part of nuget package

    Hi I am creating a package that have a macro in it. I am trying to create a nuget package of my plugin. I go through the umbraco doc link

    and it says that

    However if you are bundling up Partial View Macros as part of a package, they can also exist in this folder: ~/App_Plugins/[YourPackageName]/Views/MacroPartials

    When i create plugin and place my macro view to ~/Views/MacroPartials path, its workin in case of pluing but i am not able to find ~/App_Plugins/[YourPackageName]/Views/MacroPartials view path in my macro. How can i make macro as a part of my plugin and nuget package.

  • Markus Johansson 1696 posts 4865 karma points c-trib
    Jan 25, 2021 @ 21:43
    Markus Johansson
    0

    Hi!

    When using Umbraco’s own package format you can configure a macro to be created during install, but when you ship the package via nuget you would need to handle this differently.

    I think that the best approach is to create a migration that creates the macro using the APIs during the first startup after your fall has been added. Umbraco has a built in concept of Migrations that you can use in your package, I think that there’s some examples in the documentation.

  • Ruder Pratap 6 posts 91 karma points
    Jan 26, 2021 @ 20:21
    Ruder Pratap
    0

    Hi Markus,

    Thanks for reply

    Can you please share some link that help to create macro as part of nuget

    Thanks

  • Markus Johansson 1696 posts 4865 karma points c-trib
    Jan 27, 2021 @ 07:23
    Markus Johansson
    100

    Hi!

    Is all in the docs here on our.

    You would need to create a custom migration, this one shows how to create db-tables but you can see the concept here: https://our.umbraco.com/documentation/extending/database/

    One might think that it would work with a component that just creates the Marco during startup but the migration makes sure that the Marco is only creates once and not gets recreated when if someone removes it or renames it.

    And add the Marco: https://our.umbraco.com/documentation/reference/management/services/MacroService/

    Good luck! :)

Please Sign in or register to post replies

Write your reply to:

Draft