Yet another “Yet another” blog post on how to upgrade CMS 7 to latest CMS (7.9.X)
You sure have done a few upgrades by know but I hadn't. So I thought I would write my experience about upgrading a CMS 7 website to the latest release. There are a few blog post about this subject and I will use them as reference, mainly because they are covering most of the important stuff.
But since non of them talked about the complete process of upgrading both dev.environment to production this blog post will cover these subjects or at least describe the steps I did to complete a upgrade process from dev to production.
Upgrade your development environment.
Of course we start with dev.environment, but to do so you probably develop the same way I do. By that I mean that you use the local IIS Express server inside Visual Studio. Since upgrading with Deployment Center is the way we upgrade to 7.5 we need to figure out a way to get Deployment Center to find your dev.environment.
Since you have everything up and running already you just need to add a new instance in your local IIS server and set the physical path of the new website to your directory, see picture below.
Now you have an instance that you can find with Deployment Center. The upgrade process is straightforward but if you need more information please visit Teds blog post, see reference nr 4.
- Run Upgrade site with SQL Server database
- Run Upgrade/disable addons.
Site is now running on 7.5 so what is next? Before we try to compile our website we need to upgrade our Nuget packages so that we use the latest when building and copying the binaries to the bin-folder.
EPiServer handles this straightforward and you should be able to upgrade most of your nugets without problem. When that is done you can compile your project. If you like me have used the attribute AvailablePageTypes, you will need to change that to AvailableContentTypes.
Since we are upgrading to the latest version of the CMS, when I wrote this, 7.9.0 we also got changes that we need to install into our database. This is done via the Nuget Package Manager Console, see reference 1. If you do not run this you will get an error saying you need to run it
Ok, now you might think you are done with your development environment. But what I found out was that my AppData-folder was source controlled. So when I tried to checkin my upgraded project I got like thousends of errors. The errors were related to the fact that the upgrade process had moved and or deleted files. So when I tried to checkin these files I was not able to.
To fix this issue I undid my pending changes for the specific error. Then I deleted the folder from the source control tool instead and made a checkin. The time I spent was like 5 minutes. EPiServer had created new folders for the new versions so it was easy to delete old folders manually.
The errors I got was: ..\AppData\ModulesRepository\CMS.2.1.82\CMS.2.1.82.nupkg: Could not find a part of the path
Enable Nuget Package restore for your solution
My project did not use nuget package restore. Since this feature is awesome you should enable that for your project as well. Once that is done you are able to remove all your nuget packages from your repository (TFS/Git). All packages will be downloaded when you compile your project for the first time.
Migrate VPP folders and add content types
Finally we need to migrate the VPP and add support for strongly typed files. Ted has written a great guide for this in his blog post, reference 4. So my suggestion is that you follow his guide. But I would like to add that when you have done this you might need to change a lot of code in your project. In my case I was using ImageResizer.net for croping and image manipulation. The new way of handling files is not supported so we need to do some changes and also add some code to our project.
Changes to make ImageResizer work
After migration of the VPP I got an runtime error saying I had a culture problem but the problem was that ImageResizer did not work properly with the new way of handling images. The error was:
To fix this I first added this excellent nuget package: http://nuget.episerver.com/en/OtherPages/Package/?packageId=ImageResizer.Plugins.EPiServerBlobReader. I then changed the calls for rendering images to use the new GetUrl:
A couple of changes later I was up and running again.
When all this is done you have updated your dev.environment and can checkin the result. Finally we need to upgrade our production environment and release the new code.
Since we have made all changes need to our project and it compiles we can now perform the upgrade on our production environment.
- Do a complete backup!
- Run the scripts from Deployment Center to upgrade to 7.5
- Publish code to production
- Copy folders for upgrading to 7.9.x
- Modules – in AppData
- ModulesRepository – in Appdata
- ModulesBin – in website root
Since we have upgraded to 7.9.x I needed to deploy the folders that were updated by our nuget packages as well. If you do not do this edit mode will most likely stop working.
If you remember we also did an upgrade of the database. Now we need to do the same with the production database. In this case we can not run the same script. EPiServer help us with an export of the schema that is independent of visual studio. From Visual Studio you can run Export-EPiUpdates in the package manager console. You get a package containing files and scripts that you need to run, see reference 1.
I ran the sql-script directly on my database and I was good to go
No your website should be up and running on the latest release of EPiServer CMS 7.5.
I should add that I keep my config-files for production the same as for dev. Therefore I could publish them as well without any problem. A lot of changes are made to the config-files so before you start be sure you can publish the files you have locally. In my case I used config-transformations for handling different environments.
Download a new license.