I was planning to update a farm of EPiServer sites running EPiServer CMS 8.4 – 8.5 to EPiServer 9.4. EPiFind was running version 9 and ImageVault was running 4.7 with the aim to become EPiFind 11 and ImageVault 4.8.
Since these solutions reference the same packages in a circular way there wasn't any way to run any smooth update using Nuget, the console showed errors like
Update-Package : Unable to uninstall 'EPiServer.CMS.Core 9.0.0' because 'EPiServer.CMS 8.4.0' depends on it. At line:1 char:1 + Update-Package ImageVault.EPiServer + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Update-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand
I was in the world of pain realizing that I had to do this in a bit more manual way than originally planned but found salvation after a while, here is how I did it.
The works
Safety first: Back everything up, snapshot the machine(s), create a new branch, pray.
Open your project in Visual Studio and open the Nuget Package Manager Console. This isn’t any magic console, it’s PowerShell with a Nuget add-in.
Removing
To get started you must begin by uninstalling the following packages
Uninstall-Package EPiServer.CMS -RemoveDependencies Uninstall-Package EPiServer.Find.Cms -RemoveDependencies Uninstall-Package ImageVault.EPiServer.UI -RemoveDependencies Uninstall-Package EPiServer.Search -RemoveDependencies
Check the references of your projects ensuring there are no references left to EPiServer, EPiServer Find or ImageVault. You may have to repeat the process if you have references in multiple projects of your solution.
Reinstalling
Next step is to install the packages again with a modified dependency version, as of the date this article was written it wasn’t possible to install ImageVault directly with Epi 9.4 (or newer) using Nuget.
Install-Package ImageVault.EPiServer -DependencyVersion Lowest Install-Package EPiServer.Find.Cms -DependencyVersion Lowest Install-Package EPiServer.Find -DependencyVersion Lowest Install-Package EPiServer.Find.Framework -DependencyVersion Lowest Install-Package EPiServer.CMS -Version 9.0 -DependencyVersion Lowest Install-Package EPiServer.Search -Version 8.0 -DependencyVersion Lowest Install-Package EPiServer.Logging.Log4Net -DependencyVersion Lowest
This may take a while, get some coffee and check what’s new on Imgur.
Read more about DepencencyVersion in the Package Manager Console Powershell Reference, https://docs.nuget.org/consume/package-manager-console-powershell-reference#install-package
Updating and cleaning up
You are probably stuck with a project that might compile but won’t run due to dependency errors and missing libraries, this is normal when you install something using ‘DependencyVersion Lowest’. What you need to do is to update some libraries to a specific version, when done you’ll need to add some missing packages. Finish it all up by updating all EPi libraries once again.
Update-Package Castle.Core -Version 3.3 Update-Package Castle.Windsor -Version 3.3 Update-Package Microsoft.AspNet.Mvc Install-Package Microsoft.IdentityModel # required by EPi Find in some cases Install-Package Microsoft.Identity.Model.Extensions # required by EPi Find in some cases Install-Package ImageVault.EPiServer.UI Update-Package EPiServer.CMS Update-Package EPiServer.CMS.Core Update-Package EPiServer.Framework Update-Package EPiServer.CMS.UI Update-Package EPiServer.CMS.UI.Core
Update ImageVault
Download and install the latest version of ImageVault (4.8 when written) from EPiWorld, http://world.episerver.com/download/Items/ImageVault/imagevault-4-8-for-episerver-cms/.
Update the ImageVault Core and Instance using the EPiServer Deployment Center.
That should be it!
Common errors
Update-Package : Unable to uninstall
There may be various versions of the one I’ve posted above and if you get this error, run the guide above
Update-Package : Unable to uninstall 'EPiServer.CMS.Core 9.0.0' because 'EPiServer.CMS 8.4.0' depends on it.
Loader exception errors
If you get a loader exception from EPiServer it is probably EPiServer Find that can’t do its voodoo.
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
{"Could not load file or assembly 'Microsoft.IdentityModel.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca' or one of its dependencies. The system cannot find the file specified.":"Microsoft.IdentityModel.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca"}
{"Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
The solution is usually to install Microsoft.Identity.Model.Extensions and Microsoft.IdentityModel (see above). Please note that in some installations EPiServer Find also requires WIF (Windows Identity Foundation) to be installed, this is done by running the following command in a console
dism /online /Enable-Feature:Windows-Identity-Foundation
Feel free to contact me if you have any suggestions, questions or comments on this.