Pure F# Web API and Team City Build
How I fixed the broken build
We use TeamCity at work for continuous integration. I recently added a Pure F# Web API to a solution. Everything was building but this one project. The build (with FAKE) ran just fine locally, but in the Team City environment, running the same FAKE script, the build broke.
And all I got was this fun error:
D:\TeamCity\buildAgent\work\d9d55e901e3e377a\src\MedPortal.WebApi\unknown(1,1): error FS0078: Unable to find the file 'mscorlib.dll' in any of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1 D:\TeamCity\buildAgent\work\d9d55e901e3e377a\src\MedPortal.WebApi D:\TeamCity\buildAgent\work\d9d55e901e3e377a\packages\FSharp.Core.4.1.0\lib\net40 [D:\TeamCity\buildAgent\work\d9d55e901e3e377a\src\MedPortal.WebApi\MedPortal.WebApi.fsproj]
I also saw this:
FSC : warning FS0082: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. (Code=MSB3270) [D:\TeamCity\buildAgent\work\d9d55e901e3e377a\src\MedPortal.WebApi\MedPortal.WebApi.fsproj]
O hai TeamCity build, why are you trying to find mscorlib in the wrong framework version? We are targeting v4.6.1 not v4.5.1. Also if you can't find it how do you know there is a mismatch?
After trying about eleventymillion things, I noticed something. I had a similar project that was not built using the Pure F# Web API template and, whoa, wait a minute, is it referencing mscorlib? Why yes, yes it is. So I added a reference to mscorlib to my broken project. Build is working now. Yay!
I am putting this here in case anyone else using the templates has a problem on a build server. You may just need to add a reference to mscorlib.
If anyone reading this has a better suggestion for fixing this problem, please tweet me.
Now if I can only figure out why the TeamCity build needed mscorlib in the references, but the local build was fine ... .
Full Stack .NET Programmer and Ham