2016-03-30 35 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)" /> 

它沒有工作。所以我把它放在下面,現在一切都像魅力一樣。