Thoor
Thoor

Reputation: 137

Add Folder named like project to build path

I have made the example build script, but since i have several projects in my solution i need them built into different folders.

Main question would be how to get the name of the current file processed so i can add it to the buildDir string.

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

I need something like (buildDir + "/" + projectName), i searched already the web but didn't find anything.

Upvotes: 1

Views: 57

Answers (1)

Tomas Petricek
Tomas Petricek

Reputation: 243061

There might be an easier way to do this (I'm not familiar with all the FAKE libraries), but one way to do this is to explicitly iterate over the project files and build then one by one.

The !! operator returns a sequence of matching files. In your version, you just pass them to MSBuildRelease, but you can also iterate over them using 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: ")
)

Upvotes: 1

Related Questions