DEV Community

loading...

Nuget restore issues after Umbraco upgrade

dawoe profile image Dave Woestenborghs ・2 min read

Ever experienced other developers in your team reporting issues with the Umbraco backend after you did a upgrade of the CMS using nuget ?

I have. But I never really figured out what was causing it. So often I gave the following 3 options to them :

  • Force a nuget reinstall
  • Download the zip and extract the umbraco folder.
  • Get a new clone from source control.

Lately people started reporting issues on the forum and issue tracker after upgrades to 8.12.2

So what is going on ?

As far as I can see is that everybody reporting issues is using Visual Studio and have installed Umbraco using Nuget. I suspect most of them also exclude the umbraco folder from source control.

That is how I set up my Umbraco projects as well.

So in this setup one person upgrades umbraco locally by updating the umbraco nuget packages. This person will not experience the issues. After the upgrade the changes are pushed to source control and other team members will pull them to their local environment. When they build the solution visual studio will restore the upgraded nuget packages.

But running the backoffice will suddenly produce errors on their machine.

So why is this ? Apparently a nuget restore just downloads the packages but does not copy the files to your VS project. This is a long known [issue[(https://github.com/NuGet/Home/issues/3787) with nuget. But this also means your umbraco folder does not get updated when restoring the nuget package.

How can we fix this ?

There are several ways how to deal with this problem. I already mentioned 3 earlier, but these manual steps to be taken. So let's have a look at some other options.

Source control the umbraco folder

This has the advantage that all changes in the umbraco folder made by nuget upgrades are in source control.

But personally I don't like this approach. You will be including more than 2500 files in your source control that you will not be changing yourself.

You don't include your /node_modules or /packages folder in source control either.

The official documentation actually mentions you should exclude the folder from source control.

Including the umbraco folder in the VS Project

When you set up a website in Visual Studio and install Umbraco using nuget by default the umbraco folder is not included in the VS project. And remember that I said earlier that the umbraco does not get updated when restoring the nuget package. This is the reason.

So a easy way to include your umbraco folder in your vs solution is by adding this to your csproj file

<Content Include="umbraco\**\*.*" />
Enter fullscreen mode Exit fullscreen mode

With this line in place a nuget restore will add all missing files to the folder.

My personal preference goes to this solution.

What do you think ?

I am interested in hearing from others if theu source control the umbraco folder or not. Or that they have experienced issues like this before.

Discussion (0)

pic
Editor guide