Một sửa chữa ngắn hạn cho đến khi SDK có thể được cài đặt riêng biệt là thêm một chỉ thị vào tệp dự án để tìm trong thư mục gói NuGet cho tệp Microsoft.FSharp.Targets.Dưới đây là các bước tôi đã để sửa lỗi này:
Đảm bảo sử dụng của bạn F # dự án mới từ VS.NET 2017 như nó có chỉ thị này:
<Import Project="..\packages\FSharp.Compiler.Tools.4.1.17\build\FSharp.Compiler.Tools.props" Condition="Exists('..\packages\FSharp.Compiler.Tools.4.1.17\build\FSharp.Compiler.Tools.props')" />
Thay thế phần này của hồ sơ dự án:
<Choose>
<When Condition="$(TargetFSharpCoreVersion) >= 4.3.0.0 AND $(TargetFSharpCoreVersion) < 4.3.1.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<When Condition="$(TargetFSharpCoreVersion) >= 4.3.1.0 AND $(TargetFSharpCoreVersion) < 4.4.0.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<When Condition="$(TargetFSharpCoreVersion) >= 4.4.0.0 AND $(TargetFSharpCoreVersion) < 4.4.1.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
Với XML này:
<Choose>
<When Condition="$(TargetFSharpCoreVersion) >= 4.3.0.0 AND $(TargetFSharpCoreVersion) < 4.3.1.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<When Condition="$(TargetFSharpCoreVersion) >= 4.3.1.0 AND $(TargetFSharpCoreVersion) < 4.4.0.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<When Condition="$(TargetFSharpCoreVersion) >= 4.4.0.0 AND $(TargetFSharpCoreVersion) < 4.4.1.0 ">
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<!-- This is needed for TeamCity where F# SDK is only available via NuGet right now - hopefully can be removed at some point once the SDK is available for install -->
<PropertyGroup Condition="!Exists('$(FSharpTargetsPath)')">
<FSharpTargetsPath>$(FscToolPath)\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
Đảm bảo bạn xây dựng máy chủ đã khôi phục gói NuGet bước pri hoặc để làm xây dựng
Đảm bảo bạn gói tập tin bao gồm: FSharp.Compiler.Tools và FSharp.Core
Lý do làm việc này là như sau: này sẽ kiểm tra xem nếu FSharpTargetsPath tồn tại và nếu không sử dụng thư mục gói dưới dạng nguồn. Bạn không muốn luôn luôn sử dụng thư mục gói nếu không trên một thanh toán mới trên một máy người dùng các gói không có sẵn và xây dựng sẽ thất bại. Đối với điều này để làm việc trên máy chủ xây dựng này giả định bạn có một bước để khôi phục lại các gói NuGet PRIOR để làm việc xây dựng.
Nguồn
2017-05-11 15:16:09
Làm việc cho chúng tôi. Đó là đủ để thêm Fsharp.Compiler.Tools nuget. Nó tự động thêm câu lệnh nhập và thêm thay đổi duy nhất cần thiết là nhập có điều kiện (cuối cùng trong đoạn mã của bạn) –