I often use Umbraco as a CMS for my web projects, and NuGet for referencing other libraries. This made me wonder whether Umbraco could be deployed via Nuget. The short answer is, it is possible, but it does not work very well. Here is my experience.
I started to read the NuGet docs to figure out what a NuGet package actually is.
A NuGet package is a file that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. A NuGet package is comprised by these three things:
- tools – The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.
- lib – Assemblies (.dll files) in the lib folder are added as assembly references when the package is installed.
- content – Files in the content folder are copied to the root of your application when the package is installed.
The documentation also indicate that NuGet was not designed for a project like Umbraco with so many files and such a complex web.config file. But I wanted to try and see how and if it was actually possible.
The Umbraco project consists of libraries/assemblies and content, so it should be rather easy to create the NuGet package.
The first step was to download Umbraco 4.7.1 and go through the required assemblies and web.config. Initially I located assemblies that could already be found on NuGet and added these dependencies to the NuGet package. It later showed, that there would be versioning problems which I was not able to fix.
So instead of using dependencies to other NuGet packages as NuGet was actually intended, I just added all the assemblies released with Umbraco 4.7.1.
The assemblies that gave me the most trouble was ClientDependency and ICharpCode.SharpZipLib.
ClientDependency was actually already in the NuGet feed, but the configuration transformation made from that NuGet package combined with the web.config transformation from the Umbraco package, yilded an invalid web.config file. ClientDependency was therefor provided as an assembly directly from the Umbraco package and not as an external dependency.
The assembly ICSharpCode.SharpZipLib was also found in the NuGet feed, but Umbraco 4.7.1 required a specific version (0.85.5.452) that NuGet could not provide, and this assembly was as such also added as a part of the Umbraco package.
The web.config configuration file for Umbraco is long and rather complex, and that makes merging of multiple web.config files difficult. The configuration transformation features in NuGet are limited, so you should expect problems when adding the Umbraco package to an existing website. The best results I achieved was when the package was added to an empty website or web application.
But even though a web.config file is almost empty, you should still prepare for some clean up.
The Umbraco 4.7.1 binary release containes more than 1500 files. NuGet was not designed for this number of files and does not handle it very well. A complete package installation can take up to 5-10 min. depending on you machine and SSD/HDD configuration.
The following describes the steps I used to run the Umbraco NuGet package against a web application project and the problems that arose.
1. Open Visual Studio 2010 and create an empty C# web application project
2. Open the NuGet Package Manager Console
Install-Package "Umbraco" -Source "c:\[NuGetPackageFolder]"
NuGetPackageFolder: Replace with the path to the folder containing the Umbraco.4.7.1.nupkg file. Important do not give the full path to the file, just the folder
4. Hit [ENTER] and wait for NuGet to do its work
5. Wait for the following two messages:
Successfully installed 'Umbraco 4.7.1'.
Successfully added 'Umbraco 4.7.1' to WebApplication1.
6. Compile and receive an error from web.config. (Multiple System.Web -> Compilation sections are present)
7. Remove the first and compile and run again
<compilation debug="true" targetFramework="4.0" />
8. At this point everything worked and I was able to follow the usual Umbraco installation steps
Umbraco is a fantastic CMS and NuGet is very cool, but together is not a good idea.
My goal was to find a way for installing Umbraco to a web project via NuGet, and that is not impossible, but I would not recommend it. I find it a lot easier to simply download the Umbraco released ZIP, and then extract and drag all files to my web application project. So that is what I will do
But if you still wants the Umbraco NuGet file, you can download it here.