nuke-build / nuke

🏗 The AKEless Build System for C#/.NET
https://nuke.build
MIT License
3.07k stars 369 forks source link

PackageDownload dependencies cannot be found by global tools #1377

Closed Elodon closed 5 months ago

Elodon commented 6 months ago

Usage Information

Nuke 8.0.0 / SDK 6.0.321 / .NET 6.0 / Windows 11

Description

Publishing a global tool version of a Nuke build with dependencies defined with the PackageDownload feature results in errors for missing packages when trying to execute the global tool.

Reproduction Steps

I have attached a Minimal Reproducible Example (MRE). This behavior can be reproduced by:

  1. Navigate to the root directory of the solution in PowerShell
  2. Enter command nuke to build the project successfully using Build.cs from the _build project
  3. Enter command dotnet pack to package the Nuke build as a global tool
  4. Enter command dotnet tool install --global --add-source .\artifacts MyGlobalTool to install the global tool
  5. Enter command my-command to execute the build from the global tool which will fail
  6. Enter command dotnet tool uninstall --global MyGlobalTool to remove the global tool

nuke-global-tool-repro.zip

Expected Behavior

Dependencies defined with the PackageDownload feature (e.g. GitVersion.Tools) would be packed into the global tool such that they can be referenced when executing the global tool.

Actual Behavior

Attempts to reference PackageDownload dependencies when executing the global tool result in missing package errors which fail the build, such as:

Could not inject value for Build.GitVersion
System.Exception: Missing package reference/download.
Run one of the following commands:
  - nuke :add-package GitVersion.Tool --version 5.12.0
  - nuke :add-package GitVersion.CommandLine --version 5.12.0
 ---> System.ArgumentException: Could not find package 'GitVersion.Tool' or 'GitVersion.CommandLine'

Regression?

This worked in 5.2.1. It does not work in 7.0.5. I am not sure about the versions in between. I believe this is a recurrence of an issue previously addressed multiple times in 2020:

Known Workarounds

None

Could you help with a pull-request?

Yes, in theory, but I don't currently know how to solve the problem.

matkoch commented 5 months ago

PackageDownload is not transitive

matkoch commented 5 months ago

check the updated docs