Custom module install/upgrade scripts

Stephen Rushing asked on March 12, 2015 14:08

I'm working on some custom modules, and I need to execute some code when it is installed. Thinking ahead, I need this install code to be patterned in a way that supports version comparison, and can run a series of upgrades depending on those versions.

I think this is where to start, but coming from a PHP background, I'm ignorant to the generic .Net practices of how to achieve this, so I'm looking for general and Kentico-specific advice.

I was thinking I could store the version as a static string on my module class, and use System.Version for comparison.

I'd place all of my install scripts in App_Code/CMSModules/ModuleName/Install. I'll need to determine what version the Kentico instance already has and compare it to my class's static version, then loop through the available install scripts, comparing versions and executing as necessary. Where do I store that version and the list of install scripts to loop through? I assume there are some Kentico-specific standards for this.

Thanks in advance!

Correct Answer

Brenden Kehren answered on March 14, 2015 16:58

The first link you mentioned for Modules to run custom code is one of them.

Global events

Available global events - specifically Import/Export

Creating custom modules the last section talks about exporting and importing your module and what is available and what isn't.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on March 12, 2015 17:59

Once a module is installed or imported, if you attempt to import it again (after you've made changes on dev or somewhere else) it won't install all of the module like it initially did. So you should research how the Kentico module development and import process works out of the box. Adding a version # to the module within Kentico would be nice although as I mentioned it wouldn't be much help if it doesn't update the whole module.

I'm pretty sure on the initial import of your module you could add a global handler to do some checking on subsequent imports for that module and then code in some additional updates. I've never done this but I've read about it.

1 votesVote for this answer Mark as a Correct answer

Stephen Rushing answered on March 13, 2015 21:12

Thanks, Brenden. Any links to the resources you referenced would be helpful. I'll need to perform some non-Kentico tasks for at least one of the modules (a NodeJS proxy) when it's installed, and presumably in future upgrades. Given that need, I wanted to glean and established a solid iteration/upgrade pattern for all of my modules that exceed the scope of the import/export process.

0 votesVote for this answer Mark as a Correct answer

Stephen Rushing answered on March 16, 2015 19:48

I've been pouring over these the last couple of weeks while developing my modules, but wasn't sure if I was missing some. Thanks again for taking the time to answer!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.