Running unit test on a TeamCity is usually not a big problem but a couple of days ago I noticed I very strange behaviour.
The number of tests executed on the build server was much smaller than the number of tests running on my local machine but TeamCity did not report any errors. After digging into the build log, I noticed this exception in the log files:
System.Runtime.Serialization.SerializationException: Unable to find assembly 'FakeItEasy, Version=220.127.116.11, Culture=neutral, PublicKeyToken=eff28e2146d5fd2c'.
The only noticeable difference between the execution on TeamCity and my local machine was that locally I used the ReSharper test runner and on the build server xunit.console.exe was used to run the test.
When trying to run the tests with xunit.console.exe on my local machine I could reproduce the error.
For some unclear reason, XUnit was not able to load the FakeItEasy assembly that was located in the bin folder of the test assembly. The only workaround I found was to copy the FakeItEasy assembly to the folder of xunit.console.exe. After doing this, the number of tests on my local machine and on TeamCity matched again.
This is not really a satisfying solution, but I couldn’t find a better solution. Did someone find a proper solution for this problem?
Having a build server to compile all checked in code is a very useful thing but preparing the build server for SharePoint 2013 projects requires a few steps (applicable for TFS 2010 and TFS 2012). In order to complete it, you need to have a SharePoint development machine to copy the assemblies from.
- Run the SharePoint Prerequisites Installer in order to install all dependency (like Windows Identity Foundation etc.)
- Open the GAC on the development machine (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\ ) and copy the following assemblies:
- Copy all SharePoint related assemblies from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI to C:\Program Files\Reference Assemblies\SharePoint\ on the build server
- Open the registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx and add the following key: SharePoint15]@=”C:\Program Files\Reference Assemblies\SharePoint\”
- Copy the folders SharePointTools,Web, WebApplications from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0 to the corresponding path on the build server
- Copy the file C:\Program Files\Common Files\Microsoft Shared\web server extensions\15\TEMPLATE\XML\appManifest.xsd to the corresponding path on the build server (only necessary if you want to build SharePoint 2013 Apps)
Hint: This tutorial assumes that the TFS binaries are installed and the build server is already connected to a TFS. The required steps are listed here: http://msdn.microsoft.com/en-us/library/hh395023.aspx