我有以下设置描述here(TeamCity安装了MSBuild和F#3.1工具)。
我的解决方案中有很多项目,其中还有一个F#项目。一切都在Visual Studio中构建良好,但是当我尝试在我的TeamCity服务器(没有安装VS)上使用MSBuild构建它时,它会在引用我的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 :(得分: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
软件包。