2014-03-12 84 views
4

我有以下安裝描述here(TeamCity與MSBuild和F#3.1工具安裝)。FSharp項目構建在TeamCity的MSBuild中失敗

我在我的解決方案中有許多項目,其中還有一個F#項目。一切都建立在Visual Studio很好,但是當我試圖用的MSBuild我的TeamCity服務器(其沒有安裝VS)來構建它,它引發以下生成錯誤的引用我的FSharp項目項目:

"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. 

但是,我發現在構建MY_FSHARP_PROJECT_NAME(FSharp項目)時沒有錯誤,所以我猜構建成功了。 這是我在構建項目中遇到的唯一錯誤。 我已經安裝了F#3.1工具(FSharp.Core 4.3.1.0)。

有沒有人遇到過這種類型的問題?

這是從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 
+0

您可以仔細檢查F#項目構建到的目錄,並交叉檢查C#項目引用它的位置。我的猜測會在這裏有所不同。 –

+0

正如我所看到的,Fsharp項目的dll不會生成(在包含dll的項目文件夾中沒有bin文件夾)。但是,它並沒有在TeamCity中拋出任何異常。我是否需要添加某種構建順序(構建Fsharp項目,然後是REFERENCING_PROJECT - 雖然我認爲這是默認完成的)? –

回答

0

打開.fsproj文件爲文本文件,並檢查它在它的下面幾行:

<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')" /> 

如果它不」沒有這個,然後在<ItemGroup>部分之前插入上面的部分,其中包含所有.fs文件。

仔細檢查您的構建服務器上是否存在路徑和文件。如果不是這樣,你可能只想從安裝了VS的機器上移動相關文件,儘管它們應該已經包含了F# Tools包。

+0

不,仍然沒有運氣:同樣的錯誤被拋出。問題是在構建REFERENCING_PROJECT時拋出錯誤,但在構建FSharp_PROJECT時不顯示錯誤。另外,我不完全理解**(CoreCompile target)**的含義以及它爲什麼會在那裏引發錯誤。 –

+0

那麼這個問題似乎是在F#編譯階段沒有任何內容。你能夠將整個構建日誌附加到你的問題嗎? –

+0

我從TeamCity日誌中添加了失敗的部分。仍然沒有在FSHARP_Project bin/Debug文件夾中生成DLL。 –