Upgrading
With the CLI

Oct 03

Introduction

Upgrading Sitefinity continues to improve. Back in the day, it was best to upgrade by each major version. Then NuGet packages came along and support for upgrading multiple major versions was supported. Now we have CLI and as of 13.1 it is quite robust and the way going forward I think.

All the upgrade paths from any version are catered for in the Sitefinity docs. To use the CLI you currently need to be on Sitefinity 12.0 or higher. There is talk of targeting older versions but for now, you will have to get to 12 first. Have a read of the CLI upgrade process and I will tell you what I ran into and did to ensure a smooth process.

Update March 2021
Sitefinity have released an update to the CLI and you now no longer need to set the Execution Policy beforehand.

It's not Faster

Don't expect that this is a lightning-fast process. It still takes some time, even more so than what it would take me to upgrade NuGet packages. To be fair, it is doing a lot more and doing it hands-off.

Getting Started

The first part is, of course, downloading the CLI to your machine. I went for the prebuilt version. I extracted it to a 'folder' on my machine and I run it from that folder. You can also add it to your PATH system variables to run it from anywhere.

You can also get this included in your CI build steps. Personally I am not sure I would want to do this. When I am upgrading a project I tend to do it locally, test locally, fix locally and check it in as a commit. Not sure I would be comfortable including this as an automatic build step.

The minimum command to kick this off is:

sf upgrade "{{path to the solution you want to upgrade}}" "{{version you are upgrading to}}"
sf upgrade "D:\TestProject\SitefinityWebApp.sln" "13.0.7300"

But a few considerations before you do this.

Run the command prompt as an administrator. The process does a lot of things including opening Visual Studio, loading your solution and accessing NuGet to download and install files. If, as an example, you use IIS to run your project, that needs Visual Studio to open as an administrator otherwise the project will fail to load and you will need to start again.

You may get errors about PowerShell not being able to execute due to local policy restrictions. Check your current policy by running Get-ExecutionPolicy. If you do, you can try running PowerShell with administrator privileges and execute:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser

And make sure you undo that after the upgrade. Of course, set it back to what it was in the first place.

Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope CurrentUser

Another thing you may want to add is a few extra switches to make it even more hands-off.

 --skipPrompts --acceptLicense

I still found I needed to say/acknowledge a [Y]yes during the NuGet install process but apart from that nothing to do except drink coffee and tell your project manager your busy upgrading.

Once done, remember it does take some time, don't forget to add your new licence. Then, 'Clean' the solution to get rid of old build files that may be hanging around in your bin and obj folders. Finally, do a build then run the solution.

Wrapping Up

I have upgraded three projects this way now. The first one I worked out all the above notes and the other two went really well.

What I would like to see is a 'reset' option. If I have a project that has been manually upgraded till now but I don't actually want to upgrade it but do I do want the CLI to run through and check that all is good. I tried this but it didn't really run. It seemed to detect that I was already on that version and then skipped out. Of course, newer updates to the CLI may have already addressed this since I did that test. In my case, I just upgraded to the next minor patch release.


Darrin Robertson - Sitefinity Developer

Thanks for reading and feel free to comment - Darrin Robertson

If I was really helpful and you would buy me a coffee if you could, yay! You can.


Leave a comment
Load more comments

Make a Comment

recapcha code