FSharp build fails in MSBuild, but works ok in Visual Studio

前端 未结 3 828
梦如初夏
梦如初夏 2021-01-12 03:05

I have a number of projects in my solution, among which also a F# project. Everything builds fine in Visual Studio, but when I try to build it with MSBuild on my TeamCity se

相关标签:
3条回答
  • 2021-01-12 03:35

    I had a problem today with the same symptoms on my build server. What fixed it for me was starting up VS on the build server and creating a F# project, which installed the F# tooling. It was not installed completely by default.

    0 讨论(0)
  • 2021-01-12 03:44

    You can create the target "Clean" in your project:

    <Target Name="Clean">
        <MSBuild
        Targets="Clean"
        Projects=".\MySolutionDir\MySol.sln"
        Properties="Configuration=$(Configuration)"  />
    </Target>
    

    Or you can modify the command line to something like this:

    MSBuild MyProj.proj /p:Configuration=Release;Targets=Clean
    
    0 讨论(0)
  • 2021-01-12 03:47

    We had the same problem with AutoFixture.AutoFoq and ZeroToNine.

    What we did was to modify the .fsproj files.

    First, you have to add

    <TargetFSharpCoreVersion>4.3.0.0</TargetFSharpCoreVersion>
    

    to the first <PropertyGroup>.

    Second, you replace

    <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
    

    with this:

    <Choose>
      <When Condition="'$(VisualStudioVersion)' == '11.0'">
        <PropertyGroup>
          <FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
        </PropertyGroup>
      </When>
      <Otherwise>
        <PropertyGroup>
          <FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
        </PropertyGroup>
      </Otherwise>
    </Choose>
    <Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
    

    Finally, replace

    <Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    

    with

    <Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    

    If you want to see this in context, you can review the ZeroToNine commit that does the above.

    0 讨论(0)
提交回复
热议问题