Copied to clipboard

Flag this post as spam?

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


  • peter 13 posts 144 karma points
    Mar 14, 2017 @ 15:26
    peter
    0

    Creating package

    Hi,

    this is my very first post so please tell me if i dont follow convention. Ive been working in umbraco and .NET MVC for a month now or so.

    I've been trying to create a package that gives the user a custom section following this tutorial:

    http://www.nibble.be/?p=440

    Ive got that all up and running within a few days, which im quite glad about. The next step was for me to get it working with a package, since my client requires it for multiple sites, so it would be easy if I can just use nuget install.

    Ive seen the create package on the developper section but I'm at a loss how to use it.

    What ive seen so far is that it just creates a zip file of all my files, not keeping MVC structure or anything.

    I tried browsing the documentation which brought me to this dead link: https://our.umbraco.org/wiki/reference/packaging/package-actions

    My question is: Could you refer me to any good tutorials to get me going?

    Thanks in advance

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Mar 14, 2017 @ 18:32
    Kevin Jump
    100

    Hi

    your right the package crate basically creates a zip of all the files, in one folder, but it doesn't loose the folder structure of your files there is another file in the zip called packages.xml which tells umbraco where to put the files during an install.

    If you solution is mainly code files then you will need to add the folders / files in the 'package files' section of the create package.

    I usually create a package in umbraco first - but then unzip it somewhere and use that as the basis of any updated packages I release - using build steps to put files into the folder ready to be zipped up. (for a simple example see: https://github.com/KevinJump/StyledTextbox/tree/master/Distrib/styledtextbox

    The package action documentation seems to have fallen of the site. at the moment the best place to understand how package actions work is to look at the source .

    If you are building a tree i don't think you need package actions as the tree config should get updated based on the class attributes when umbraco starts

    Nuget If you want to create a nuget package then that is also doable, as long as you don't need to do to many changes to umbraco during the isntall (creating doctypes, templates, etc.. is doable but more difficult in a nuget pacakge)

    Creating a nuget package I would separate the code from the website in another dll (so a "Class Library" project in visual studio) and use that as the basis of the nuget package - this would contain that dll and any files from app_plugins needed for the package.

    In the first instance you can do all of this by hand (and that's probibly the way to go) but you can automate the building of packages and nuget packages (http://www.theoutfield.co.uk/blog/2010/11/automating-umbraco-package-creation-using-msbuild) this is a bit more complex but if you are going to maintain/update the package a lot it might be worth it. (example of that in use here : https://github.com/DanDiplo/UmbracoTraceLogViewer/tree/master/BuildPackage

  • peter 13 posts 144 karma points
    Mar 15, 2017 @ 09:38
    peter
    0

    Hi Kevin,

    Thank you so much for your answer. When I install the package, it indeed goes to the proper structure.

    However, the files aren't picked up by umbraco. I think its the fact that the namespace of the classes are inconsistent with the project the package gets installed on, since the namespace in the files remain the same.

    Can I in some way change this depending on the namespace of the umbraco project i install the package on or am I making a beginners error here?

  • peter 13 posts 144 karma points
    Jun 14, 2017 @ 13:13
    peter
    0

    Hi Kevin,

    sorry to bring up this old post again. I'm currently working on something that requires this exact thing you said in this post:

    Nuget If you want to create a nuget package then that is also doable, as long as you don't need to do to many changes to umbraco during the isntall (creating doctypes, templates, etc.. is doable but more difficult in a nuget pacakge)

    My question is: how? I've already spent hours trying to find answers and no one seem to be able to answer it. Even systems that automate the build by using grunt seem to just skip documenttypes and templates entirely.

    Is it even possible by just xml?

    thanks

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Mar 15, 2017 @ 09:47
    Kevin Jump
    0

    hi

    yeah umbraco won't do anything clever with namespaces during the install :( - but that is something you can achieve with Nuget.

    If the backoffice code in the package you are developing wont change once installed then you are probably better creating the code in it's own dll and installing that into the bin folder, then it will 'just work' when installed.

    if you are looking to effectively install template code that you then modify a nuget package can do that but you have to mark your files up in a certain way (see https://docs.microsoft.com/en-us/nuget/create-packages/source-and-config-file-transformations).

    Kevin

  • peter 13 posts 144 karma points
    Mar 15, 2017 @ 10:01
    peter
    0

    Hi,

    Too bad that umbraco doesn't handle it (maybe yet?) I'll try out what you put in the lin, I think that is the way to go as well.

    Thank you very much, and I'll be back if I've made some progress :)

    Peter

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Mar 15, 2017 @ 10:03
    Kevin Jump
    0

    yeah also I the long term direction of umbraco is towards NuGet and away from the package installer - so its unlikely it will make it into umbraco.

    but one day it will all be nuget :)

  • peter 13 posts 144 karma points
    Mar 17, 2017 @ 11:43
    peter
    0

    EDIT: I didnt add the .pp extension, silly me. I solved the issue and thank you for your time (Topic can be closed now).

    Explanation:

    What got me confused was this line in the documentation (to Microsoft Docs)

    the project file directly is necessary for token replacement because the project is the source of the token values. Token replacement does not happen if you use nuget pack with a .nuspec file.

    However this doesnt mean that you cannot use the nuspec file as i orignally thought.

    I solved this by creating this nuspec file:

    <?xml version="1.0"?>
       <package >
         <metadata>
           <id>$id$</id>
           <version>$version$</version>
           <title>$title$</title>
           <authors>$author$</authors>
           <owners>$author$</owners>
           <requireLicenseAcceptance>false</requireLicenseAcceptance>
           <description>$description$</description>
           <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
           <copyright>Copyright 2017</copyright>
           <tags>Tag1 Tag2</tags>
        </metadata>
    
        <!-- This is the important part-->
        <files>
          <file src="content\**" target="content"/>
       </files>
    </package>
    

    This will make the file go in the content file in the package.

    Hi Kevin,

    as i said i wanted to comeback to you when i created something close. What i ended up doing is as you said creating the logic in a seperate solution (a class library).

    Then using Nuget pack 'path/to/project.csproj' - Build created the nuget package.

    It does what i want to so i marked your awnser as the solution.
    However, If I try the latest link you gave me and substitute $rootnamespace$ in a class, eg : Root/content/Test contains a class.

    namespace $rootnamespace$.Test
    {
        class Class1
        {
        }
    } This doesnt build so I cannot create a package anymore. Should i change the code after its build or something in the nupkg itself?
    
Please Sign in or register to post replies

Write your reply to:

Draft