chore: provide a builder for the samples - #2791
Conversation
| var target = GetBuildTarget(GetArgument(arguments, "-buildTarget")); | ||
| var outputPath = GetArgument(arguments, "-buildOutput"); |
There was a problem hiding this comment.
Bug: The build script passes arguments like --target while the C# code expects -buildTarget, causing an ArgumentException and build failure due to the mismatch.
Severity: CRITICAL
Suggested Fix
Align the argument names between the build-sample.ps1 script and the SampleBuilder.cs code. For example, update the C# code to search for --target and --output-path instead of -buildTarget and -buildOutput. Alternatively, modify the PowerShell script to pass the argument names the C# code expects.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: samples/unity-of-bugs/Assets/Editor/SampleBuilder.cs#L14-L15
Potential issue: The build script `build-sample.ps1` passes command-line arguments like
`--target` and `--output-path` to the Unity build process. However, the
`SampleBuilder.cs` code expects arguments with different names and prefixes,
specifically `-buildTarget` and `-buildOutput`. The `GetArgument` helper function
performs an exact string comparison and will fail to find these arguments. This mismatch
causes `GetArgument` to throw an `ArgumentException`, which will cause the sample
project build to fail for anyone following the documented build instructions.
Also affects:
scripts/build-sample.ps1:36~41
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b01226d. Configure here.
| { | ||
| var arguments = Environment.GetCommandLineArgs(); | ||
| var target = GetBuildTarget(GetArgument(arguments, "-buildTarget")); | ||
| var outputPath = GetArgument(arguments, "-buildOutput"); |
There was a problem hiding this comment.
Output path argument name mismatch
High Severity
build-sample.ps1 passes --output-path to Unity CLI, but SampleBuilder.Build reads -buildOutput from GetCommandLineArgs(). Those names do not line up under Unity CLI’s normal flag mapping, so the builder throws for a missing required argument and the sample build never runs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b01226d. Configure here.
|
|
||
| if (-not (Test-Path $outputPath)) { | ||
| throw "Unity CLI build for $Target completed without producing $outputPath." | ||
| } |
There was a problem hiding this comment.
Weak iOS and WebGL output check
Low Severity
For iOS and WebGL, $outputPath is the build directory that is created with New-Item before Unity runs. The later Test-Path check therefore always succeeds for those targets, even when no build artifacts were written.
Reviewed by Cursor Bugbot for commit b01226d. Configure here.


This provides an easy way utilizing Unity CLI to build the samples.
#skip-changelog