Reputation: 23472
Usually the solutions I make contains multiple applications, it could be a web-app, service and maybe a simple console app.
To build my projects I use:
let projects = !! "src/**/*.csproj" -- "src/**/*.Tests.csproj"
and then
projects
|> MSBuildRelease buildDir "ResolveReferences;Build"
The problem with this is that all my service dlls and console dlls end up in the same directory, buildDir
, is there a way to force each project to have a subfolder inside the buildDir
? For web projects it looks to be fine since there I have the _PublishedWebsites
folder to rely on.
Also, when building it this way, doesn't that open up for some projects to be built multiple times? I mean, if both Service
and Web
have a reference to LibA
, won't this end up with building LibA
three times? One time it matches the file pattern itself and two times because of the references from Web
and Service
.
UPDATE:
It is for a demo project and you can find the code here: https://github.com/mastoj/FAKESimpleDemo
Upvotes: 2
Views: 450
Reputation: 23472
I've must have been really tired when I did this, because it is quite obvious what to do. Instead of passing in all the projects right away I can just do the iteration myself and figure out what the output folder should be. So to resolve this I just added two helper functions:
let getOutputDir proj =
let folderName = Directory.GetParent(proj).Name
sprintf "%s%s/" buildDir folderName
let build proj =
let outputDir = proj |> getOutputDir
MSBuildRelease outputDir "ResolveReferences;Build" [proj] |> ignore
Target "Build" (fun() ->
trace "Building again!"
projects
|> Seq.iter build
)
This way you will get one folder in the output directory per project built. The name of the folder is take from the parent directory name of the project file. You could probably use the name of the of the file instead if you wanted to.
Upvotes: 1