2016-03-30 34 views
3

我们有一个F#项目无法在teamctiy上构建,无法找出解决方案。看起来像通过teamcity建立fsc的论据对我们来说是不正确的。如果我在同一个源上手动运行msbuild /t:Rebuild /p:Configuration=Release,它都可以正常工作。构建F#项目时如何为fsc创建引用?

我会提供失败的fsproj文件的内容来说明我的意思(它不是一个大的项目):

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> 
    <PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
    <SchemaVersion>2.0</SchemaVersion> 
    <ProjectGuid>3e68783b-823c-4394-85cb-4a05aa3f3722</ProjectGuid> 
    <OutputType>Library</OutputType> 
    <RootNamespace>SFag.DataRepository</RootNamespace> 
    <AssemblyName>SFag.DataRepository</AssemblyName> 
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> 
    <TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion> 
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> 
    <Name>Sfag.DataRepository</Name> 
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> 
    <TargetFrameworkProfile /> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
    <DebugSymbols>true</DebugSymbols> 
    <DebugType>full</DebugType> 
    <Optimize>false</Optimize> 
    <Tailcalls>false</Tailcalls> 
    <OutputPath>bin\Debug\</OutputPath> 
    <DefineConstants>DEBUG;TRACE</DefineConstants> 
    <WarningLevel>3</WarningLevel> 
    <DocumentationFile>bin\Debug\SFag.DataRepository.XML</DocumentationFile> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 
    <DebugType>pdbonly</DebugType> 
    <Optimize>true</Optimize> 
    <Tailcalls>true</Tailcalls> 
    <OutputPath>bin\Release\</OutputPath> 
    <DefineConstants>TRACE</DefineConstants> 
    <WarningLevel>3</WarningLevel> 
    <DocumentationFile>bin\Release\SFag.DataRepository.XML</DocumentationFile> 
    </PropertyGroup> 
    <ItemGroup> 
    <Reference Include="mscorlib" /> 
    <Reference Include="System" /> 
    <Reference Include="System.Core" /> 
    <Reference Include="System.Numerics" /> 
    </ItemGroup> 
    <ItemGroup> 
    <Compile Include="AssemblyInfo.fs" /> 
    <Compile Include="Tilsynsmyndighet.fs" /> 
    <None Include="Script.fsx" /> 
    <None Include="paket.references" /> 
    <Compile Include="KonsesjonRepository.fs" /> 
    </ItemGroup> 
    <ItemGroup> 
    <ProjectReference Include="..\Sfag.Contracts\Sfag.Contracts.csproj"> 
     <Name>Sfag.Contracts</Name> 
     <Project>{260b3032-028d-417e-acde-1c332744b1bf}</Project> 
     <Private>True</Private> 
    </ProjectReference> 
    </ItemGroup> 
    <PropertyGroup> 
    <MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion> 
    </PropertyGroup> 
    <Choose> 
    <When Condition="'$(VisualStudioVersion)' == '11.0'"> 
     <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> 
     <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> 
     </PropertyGroup> 
    </When> 
    <Otherwise> 
     <PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')"> 
     <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> 
     </PropertyGroup> 
    </Otherwise> 
    </Choose> 
    <Import Project="$(FSharpTargetsPath)" /> 
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     Other similar extension points exist, see Microsoft.Common.targets. 
    <Target Name="BeforeBuild"> 
    </Target> 
    <Target Name="AfterBuild"> 
    </Target> 
    --> 
    <Choose> 
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'"> 
     <ItemGroup> 
     <Reference Include="FSharp.Core"> 
      <HintPath>..\packages\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath> 
      <Private>True</Private> 
      <Paket>True</Paket> 
     </Reference> 
     </ItemGroup> 
    </When> 
    </Choose> 
    <Choose> 
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'"> 
     <ItemGroup> 
     <Reference Include="FSharp.Data.SqlClient"> 
      <HintPath>..\packages\FSharp.Data.SqlClient\lib\net40\FSharp.Data.SqlClient.dll</HintPath> 
      <Private>True</Private> 
      <Paket>True</Paket> 
     </Reference> 
     <Reference Include="System.Data"> 
      <Paket>True</Paket> 
     </Reference> 
     <Reference Include="System.Xml"> 
      <Paket>True</Paket> 
     </Reference> 
     </ItemGroup> 
    </When> 
    </Choose> 
</Project> 

当运行msbuild手工我们得到正确的参数fsc.exe

C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Release\SFag.DataRepository.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\SFag.DataRepository.XML --optimize+ -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Core\lib\net40\FSharp.Core.dll -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Data.SqlClient\lib\net40\FSharp.Data.SqlClient.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\Sfag.Contracts\bin\Release\Sfag.Contracts.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "C:\Users\admtoja1\AppData\Local\Temp\.NETFramework,Version=v4.6.1.AssemblyAttributes.fs" AssemblyInfo.fs Tilsynsmyndighet.fs KonsesjonRepository.fs 

当TeamCity的运行构建我们没有得到确切的相同的输出:

C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe -o:obj\Release\SFag.DataRepository.dll --debug:pdbonly --noframework --define:TRACE --doc:bin\Release\SFag.DataRepository.XML --optimize+ -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\packages\FSharp.Core\lib\net40\FSharp.Core.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" -r:E:\TeamCity\buildAgent2\work\cd80d924274f60cd\src\Sfag.Contracts\bin\Release\Sfag.Contracts.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" --target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors --subsystemversion:6.00 --highentropyva+ "E:\TeamCity\buildAgent2\temp\buildTmp\.NETFramework,Version=v4.6.1.AssemblyAttributes.fs" AssemblyInfo.fs Tilsynsmyndighet.fs KonsesjonRepository.fs 

错误是在Teamcity版本中没有提及FSharp.Data.SqlClient。这真的很奇怪,因为我认为teamcity会在我的解决方案上拨打msbuild

回答

0

FSharp.Data.Client来自NuGet包,我猜测NuGet包在编译之前没有被正确恢复。

通过管理链接启用的NuGet上的TeamCity

enter image description here

添加的NuGet安装之前的编译一步一步

enter image description here

希望这有助于

+0

我们正在使用paket来处理所有的软件包,这与此有关。 –

+0

真棒,很高兴它指出你在正确的方向。我现在在Google上搜索:) –

+0

你一定要查找paket,https://fsprojects.github.io/Paket/。帮助您处理nuget软件包之间的版本冲突,还可以让您引用除nuget软件包以外的其他内容。 –

0

这可能是一个新手包的错误。因为我们希望有,当我们建立在Visual Studio中的包的自动决心我们必须一行添加到我们的项目文件:

<Import Project="..\.paket\paket.targets" /> 

而且这也很重要,这个文件在项目文件中的正确的地方。如果我有以上

<Import Project="$(FSharpTargetsPath)" /> 

它没有工作。所以我把它放在下面,现在一切都像魅力一样。