4

I have the following setup described here (TeamCity with MSBuild and F# 3.1 Tools installed).

I have a number of projects in my solution, among which also a F# project. Everything builds fine in Visual Studio, but when I try to build it with MSBuild on my TeamCity server (which does not have VS installed) it throws the following build error on a project that references my FSharp project:

"C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\MY_SOLUTION.sln.teamcity" (TeamCity_Generated_Build target) (1) ->
[17:04:14]"C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\MY_SOLUTION.sln" (Build target) (2) ->
[17:04:14]"C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\Folder 0\ONE_PROJECT.csproj.metaproj" (default target) (3) ->
[17:04:14]"C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\Folder 1\ANOTHER.csproj" (default target) (4) ->
[17:04:14]"C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\Folder 2\REFERENCING_PROJECT.csproj" (default target) (7) ->
[17:04:14](CoreCompile target) -> 
[17:04:14]  SOME_CLASS_IN_REFERENCING_PROJECT.cs(10,7): error CS0246: The type or namespace name 'MY_FSHARP_PROJECT_NAME' could not be found (are you missing a using directive or an assembly reference?) [C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\Folder 2\REFERENCING_PROJECT.csproj]
[17:04:14] ... AND a bunch of similar errors here.

However, I see no errors in building the MY_FSHARP_PROJECT_NAME (the FSharp project) so I guess the build went ok. This is the only error I get in the build project. I have F# 3.1 Tools installed (FSharp.Core 4.3.1.0).

Does anyone came across this type of issue?

This is the build log from TeamCity:

Step 2/3: 2. Build Solution (MSBuild) (10s)
[13:57:31][Step 2/3] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9 "/msbuildPath:C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe"
[13:57:31][Step 2/3] in directory: C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9
[13:57:35][Step 2/3] SOLUTION.sln.teamcity: Build target: TeamCity_Generated_Build (5s)
[13:57:35][SOLUTION.sln.teamcity] TeamCity_Generated_Build (5s)
[13:57:35][TeamCity_Generated_Build] MSBuild (5s)
[13:57:35][MSBuild] SOLUTION.sln: Build targets: Clean;Build (5s)
[13:57:35][SOLUTION.sln] ValidateSolutionConfiguration
[13:57:35][SOLUTION.sln] ValidateProjects
[13:57:35][SOLUTION.sln] Clean (2s)
[13:57:36][Step 2/3] C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.CSharp.CurrentVersion.targets(388, 5): warning MSB4011: "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets (203,5)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\FSHARP_PROJECT\Infotron.FSHARP_PROJECT.fsproj]
[13:57:33][Step 2/3] MSBuild command line parameters contain "/property:" or "/p:". It is recommended to define System Property on Build Parameters instead.
[13:57:38][SOLUTION.sln] Build (2s)
[13:57:38][Build] MSBuild (2s)
[13:57:38][MSBuild] SOME_FOLDER3\Nl.SOME_PARENT_REFERENCING_PROJ.UI.csproj.metaproj: Build default targets (2s)
[13:57:38][SOME_FOLDER3\Nl.SOME_PARENT_REFERENCING_PROJ.UI.csproj.metaproj] Build (2s)
[13:57:38][Build] MSBuild (2s)
[13:57:38][MSBuild] SOME_FOLDER\SOME_PARENT_REFERENCING_PROJ.csproj: Build default targets (2s)
[13:57:38][SOME_FOLDER\SOME_PARENT_REFERENCING_PROJ.csproj] ResolveProjectReferences (2s)
[13:57:38][ResolveProjectReferences] MSBuild (2s)
[13:57:38][MSBuild] SOME_FOLDER2\PROJECT2.csproj: Build default targets (1s)
[13:57:39][MSBuild] FormulaTransformation\REFERENCING_FSHARPPROJ_PROJECT.csproj: Build default targets
[13:57:39][FormulaTransformation\REFERENCING_FSHARPPROJ_PROJECT.csproj] ResolveProjectReferences
[13:57:39][FormulaTransformation\REFERENCING_FSHARPPROJ_PROJECT.csproj] GenerateTargetFrameworkMonikerAttribute
[13:57:39][FormulaTransformation\REFERENCING_FSHARPPROJ_PROJECT.csproj] CoreCompile
[13:57:39][CoreCompile] Csc
[13:57:39][Csc] C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\SOME_FOLDER2\bin\Debug\SOME_FOLDER2.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\FSharp.Core.dll" /reference:C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\lib\Irony.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Entity.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /reference:C:\TeamCity\buildAgent\work\9d3b5b7177ddb2b9\Util\bin\Debug\Util.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\FormulaTransformation.dll /subsystemversion:6.00 /target:library /utf8output REFERENCING_FSHARPPROJ_CLASS.cs Properties\AssemblyInfo.cs "C:\TeamCity\buildAgent\temp\buildTmp\.NETFramework,Version=v4.5.AssemblyAttributes.cs"
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(10, 7): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS (**this class is in the project that references the FSharp project and calls SOME_CLASS_FROM_FSHARP_PROJ class from FSharp project**).cs(38, 16): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(154, 24): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(192, 78): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(192, 28): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(229, 32): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(252, 16): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(263, 29): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][Csc] REFERENCING_FSHARPPROJ_CLASS.cs(357, 50): error CS0246: The type or namespace name 'SOME_CLASS_FROM_FSHARP_PROJ' could not be found (are you missing a using directive or an assembly reference?)
[13:57:40][MSBuild] ANOTHER_PROJECT\ANOTHER_PROJECT.csproj: Build default targets
[13:57:41][MSBuild] ANOTHER2_PROJECT\ANOTHER2_PROJECT.csproj.metaproj: Build default targets
[13:57:41][ANOTHER2_PROJECT\ANOTHER2_PROJECT.csproj.metaproj] Build
[13:57:41][Build] MSBuild
[13:57:41][MSBuild] SOME_FOLDER\SOME_PARENT_REFERENCING_PROJ.csproj: Build default targets
[13:57:41][SOME_FOLDER\SOME_PARENT_REFERENCING_PROJ.csproj] Project SOME_FOLDER\SOME_PARENT_REFERENCING_PROJ.csproj failed.
[13:57:41][Step 2/3] Process exited with code 1
[13:57:41][Step 2/3] MSBuild output
[13:57:41][Step 2/3] Step 2. Build Solution (MSBuild) failed
Community
  • 1
  • 1
Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59
  • Can you double check which directory the F# project is building into, and cross check where the C# projects look to reference it. My guess would be something is working differently here. – Chris Ballard Mar 12 '14 at 16:34
  • As I can see, the dll for the Fsharp project are not generated (there is no bin folder in the project folder containing the dll). However, it does no throw any exception in TeamCity. Do I need to add some sort of build ordering (to build the Fsharp project then the REFERENCING_PROJECT - although I think this is done by default)? – Tamas Ionut Mar 13 '14 at 08:23

1 Answers1

0

Open your .fsproj file as a text file, and check that it has the following lines in it:

  <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
  <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />

If it doesn't have this, then insert the above just before the <ItemGroup> section which has all the .fs files within it.

Double check that the paths and files actually exist on your build server. If not, you may just want to move the relevant files across from a machine with VS installed, although they should have come down with the F# Tools package.

Chris Ballard
  • 3,771
  • 4
  • 28
  • 40
  • Nope, still no luck: same error is thrown. The problem is that it throws the error when building the REFERENCING_PROJECT, but displays no errors when building the FSharp_PROJECT. Also, I don't exactly understand what the **(CoreCompile target)** means and why it throws the error there. – Tamas Ionut Mar 13 '14 at 12:42
  • Well the problem seems to be that nothing is being built in the F# compilation stage. Are you able to attach the entire build log to your question? – Chris Ballard Mar 13 '14 at 12:47
  • I have added the failing part from TeamCity log. Still no dll is generated in the FSHARP_Project bin/Debug folder. – Tamas Ionut Mar 13 '14 at 13:15
  • And I still don't understand why, in the build log it doesn't show anywhere a build entry for the FSHARP_PROJECT. Shouldn't be some sort of order in which the build for FSHARP_PROJECT appears before the REFERENCING_FSHARP_PROJECT? – Tamas Ionut Mar 13 '14 at 13:20