Orchard CMS is a great asp.net MVC based CMS which is really flexible but as it stands its upgrade process is a long and complex process far from the simplicity of WordPress and other competitors. After you have followed their many-step upgrade process you will need to bring any custom themes or modules back into your main solution. At this point I started getting hit with compile time errors. With a huge solution like Orchard it can be be daunting task to figure out the solution but after some digging around I figured out what was causing this particular issue.
The issue first began when I took one of the more popular Orchard modules, Vandelay Industries. When I dropped the source in and went to “add existing project” the references for Orchard all had alerts on them.
My gut reaction was that something had changed in Orchard since the last version and new versions of the modules would be needed. However, when I checked the website it seems there hadn’t been any new releases since Orchard 1.9 had come out.
The next stop was thinking that the references were somehow pointing to the wrong folders because I had copied the projects over from the old install. Deleting and recreating them didn’t help.
Changing the target framework
At this point I widened my search and dropped the mention of Orchard CMS, instead just looking for a stripped down version of the error message. That’s when I had the breakthrough.
This obscure message was actually complaining because the old module projects were compiling against .NET Framework 4.5 but now Orchard uses .NET Framework 4.5.1. The modules were getting confused because they were trying to pull in Orchard assemblies that had been compiled against newer versions of the .NET Framework!
Fixing the issue
The solution is to set the .NET Framework to the same version as the rest of the solution.
Here is a step by step process:
- Right click offending project in the Orchard solution
- Set Target framework drop down to
.NET Framework 4.5.1(or if you’re reading this in the future, whatever framework version of .NET Orchard is currently compiling against)
GOTCHA – Don’t use your keyboard
There is a bug which is in definitely in Microsoft Visual Studio Community 2015 but probably in other versions as well. When you are changing the target framework you must click the option with your mouse not using an arrow keys / enter combo.
There is an extra event which is triggered when you properly change the selection. When you click on the new framework version you should see a dialog box offering to update your
web.config to target the newly selected version. If you don’t see something like this then you need to try again:
As soon as you press
Yes the project will update and close.
Repeat this process for each of the troublesome projects and you will soon have a compiling version of your Orchard CMS based website!