FSharp build error in MSBuild in TeamCity

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

There are a number of projects in my solution, among which is also the F # project. Everything works fine in Visual Studio, but when I try to create it using MSBuild on my TeamCity server (which does not have VS installed), it gives the following build error for the project that refers to 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 creating MY_FSHARP_PROJECT_NAME (FSharp project), so I think the build went fine. This is the only error I get in the build project. I have F # 3.1 Tools installed (FSharp.Core 4.3.1.0).

Has anyone encountered this type of problem?

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 
+4
visual-studio build f # msbuild teamcity
source share
1 answer

Open the .fsproj file as a text file and make sure that it has the following lines:

  <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, paste above just before the <ItemGroup> section, which has all the .fs files.

Double check that the paths and files actually exist on your build server. If not, you can simply move the corresponding files from the computer with VS installed, although they should have come down with the F# Tools package.

0
source share

All Articles