Post build events for Package devs

When building Umbraco packages I always use post build events in Visual studio to "deploy" the bits to my Umbraco development environments. Since most of my packages support multiple versions of Umbraco I need to test the package on every supportedĀ  version of Umbraco. For every Umbraco version I have a complete website available in my Umbracosites folder.


And I'm using post build events to copy the package files to the Umbraco websites.

XCOPY "$(ProjectDir)bin\CMSImport*.dll" "F:\umbracosites\umbracoV47\bin\" /y
XCOPY "$(ProjectDir)bin\umbraco.licen*.dll" "F:\umbracosites\umbracoV47\bin\" /y
XCOPY "$(ProjectDir)controls\*.ascx" "F:\umbracosites\umbracoV47\umbraco\plugins\CMSImport\usercontrols\" /y
XCOPY "$(ProjectDir)pages\*.aspx" "F:\umbracosites\UmbracoV47\umbraco\plugins\CMSImport\pages\" /y

XCOPY "$(ProjectDir)bin\CMSImport*.dll" "F:\umbracosites\umbracoV48\bin\" /y
XCOPY "$(ProjectDir)bin\umbraco.licen*.dll" "F:\umbracosites\umbracoV48\bin\" /y
XCOPY "$(ProjectDir)controls\*.ascx" "F:\umbracosites\umbracoV48\umbraco\plugins\CMSImport\usercontrols\" /y
XCOPY "$(ProjectDir)pages\*.aspx" "F:\umbracosites\UmbracoV48\umbraco\plugins\CMSImport\pages\" /y

XCOPY "$(ProjectDir)bin\CMSImport*.dll" "F:\umbracosites\umbracoV49\bin\" /y
XCOPY "$(ProjectDir)bin\umbraco.licen*.dll" "F:\umbracosites\umbracoV49\bin\" /y
XCOPY "$(ProjectDir)controls\*.ascx" "F:\umbracosites\umbracoV49\umbraco\plugins\CMSImport\usercontrols\" /y
XCOPY "$(ProjectDir)pages\*.aspx" "F:\umbracosites\UmbracoV49\umbraco\plugins\CMSImport\pages\" /y

Post build events

Separating the package bits and websites allows me to completely destroy an Umbraco environment without having to worry about it, reinstall, or restore the environment when it is destroyed and deploy the bits from Visual studio and all is working again.

Improving this build process

Until recently I was very happy with this approach. A new version of Umbraco was released every few months, so every few months I needed to update the post build event. But then a new version of Umbraco was released every few weeks and IĀ  needed to update the post build event more often and when a new item is added to the build script I needed to copy this for every environment in the script. That got me thinking about a new way to do post build copies.

If you are a bit familiar with Post build event scripts you know that you can use variables in these scripts. One of these variables is the $(ConfigurationName) variable, which holds the value of the current Build configuration. By default it comes with two configurations Debug and Release. But when you go to Build, configuration manager and hit the Active solution configuration you see you can create your own.


When you build your project the $(ConfigurationName) will be replaced with the actual value of the configuration. So by creating a UmbracoV410 configurationĀ  I can update my post build script to the following and it will replace $(ConfigurationName) with UmbracoV410 and files will be copied to f:\umbracosites\ when using the UmbracoV410 build configuration. By creating configurations for every Umbraco version the package supports the post build event will work for every Umbraco environment.

XCOPY "$(ProjectDir)bin\CMSImport*.dll" "F:\umbracosites\$(ConfigurationName)\bin\" /y
XCOPY "$(ProjectDir)bin\umbraco.licen*.dll" "F:\umbracosites\$(ConfigurationName)\bin\" /y
XCOPY "$(ProjectDir)controls\*.ascx" "F:\umbracosites\$(ConfigurationName)\umbraco\plugins\CMSImport\usercontrols\" /y 
XCOPY "$(ProjectDir)pages\*.aspx" "F:\umbracosites\$(ConfigurationName)\umbraco\plugins\CMSImport\pages\" /y 

Optimized Post build events

Hope this helps you make it easier to test packages when developing for multiple versions of Umbraco!

Merry Christmas!

Richard Soeteman

Richard is on Twitter as