Nuke 构建 .nuke 文件并构建多个解决方案

Nuke build .nuke file and build multiple solutions

我是第一次使用nuke build

通过 getting started 指南,我得到了 运行 以下内容:

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

这运行通过向导生成:

  1. 包含用于构建的 csharp 项目的构建文件夹
  2. .nuke 文件
  3. build.ps1 and build.sh to 运行 build

.nuke 文件似乎包含我在构建过程中选择的解决方案。现在我有几个解决方案位于我要构建的文件夹下。

所以我假设我可以将它们放入 .nuke 文件中。

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

无济于事。当我 运行 构建时。ps1,它只构建列表中的第一个解决方案。

我看到的关于 .nuke 文件的唯一帮助是 "Root directory marker file; references default solution file"

问题是,使用 nuke 构建,如何在文件夹层次结构下构建多个解决方案?

我不认为它是为此而设计的 - 相反,您需要为每个解决方案构建一个 nuke。

.nuke文件目前主要用于SolutionAttribute。最终,它将被使用 global.json 代替。如果您要构建多个解决方案,我建议创建 IEnumerable<Solution> 属性 并通过 MSBuild 或 dotnet CLI 使用 combinatorial invocations

这也是我的用例,我会热切地等待 global.json 文件 :) 因为我也想知道多个解决方案 targets/etc,这就是我收集到的大致内容:

.nuke 文件用于查找注入的 RootDirectory(其他内部 afaik 使用它),如果您使用不带参数的 [Solution] 属性,也可以包含默认解决方案。 您可以通过以下任一方式设置 Matthias 所说的组合调用:

  1. 设置注入的静态解决方案文件:
//inside of build.cs
[Solution("Test1/example1.csproj")]
readonly Solution ExampleSolution1;

[Solution("Test2/example2.csproj")]
readonly Solution ExampleSolution2;
  1. 在运行时创建解决方案对象
//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"),
 };