Module Packaging

by: Mari Jørgensen

 

Manager_1

If you have installed the new demo package available on EPiServer World, you have already used the new module installation feature in the EPiServer CMS Manager. This feature is rather new, and IMHO one of the coolest things in EPiServer CMS 5.

You need the latest version of the EPiServer CMS Manager to make everything work flawlessly. Installing pre-packaged EPiServer modules to extend the features of your site is of course neat, but did you know that you can actually package your own modules?

A module is just a zip file - but with some magic attached - which you'll learn all about right now!

So why is this cool?

This is a neat tool not only for module installations, but also to ship your deployment updates - especially where access to the production environment is limited, or you are not allowed to do the deployment yourself. Apart from copying the runtime files (templates and dependencies) to the installation directory according to the relative paths within the zip, the EPiServer CMS Manager module installation can also import EPiServer data and perform web.config updates.

Include runtime files

You can use Unleash IT or a similar tool to extract the runtime files from your project. You will typically have a /bin folder for your .dll's, /lang for any language files, and so on. 

folder_structure

 

 

A sample structure for a module zip installation.

 

EPiServer data

Place any episerver content (new pagetypes, pages etc) in an .episerverdata export file into an Util/install folder.

Web.config changes

All web.config changes need to specified in an web.config.xmlupdate file located in the .zip root. It is possible to add, set and remove settings from the web.config file.

AppSettings using add

The example below will modify the first node of type <appSettings> where the attribute key has a value of ="UniqueKey". If that node does not exist, it will add a new node  <add key="UniqueKey" value="abc" /> to the appSettings section.

<?xml version="1.0" encoding="utf-8"?>
<modifications>
  <add path="/configuration/appSettings">
    <add key="UniqueKey" value="abc" __keyAttributes="key" />
  </add>
</modifications>

Note that by omitting the __keyAttributes option, the configuration will modify the first node of type <add> that is a child of the node in "appSettings".

Custom configuration settings using add
<?xml version="1.0" encoding="utf-8"?>
<modifications>
  <add path="/configuration/configSections">
    <section name="EPiRssToPageSettings" 
type="EPiCode.RSSToPage.Library.RssSettingsSection"
__keyAttributes="name" /> </add> <add path="/configuration"> <EPiRssToPageSettings disableModule="false"
feedUrl="https://www.coderesort.com/p/epicode/blog?format=rss" rssTemplatePageTypeName="[EPiCode] ContentFromRss" /> </add> <add path="/configuration"> <location path="epicode/rsstopage" __keyAttributes="path"> <system.web> <authorization> <allow roles="WebEditors, WebAdmins,
Administrators
" /> <deny users="*" /> </authorization> </system.web> </location> </add> </modifications>

The sample above will do three things:

  1. Add a new configuration section to the configSections node
  2. Add the new section ”EPiRssToPageSettings” to the configuration node
  3. Add a location setting to secure my module folder
Edit EPiServer Settings using set

EPiServer settings need to be prefixed with ”:epi”. The following example will enable globalization for all sites in the web.config file.

<?xml version="1.0" encoding="utf-8"?>
<modifications>
  <set path="/configuration/epi:episerver/
epi:sites/epi:site/epi:siteSettings
" name="uiShowGlobalizationUserInterface" value="true" /> </modifications>
Use xpath with a unique attribute to limit your update

If you want the sample above to only effect one of your sites - use applicationId as a unique value.

<?xml version="1.0" encoding="utf-8"?>
<modifications>
  <set path="/configuration/epi:episerver/epi:sites/
epi:site[@applicationId='/LM/W3SCV/19/Root']/epi:siteSettings
" name="uiShowGlobalizationUserInterface" value="true" /> </modifications>
Remove settings

You can also remove settings from web.config.

<?xml version="1.0" encoding="utf-8"?>
<modifications>
  <remove 
path="/configuration/appSettings/add[@key='UniqueKey']" /> </modifications>
Keep in mind
  • Path-attributes using <add> or <set> must point to an EXISTING node
  • Put the attributes that make your new node unique in the _keyAttributes list (comma separated)
  • The installation will handle assembly redirects, and create a separate Upgrade.log file under
    C:\Program Files\EPiServer\Manager\Modules\<yourmodulename>

21 April 2008


Comments

  1. Great write up! There has been far to few documentations of the module installer so far. Didn't know about the "epi:" prefix! From what I have experienced it doesn't matter where you put your .episerverdata files, though it might be a good standard to put them in Util/install. And to the wishlist: If the episerver manager would be callable from a commandline (which by looking would take a big rewrite). Then you could run continuous integration building module packages and installing them using build scripts. Now wouldn't that be totally wonderful? And a final thing that would be great would be if you as a module package writer would have access to the database and system setup harness that the manager uses for the episerver install. Then we would have a full featured installer for our episerver sites!
  2. I actually think you can put a myfile.systemsetup file in the package too, and have EPiServer set up the file access rights and also apply IIS (metabase) settings for you. Check your C:\Program Files\EPiServer\Manager\Download folder, and look for DefaultEPiServerSite.systemsetup for an example on how to apply these settings.
  3. Thanks Steve! Had my suspicions of that, will check it out!
  4. so with the DefaultEPiServerSite.systemsetup i can add/modify existing users credentials ??
  5. so with the DefaultEPiServerSite.systemsetup i can add/modify existing users credentials ??
Post a comment    
User verification Image for user verification  
EPiTrace logger