whihathac's Den

code is poetry

Upgrading BlogEngine.NET from version 2.0 to 3.0

I've been using BlogEngine.NET as by blog provider since 2007! I've really have been its early adopter since version v1.2 and I used to upgrade it manually each time a new version came out until version v2.0. After version v2.5 had the requirement of .NET 4.0, which my hosting provider didn't provide I was literally stuck. Recently I moved my domain to Azure Websites which has allowed me to upgrade it to the latest version v3.0.

I've upgraded it from version v2.0 to v3.0. I followed the steps mentioned here -  but then I realized that this upgrade is just an upgrade from v2.9 to v3.0. I realized this when I logged into my Admin section and I couldn't load up any settings. I posted for help in the forums, but no avail.

Finally I thought of verifying all the steps for all upgrades from v2.0 ie. v2.0 -> v2.5 -> v2.6 -> v2.7 -> v2.8 -> v2.9 and finally v3.0. Fortunately BlogEngine.NET has archived its incremental upgrades here.

So presenting the steps for upgrading BlogEngine.NET from version v2.0 -> v3.0.

Disclaimer: I use xml files for storage not DB, so that path is essentially untested. But I have consolidated my learnings from all the upgrade steps listed. Please do let me know if you face any issues.

Upgrading to BlogEngine.NET v2.0 to v3.0

File & Folder Changes

There are new files and folders in BlogEngine.NET v2.5 onwards, and some files/folders that existed in previous versions of BlogEngine.NET may no longer exist in BlogEngine.NET v2.5 onwards.  We've upgraded to ASP.NET 4.5 and there are several important updates that have been made to the web.config file. BlogEngine.NET starting from v2.5 is also making use of the new Razor technology for page markup.

Recommended Path to Upgrade

The cleanest way to upgrade to v3.0 is to start from a v3.0 installation, and then copy your existing data and settings into v3.0. The upgrade steps follow.

A couple of the steps are related specifically to those who use a database for storage, and a couple are related specifically to those who use the default XML storage (non-database). You can skip the steps that don't pertain to your method of storage.

The cleanest way to upgrade to latest version is to start from fresh installation, and then copy your existing data and settings into new version. The upgrade steps follow.

1. Backup

Make a full backup of your existing BlogEngine installation. This is very important. If anything goes wrong, you can always restore from your backup.

2. Install latest version

Install latest version on your computer, in a new folder (Installation).

3.  Web.config file (for non-database installations)

As noted above, because of the large number of changes to the web.config files, it is strongly recommended you use the web.config file that is included with v3.0.  If you have any custom settings in your existing web.config files (e.g. appSettings), it will probably be easiest to copy your custom settings into the BlogEngine.NET v3.0 web.config file.  If you have any custom settings, those can be copied into the v3.0 web.config file now.  Otherwise, you can just use the v3.0 web.config file as-is.

4.  Web.config file (for database installations) (NOT TESTED)

If you will be using a Database for data storage, Web.config files you can use are located in the /setup/ folder.  Because of the large number of changes to the web.config files, it is strongly recommended you start from these sample web.config files, and copy your specific connection string into the sample web.config file.  For example, for SQL Server, in the /setup/SQLServer folder is a file named SQLServerWeb.Config.  For MySQL, the file is /setup/MySQL/MySQLWeb.Config, etc. Copy this file to the blog root, delete the existing Web.config file in the blog root, and then rename this sample config file to Web.config (i.e. rename SQLServerWeb.Config to Web.Config).

At this point, the Web.config file you copied to the blog root and renamed contains a sample DB connection string.  The sample DB connection string will look similar to:

connectionString="Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogEngine;"

Replace this sample connection string with the connection string in your existing Web.config file.

If you have any other specific customizations to your existing Web.config file (e.g. appSettings), add those into this Web.config file.

5.  Database Upgrade Script (for database installations)

If you are using a Database to store your data in, you will need to run multiple DB upgrade scripts which will help you upgrade from v2.0 to v3.0.  Each of the /setup folders has an upgrade script. For SQL Server, it is MSSQLUpgradeFrom2.8to3.0.sql.  For MySQL, it is MySQLUpgradeFrom2.6To3.0.sql, etc. If you are upgrading from a version prior to 2.0, you will need to first run the upgrade script(s) to get your DB up to v2.0 and then subsequently v3.0. For example, if you are upgrading from v1.6, you will need to first run the 1.6to2.0 script, and after that, run the 2.0to2.5 script and then 2.5to2.6 script and finally 2.6to3.0 script! Run this script in your existing DB.

6.  App_Data folder (for BOTH database and non-database installations)

In your v3.0 installation is the App_Data folder.  Delete all of the files and folders in the App_Data folder EXCEPT for the following 3 new items introduced in BlogEngine.NET 2.5 onwards.

  1. The blogs.xml file directly under App_Data.
  2. The blogs directory directly under App_Data.
  3. The labels.txt file directly under App_Data.
  4. The packages.xml file directly under App_Data.
  5. The packagefiles.xml file directly under App_Data.
  6. The blogs directory under App_Data

Do not delete these 6 items.  Everything else can be safely deleted from the App_Data directory. 

If you are not upgrading from version 2.0, I will recommend you to check specific upgrade story by deducing it from incremental upgrades here.  

Once everything else has been deleted, the only 5 items remaining in the App_Data directory are those 3 items listed above.  Next, copy all of your App_Data contents (files/folders) from your existing blog to the App_Data folder.

Note:  This step should still be performed even if you are using a database since even with a database, the App_Data folder is still used for storing certain items such as files, images and some other small miscellaneous files.

7. Scripts folder

  1. Move scripts from /Scritps/Header to /Scripts/Auto
  2. Move scripts from /Scripts to /Scripts/Auto

Starting with v2.7, JavaScripts added to /Scripts folder were automatically added to the end of the page at runtime. Scripts added to the /Scripts/Header were added on top of the page before any HTML load. All these auto-loaded scripts have to be moved to /Scripts/Auto to keep working this way. Main reason for this move due to /Scripts folder been a default install directory for NuGet packages and we want to avoid conflicts and keep common conventions with VS and ASP.NET. Make sure you don't have duplicates in the /Scripts/Auto, all scripts from this folder will be auto-loaded in the alphabetical order. If script depends on the other script, you can rename it to sort properly.

8. Styles folder

  1. Move css styles from /Styles to /Content/Auto
  2. If you have any folders under /Styles, move them to /Content
  3. Delete /Styles folder

Similar to situation with JavaScripts, CSS styles moved to location used by VS/ASP.NEN/NuGet

9. Migrate bin folder

Copy files from blog "bin" folder to new installation if they don't exist there. Do NOT override any files, only copy not existing DLLs.

10. Migrate blog theme

Copy your theme from current blog to new installation.

Because in version 3.0 "themes" moved to Custom/Themes, open site.master template in any text editor and change all references from "themes/" to "Custom/Themes/", then save changes.

At this point, should be able navigate to blog and brows pages. FireBug or Dev Tools should not display any JavaScript errors during navigation.

11. Migrate widgets

Copy folders and files from "/widgets" to "Custom/Widgets" if they don't exist there. Only not existing files/folders should be copied, no overrides.

Because in version 3.0 "widgets" moved to "Custom/Widgets", in any custom widget just copied replace all references from "widgets/" to "Custom/Widgets" (by opening and modifying .ascx files).

12. Migrate extensions

Because in version 3.0 BlogEngine moved from website to web application project, all extensions must be compiled before deployment to web server (walkthrough on compiling website extensions).

13. Scripts and Content and Robots.txt

Some custom plugins might have scripts, styles and images typically in "/Scripts" and "/Content" folders. Any files that do not exist in new installation should be copied from old blog "/Scripts" and "/Custom" folders. Similarly, if you have customized the robots.txt file, copy it into the v3.0 folder you have been working on.

12.  Deploy to Web Server

Please make sure you have a backup of everything you will delete (see step 1).

Because you will have files on your web server that no longer exist (or have been moved) in v3.0, it is best to delete all of the BlogEngine.NET files and folders on your web server, and then upload the new v3.0 files and folders you prepared in the previous steps.

Multiple Blogs in Single Installation

Starting with BlogEngine.NET v2.5, it introduces a new "multiple blogs" feature that allows you to create multiple blog instances within a single BlogEngine.NET installation.  If you will be running a single blog instance (which most people will be), there is nothing you need to do.  Even if you will run multiple blog instances, there is still probably nothing you need to do.  However, if you are using an existing custom theme, or using any custom extensions or widgets, those may need updates to be fully multiple-blog compatible.  Detailed information on this can be found at the link below.

Introducing Multiple Blogs in Single Instance for BlogEngine.NET

Notes for version 3.0

- Version 3.0 added few new rights, go to admin -> users -> roles, select "administrator" and make sure all rights are checked for this role.

- Switch to new gallery under custom -> gallery, in gallery settings add new feed pointing to "http://dnbe.net/v01/nuget" and set it as default.

FAQs & Troubleshooting

  1. Requires .NET framework 4.5

    Requries full trust in IIS

    Requires Razor (web pages) for .cshtml files

  2. You receive the following error message:

    The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration

    The likely cause for this is because your website is running ASP.NET 2.0 or 3.5.  BlogEngine.NET 3.0 requires your website run in an ASP.NET v4.5 application pool -- ideally in the Integrated mode pipeline, but Classic should work too.

  3. I followed steps above, but I'm getting JavaScript/CSS errors after upgrade

    You might have custom code or extensions/widgets that use script or style references pointing to old locations. You'll have to manually change those references to use /Content instead of /Styles for example. You can use FireBug or alike to identify scripts/styles that not loaded properly.

  4. My Syntax Highlighter stopped working
    Syntax Highlighter now is a part of TinyMCE. To add it to your current theme, you'll need to update 2 files (check standard theme to see full example):

    // site.master
    <head runat="server">
     <link href='<%# Page.ResolveUrl("~/editors/tiny_mce_3_5_8/plugins/syntaxhighlighter/styles/shCore.css") %>' rel="stylesheet" />
     <link href='<%# Page.ResolveUrl("~/editors/tiny_mce_3_5_8/plugins/syntaxhighlighter/styles/shThemeDefault.css") %>' rel="stylesheet" />
     <script type="text/javascript" src="<%# ShRoot %>scripts/XRegExp.js"></script>
     <script type="text/javascript" src="<%# ShRoot %>scripts/shCore.js"></script>
     <script type="text/javascript" src="<%# ShRoot %>scripts/shAutoloader.js"></script>
     <script type="text/javascript" src="<%# ShRoot %>shActivator.js"></script>

// site.master.cs protected static string ShRoot = Utils.ApplicationRelativeWebRoot + "editors/tiny_mce_3_5_8/plugins/syntaxhighlighter/"; protected void Page_Load(object sender, EventArgs e) { // needed to make <%# %> binding work in the page header Page.Header.DataBind(); }

Comments are closed