Issues Encountered Getting A Build Server To Work After Upgrading Umbraco From Version 6 to 7.5
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:
<error code="MSB3541" file="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets" line="3959" column="5" timeStamp="08/23/2016 11:11:06"><![CDATA[Files has invalid value "<<<<<<< .mine". Illegal characters in path.]]></error>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:
<target name="IncrementalClean" startTime="08/23/2016 11:51:50" elapsedTime="00:00:00" elapsedSeconds="0" success="false"> <task name="FindUnderPath" file="c:\BuildMachine\Build-TIGStage\Instant.InstantGroup.Core\Instant.InstantGroup.Core.csproj" startTime="08/23/2016 11:51:50" elapsedTime="00:00:00" elapsedSeconds="0" success="false"> <message level="low"><![CDATA[Comparison path is "bin\Debug\".]]></message> <error code="MSB3541" file="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets" line="3959" column="5" timeStamp="08/23/2016 11:51:50"><![CDATA[Files has invalid value "<<<<<<< .mine". Illegal characters in path.]]></error> </task> </target>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:
<error code="CS0012" file="UserControls/SubNavigation.ascx.cs" line="38" column="18" timeStamp="08/23/2016 14:25:15"><![CDATA[The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.]]></error>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.