添加名为project的文件夹来构建路径

时间:2015-11-29 23:02:49

标签: f# f#-fake

我已经制作了示例构建脚本,但由于我的解决方案中有多个项目,我需要将它们内置到不同的文件夹中。

主要问题是如何获取处理的当前文件的名称,以便我可以将其添加到buildDir字符串。

Target "BuildApp" (fun _->
!! "**/*.csproj"
  -- "*Test*/*.csproj"
  -- "**/*Test*.csproj"
  -- "**/TextControlEditorLight.csproj"
  |> MSBuildRelease buildDir "Build"
  |> Log "AppBuild-Output: "

我需要像(buildDir +“/”+ projectName)这样的东西,我已经在网上搜索但没有找到任何东西。

1 个答案:

答案 0 :(得分:1)

可能有一种更简单的方法(我不熟悉所有 FAKE库),但实现此目的的一种方法是显式迭代项目文件并构建然后一个接一个。

!!运算符返回一系列匹配文件。在您的版本中,您只需将其传递给MSBuildRelease,但您也可以使用Seq.iter对其进行迭代:

Target "BuildApp" (fun _->
  !! "**/*.csproj"
    -- "*Test*/*.csproj"
    -- "**/*Test*.csproj"
    -- "**/TextControlEditorLight.csproj"
  |> Seq.iter (fun project ->
    // This function will be called for individual project files and so
    // we can do whatever we want here. Like build a single project and
    // specify output directory based on the project file name.
    [project]
    |> MSBuildRelease (buildDir @@ Path.GetFileNameWithoutExtension(project)) "Build"
    |> Log "AppBuild-Output: ")
)