Nuke build .nuke file and build multiple solutions

2.7k Views Asked by At

I am using nuke build for the first time.

Working through the getting started guide, I have ran the following:

dotnet tool install Nuke.GlobalTool --global
nuke :setup

This ran through a wizard which generated:

  1. build folder containing a csharp project to do the build
  2. .nuke file
  3. build.ps1 and build.sh to run the build

The .nuke file seems to contain a solution I selected during the build. Now I have a few solutions located under a folder that I want to build.

So I was assuming I could put them in the .nuke file.

code/solution1/solution1.sln
code/solution2/solution2.sln
code/solution3/solution3.sln

To no avail. When I run the build.ps1, it only builds the first solution in the list.

And the only help I see about the .nuke file states "Root directory marker file; references default solution file"

Question is, using the nuke build, how can I build multiple solutions under a folder hierarchy?

3

There are 3 best solutions below

0
On BEST ANSWER

I don't believe it's designed for this - instead you need to have one nuke build per solution.

0
On

This is also my usecase and I'll eagerly await the global.json file :) Since I was also wondering about multiple solution targets/etc, this is roughly what I have gathered:

The .nuke file is there for finding the injected RootDirectory (which is used by other internals afaik), and also can contain the default solution if you use the [Solution] attribute with no parameters. You can set up the combinatorial invocations as talked about by Matthias by either:

  1. Setting up injected static solution files:
//inside of build.cs
[Solution("Test1/example1.csproj")]
readonly Solution ExampleSolution1;

[Solution("Test2/example2.csproj")]
readonly Solution ExampleSolution2;
  1. Creating Solution objects at runtime
//anywhere in any task or function -- if moved, just pass in RootDirectory
IEnumerable<Solution> solutions = new[]{
     ProjectModelTasks.ParseSolution(RootDirectory / "Test1/example1.csproj"),
     ProjectModelTasks.ParseSolution(RootDirectory / "Test2/example2.csproj"),
 };
0
On

The .nuke file is currently mainly used for the SolutionAttribute. Eventually, it will be replaced by using global.json. If you're building multiple solutions, I suggest creating an IEnumerable<Solution> property and using combinatorial invocations via MSBuild or dotnet CLI.