Copied to clipboard

Flag this post as spam?

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


  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jul 16, 2015 @ 11:19
    Marc Love (uSkinned.net)
    0

    Rebuild umbraco.config

    Does anyone know how to rebuild umbraco.config from code? Not sure if this is a bug with 7.2.7 however the following does not work:

    var contentService = ApplicationContext.Current.Services.ContentService;
    
    contentService.RePublishAll();
    umbraco.library.RefreshContent();
    

    Only 'Republish entire site' via content section of Umbraco CMS works.

    Cheers,

    Marc

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jul 16, 2015 @ 11:59
    Alex Skrypnyk
    0

    Hi Marc,

    You can remove physically umbraco.config file.

    Thanks, Alex

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jul 16, 2015 @ 12:14
    Marc Love (uSkinned.net)
    0

    Hi Alex,

    Thanks for your suggestion however I need to get this working via code. My issue is that default site content created via a Starter Kit is not present until 'Republish entire site' via the content section is used. Ideally I need the package installer to rebuild the umbraco.config file. The code I have posted above isnt doing this when I think it should.

    Cheers,

    Marc

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jul 16, 2015 @ 12:23
    Alex Skrypnyk
    100

    Marc, you can do like :

                        if (File.Exists(filePath))
                        {
                            File.Delete(zipFullPath);
                        }
    
  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jul 16, 2015 @ 12:50
    Marc Love (uSkinned.net)
    0

    Hi Alex,

    That worked a treat:

    string filePath = HostingEnvironment.MapPath("~/App_Data/umbraco.config");
    
    
    if (System.IO.File.Exists(filePath))
    {
        System.IO.File.Delete(filePath);
    }
    

    Cheers,

    Marc

  • Stephen 767 posts 2273 karma points c-trib
    Jul 16, 2015 @ 17:30
    Stephen
    0

    What exactly do you see when "it does not work"? Care to share your Umbraco log? Also, when/in what context exactly are you calling that code?

    Note that contentService.RePublishAll() would rebuild the entire XML in cmsContentXml, which does not happen when you just delete the umbraco.config file. But if just deleting the file is OK for you then it means you probably did not want to rebuild the entire XML in cmsContentXml.

    So yes, deleting the file does the same as umbraco.library.RefreshContent() ie it reloads the entire content cache from database cmsContentXml.

    Wondering why the package content is not visible?

  • Stephen 767 posts 2273 karma points c-trib
    Jul 16, 2015 @ 17:37
    Stephen
    0

    In addition: which starter kit is causing that issue? Just tried with the first one in the list and it worked.

Please Sign in or register to post replies

Write your reply to:

Draft