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>
    </head>
    

// 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(); }


11 things I have learnt in first 3 years of work at Microsoft

I am very lucky to have started my career in one of the best companies in the world – Microsoft. And as expected I have learnt a lot from it in past three years of working here. Microsoft has a very unique and distinct work culture, with a lot of great folks to learn from and look upon.

I am going to list down and share few things that I have learnt at Microsoft. I am hopeful this would help those who have just joined the IT industry or are going to join it in near future.

1. I love Microsoft

Loyalty - I believe this is the first and foremost belief on which you must build the foundation of your career. And this is what the company expects the least out of you. After all, they are the one who are paying you. Surely, you can avoid evangelizing the products your company makes – but think for a second, if you being an employee don’t like/buy/use the product, do you think anyone else will?

Bonus Tip: You *should* not use company resources for your personal use. Also, being a appropriator won’t serve you in the long run.

2. Stand and Deliver

If you deliver what you committed, you are achieved and deserved your Salary. The terms “committed”, “achieved” are probably specific to Microsoft, but I think there is similar terms and rationale used everywhere else. And if you fail to keep your promise, its clear you are “underachieved”.

I feel this is the most important learning I have got at Microsoft. We are not used to think like this. Isn’t it?

3.  Find your “Sachin Tendulkar” at work

You need to find someone at work whom you idolize. Build relationships, make him/her as mentor and try to learn maximum from them. Role models will help you focus and channelize your energies in one direction – your goal. Read the next one which completes this point.

4. Trust the right people

Its really difficult to do this right the first time. You are an new entrant to a unknown group of people. You faced this situation earlier when you were a fresher in your first year of college. But you had lot of time to make mistake and improve on it. Trusting wrong people, and looking up to them as role model will influence you in a wrong way. My advice, be cautious and take the advices with a pinch of salt.

5. “I hate politicians”

Stay away from Office gossips and politics. They are breeding ground for killing your creativity and loyalty. We all are/will be subjected to politics at some point of time. And its better to ignore than react to them. Believe me, you’ll get into these sort of situations now and then. Its very crucial to be cognizant and not take sides and try to leave the discussions apologizing and without hurting anyone’s sentiments.

6. Differentiating crows from crows

It’s important to listen to the feedback – good or bad. But its as important to disregard the "Ad Hominem" feedback. This kind of feedback is just blatant negative without soul and thought. These is the kind of feedback that will make you think, "Am I like this?”, “Did I do that?”. Instead of ignoring it, it’s always great to have a candid talk with the person sharing you this feedback about if this is something that he/she noticed couple of times and seek for help and guidance.

Bonus Tip: Always share constructive feedback – one that they can use it to improve. The tone of the feedback determines if you want to help him/her or point out their faults.

7. Humpty Dumpty had a great fall!

I think its more important to fall than to succeed. You learn a lot while falling (oops), fallen (sigh), trying to stand (urge) and standing to the challenge again (I can do it!). Also don’t spend time and energy explaining or reasoning out why you failed. Instead use this as an experience to avoid such mistakes in future.

8. Bad Appraisal

It’s no use crying over spilt milk. Get over it, act on your next steps. Based on my discussion with number of colleagues – peers, manager and organization leaders, they never recollect about their ratings/rankings. Not saying that you shouldn’t care about it. But what’s gone for the past year, cannot be changed. This ranking made them more determined to prove a point. Hence don’t let the rankings/ratings which I refer as “Moh Maya” bring you down. Focus on the next point instead!

9. Goal!

Identify your life goals. Stay focused and channelize all the efforts towards this one or two things you want to achieve in your lifetime. Also I find that it’s good idea to experiment when you have nothing to lose at the start of your career. Always weigh and see what you are sacrificing to achieve it and then decide its real worth.

10. Date with my GF v/s Work

Don’t try to mix personal and professional life. Keep your Work-Life-Balance healthy and do give the time your loved ones deserve. You’ll get lot of opportunities at work to become successful, but one miss at personal life, you’ll never get it back.

11. Extras

If you have reached this point, you are not bored and find some value in my post. So I think you deserve to know more from my experience. Which is why I am sharing the following tips I think are noteworthy, specific to –>

Company:

  • Know Your Company – Don’t they do a background verification on you when they hire you? On a serious note, try to know what your company does to earn the moolah, promoters or shareholders, its CSR initiatives, stock price, impact to the world – the more you know your company, more you’ll be attached to it.
  • Help your company products to improve by sharing the feedback, finding bugs and doing usability tests.

Team:

  • Its as critical to blend into the team as to stand out. Remember, you are a team member first!
  • Try to make your team successful, you’ll eventually become successful.
  • Respect the various cultural background of the team members and give enough space for your team partner to feel comfortable.

Personal:

  • Be independent and have an identity of yourself. You’ll be in a lurch, if the person (could be your manager) you are dependent on to speak for you, leaves the company.
  • Help all the people you can. When you fall down, you’ll have lot of hands to pull you back.
  • Talk less, Do more. Take initiatives to change the things you don’t like or that can be improved.
  • Read lot of books – non-fictional, management. It will help shape your outlook and attitude. Also don’t shy from reading self-help books.
  • Don’t judge or build perception. Instead try to know and reason out the situation to which he/she was subjected to.
  • Lastly you should follow your dreams. Don’t lose them. I mean literally too –> don’t lose your sleep over work! Work comes as soon as you finish it!!!

 

Hope it helps! It was an immense pleasure to share it with you all. :)

Do share your own experiences and feedback!

Regards,
Bhavik