Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Dec 14, 2012 @ 01:23
    CodeMaster2008
    0

    New Package, web.config and package actions.

    I need to create a package that among other things will have to modify the web.config.
    The modifications needed are:

    • Create a custom section group under "configSections" and append items to it.
    • Add assemblies to the "assemblies" section.
    • Add handlers to section "system.WebServer/handlers"
    • Add a new cutom section under the root "configuration"
    The only information I was able to find on this subject is this article, which covers a lot of possible package actions but looks like none will work for the above requirements.
    So, are there more actions then the ones listed or do I have to make this changes through code?
    If C# is the solution, how and where I will call my functions to apply/undo the changes?

  • Nigel Wilson 945 posts 2077 karma points
    Dec 14, 2012 @ 03:21
    Nigel Wilson
    0

    Hi Codemaster

    I have added nodes to the config files using c# code for packages I have released.

    I can dig out what I did and copy in here - I would expect the experts to be able to improve upon it, but at least it will be a starting point for you.

    The code is at home, so will dig out over the next couple of days.

    Cheers, Nigel

  • CodeMaster2008 151 posts 184 karma points
    Dec 14, 2012 @ 03:25
    CodeMaster2008
    0

    That would be very helpful, thanks a lot.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Dec 14, 2012 @ 12:29
    Richard Soeteman
    0

    Hi,

    I've started the Package action contrib for that reason. You can either include the dll, or use the code. If you use the source code make sure to have unique aliasses for every action.

    Cheers,

    Richard

  • Nigel Wilson 945 posts 2077 karma points
    Dec 14, 2012 @ 22:13
    Nigel Wilson
    0

    I would investigate Richard's solution but from a code "hacker" from down under here is what I did

     

    string filePath = System.Web.HttpContext.Current.Server.MapPath("~/umbraco/config/lang/en.xml");
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(filePath);
    //Test to make sure the node does not already exist
    var testForNode = xmlDoc.SelectNodes("/language/area[@alias = 'sections']/key[@alias = 'tagMaint']");
    if (testForNode.Count == 0)
    {
    //Create a new XML <key> node
    XmlElement keyNode = xmlDoc.CreateElement("key");
    keyNode.SetAttribute("alias", "tagMaint");
    keyNode.InnerText = "Tag Maintenance";
    //Add <key> to file and save.
    xmlDoc.SelectSingleNode("/language/area[@alias='sections']").AppendChild(keyNode);
    xmlDoc.Save(filePath);
    }

    Hope this provides some ideas.

    Cheers, Nigel

     

Please Sign in or register to post replies

Write your reply to:

Draft