在构建服务器上安装F#4.1 SDK [英] Install F# 4.1 SDK on build server

查看:80
本文介绍了在构建服务器上安装F#4.1 SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在PC上安装了具有F#支持的Visual Studio 2017,并且在 C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Enterprise \ MSBuild \ Microsoft \ VisualStudio \ v15.0中具有MSBuild目标C:\ Program Files(x86)\ Microsoft SDKs \ F#\ 4.1

I have installed Visual Studio 2017 with F# support on my PC and I have MSBuild targets in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\FSharp and F# 4.1 SDK in C:\Program Files (x86)\Microsoft SDKs\F#\4.1

我已经安装了Visual Studio 2017的构建工具(来自 https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15 ),但是没有安装F#SDK的选项,因此无法构建F#项目使用MSBuild 15失败.

I have installed Build Tools for Visual Studio 2017 (from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15 ) but there is no option to install F# SDK so building F# projects using MSBuild 15 fails.

如何在不安装Visual Studio的情况下安装F#4.1 SDK?

How can I install F# 4.1 SDK without installing Visual Studio?

推荐答案

在可以单独安装SDK之前的短期修复是向项目文件添加指令,以在Microsoft.FSharp的NuGet软件包文件夹中查找.目标文件.这是我为解决此问题而采取的步骤:

A short term fix until the SDK can be installed separately is to add a directive to the project file to look in the NuGet packages folder for the Microsoft.FSharp.Targets file. Here are steps I took to fix this:

确保使用VS.NET 2017中的新F#项目,因为它具有以下指令:

Ensure your using the new F# project from VS.NET 2017 as its has this directive:

<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')" />

替换项目文件的这一部分:

Replace this section of the project file:

<Choose>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.3.0.0 AND $(TargetFSharpCoreVersion) &lt; 4.3.1.0 ">
      <PropertyGroup>
        <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.3.1.0 AND $(TargetFSharpCoreVersion) &lt; 4.4.0.0 ">
      <PropertyGroup>
        <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.4.0.0 AND $(TargetFSharpCoreVersion) &lt; 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>

使用此XML:

  <Choose>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.3.0.0 AND $(TargetFSharpCoreVersion) &lt; 4.3.1.0 ">
      <PropertyGroup>
        <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.3.1.0 AND $(TargetFSharpCoreVersion) &lt; 4.4.0.0 ">
      <PropertyGroup>
        <FSharpTargetsPath>$(MSBuildProgramFiles32)\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
      </PropertyGroup>
    </When>
    <When Condition="$(TargetFSharpCoreVersion) &gt;= 4.4.0.0 AND $(TargetFSharpCoreVersion) &lt; 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>

在构建之前,请确保构建服务器具有还原NuGet软件包的步骤

Ensure you build server has a restore NuGet packages step prior to doing the build

确保您打包的文件包括:FSharp.Compiler.Tools和FSharp.Core

Ensure you packages file includes: FSharp.Compiler.Tools and FSharp.Core

该方法起作用的原因如下:这将检查FSharpTargetsPath是否存在,如果不存在,则使用packages文件夹作为源.您不希望始终使用packages文件夹,否则在用户计算机上进行新签出时,软件包将不可用,并且构建将失败.为了使它在构建服务器上工作,假设您有步骤在执行构建之前还原NuGet软件包.

The reason this works is as follows: This checks to see if the FSharpTargetsPath exists and if not use the packages folder as the source. You don't want to always use the packages folder otherwise on a fresh checkout on a users machine the packages aren't available and the build will fail. For this to work on the build server this assumes you have a step to restore the NuGet packages PRIOR to doing the build.

这篇关于在构建服务器上安装F#4.1 SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆