nuke-build / nuke

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

UnityTasks.UnityRunTests API does not DetectUnityVersion from project #1427

Closed chrisyarbrough closed 4 days ago

chrisyarbrough commented 2 months ago

Usage Information

Nuke 8.1.0 / 8.0.201 / net8.0 / macOS Sonoma 14.3.1

Description

When using UnityTasks.Unity without specifying a Unity editor version, it defaults to auto-detecting the version from the ProjectSettings/ProjectVersion.txt file.

However, when using UnityTasks.UnityRunTests this doesn't happen, but I would expect it to behave the same way and call DetectUnityVersion within.

Reproduction Steps

Open the repro project: [Uploading NukeBugReport_UnityTasks_UnityAutoDetectNotImplementedForTests.zip…]()

This project uses Nuke 8.0.0, but the issue also happens in 8.1.0.

For full functionality, install Unity 2021.3.21.

Run:

Nuke Test

Expected Behavior

UnityTasks.UnityRunTests should detect the Unity editor version from the project and run successfully.

Actual Behavior

UnityTasks.UnityRunTests is used, but it doesn't detect the desired Unity editor version, instead it fails with:

System.ArgumentException: Expected file to exist: /Applications/Unity/Unity.app/Contents/MacOS/Unity (Parameter 'toolPath')

It is trying to run the (old legacy) default Unity editor path instead of the one specified in the project.

Analysis

Callstack with desired behaviour:

Callstack with undesired behaviour:

Regression?

No response

Known Workarounds

Yes:

Nuke TestWorkaround

Output:

 /Applications/Unity/Hub/Editor/2021.3.21f1/Unity.app/Contents/MacOS/Unity ...

This uses UnityTasks.Unity which uses DetectUnityVersion internally.

Could you help with a pull-request?

Yes

chrisyarbrough commented 2 months ago

I went ahead and would like to propose a fix here: https://github.com/nuke-build/nuke/pull/1428 Feel free to implement a different solution. :)

matkoch commented 4 days ago

I think this should be fixed in 9.0.1... but please check and reopen if necessary.