Today's post isn't necessarily about troubleshooting Umbraco in particular, this post is more of an overview of the issues I encountered trying to get a C# Umbraco website up and running with a build server (Cruise Control). Before I tried getting the project to build and deploy correctly from the build server, I made sure that the project successfully built and published correctly on my local machine. The first issue I encountered, was this one:
SVN was being used as the course control repo, so the error made it obvious there was a merge issue, but it didn't make it obvious which file was causing the issue. After trying an 'Entire Solution' search in Visual Studio, I decided to change the MsBuild logging level on the server. The build flag was set to, /verbosity:quiet. The option of logging level includes quiet, minimal, normal], detailed and diagnostic. For troubleshooting, I tend to find detailed the most useful option. After changing this and pushing a new build I now had this:
This allowed me to figure out the issue was somewhere in the bin\Debug folder. To fix this, first I added the folder to the SVN ignore list and then on the build server I did a SVN 'Resolve'. After pushing again I was now faced with this issue:
This error was very annoying and not immediately obvious what the fix was. In my project, I was importing System.Runtime using Nuget so it was referenced. If was also building locally, so it looked likely the build server was missing something. In the end, the problem was with using 4.5.2 and not having the correct dependencies installed on the server. After some Google research, it seemed liked a lot of other people had to face a similar issue. Following some useful advice from Stackoverflow, installing the https://www.microsoft.com/en-gb/download/details.aspx?id=42637. Installing the dependencies so the build process could now compile my site was a good next step, although I was faced with another issue:
Server Error in ‘/’ Application. Attempt by security transparent method ‘WebMatrix.WebData.PreApplicationStartCode.Start()’ to access security critical method ‘System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)’ failed. 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.
This error was a bit of red herring. At first, I thought it was going to be something to do with the WebHelpers Nuget package. Instead, it was me being an idiot. The client's build process did not clear the website's webroot on a new commit. When I tried to push the 7.5 files, the old unneeded 6.2 assemblies and the new 7.5 assemblies got tangled up together in the bin folder and the result was the exception above. To fix the issue is straightforward, make sure you delete everything in your webroot before you copy all the new 7.5 files into it (remember to always backup). After triggering the build server again, the project built successfully and the site loaded and worked as expected. Conclusion Just because something works on your PC does not mean it will work on a different PC, or server. Getting a site to work on a build server can be annoying, I wasted a good half a day over a few simple issues. When you upgrade, my advice would be to always have confidence that your build works on your PC, after that if things go wrong the issue may be a result of the server being configured incorrectly.