Trying to build a pipeline but getting error path contains project built with "Create Visual Studio Solution" option

Some background:

I’m using Arcadia, but that shouldn’t matter as the output is just a c# lib that gets called by the project.

This is super confusing as using the Unity build option works perfectly, but I would like to automate the creation of Windows / Macos / Linux builds, so just trying to get this working as an editor build script.

If I’ve made a silly assumption please let me know, perhaps I should be approaching this differently.

Here are the errors I’m getting:

error:  Build path contains project built with "Create Visual Studio Solution" option, which is incompatible with current build settings. Consider building your project into an empty directory.
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
Build:BuildAllPipeline () (at Assets/Scripts/Editor/Build.cs:25)

Internal build system error. BuildProgram exited with code -2146233088.
error:  Build path contains project built with "Create Visual Studio Solution" option, which is incompatible with current build settings. Consider building your project into an empty directory.
System.Exception: Build path contains project built with "Create Visual Studio Solution" option, which is incompatible with current build settings. Consider building your project into an empty directory.
   at WinPlayerBuildProgram.WinPlayerPrerequisiteChecks.CheckSafeProjectOverwrite(PlayerBuildConfig playerBuildConfig)
   at WinPlayerBuildProgram.WinPlayerBuildProgram..ctor(String[] args)
   at PlayerBuildProgramTypeWrapper.Run(String[] args)
   at Program.Main(String[] args)
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
Build:BuildAllPipeline () (at Assets/Scripts/Editor/Build.cs:25)

BuildFailedException: Incremental Player build failed!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <ca9371748a7e4a518cfda3ab1cf36aff>:0)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <ca9371748a7e4a518cfda3ab1cf36aff>:0)
UnityEditor.WindowsStandalone.WinPlayerPostProcessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at C:/buildslave/unity/build/PlatformDependent/WinPlayer/Extensions/Managed/WinPlayerPostProcessor.cs:33)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <ca9371748a7e4a518cfda3ab1cf36aff>:0)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
Build:BuildAllPipeline() (at Assets/Scripts/Editor/Build.cs:25)

Here’s my build script:

using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Reporting;
using Arcadia;


public class Build : MonoBehaviour
{
    [MenuItem("Build/Build All")]
    public static void BuildAllPipeline()
    {
        // Don't forget to set the namespace you're interested in the configuration.edn
        // Build Clojure Bits
        Arcadia.BuildPipeline.PrepareExport();
        
        // ===== This sample is taken from the Unity scripting API here:
        // https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildPlayer.html
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/Main.unity" };
        buildPlayerOptions.locationPathName = "BuildAll";
        buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
        // buildPlayerOptions.options = BuildOptions.None;
        buildPlayerOptions.options = BuildOptions.DetailedBuildReport | BuildOptions.StrictMode;

        BuildReport report = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
        {
            Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
        }

        if (summary.result == BuildResult.Failed)
        {
            Debug.Log("Build failed");
        }
    }
}

Things I’ve tried so far:
Googling the error got me 0, 1 and 2:
0 suggests, to create a new folder Build Versions and run the command from there, I feel that I migh be doing this using locationPathName = "BuildAll", but not certain. It also mentions that Unity expects the result of locationPathName as a folder will trigger will trigger this error, not certain why the Unity example from the docs 3 uses the folder iOSBuild.

1 and 2 suggests deleting the .sln files which I tried, but didn’t appear to make any difference.

PS: Sorry about the formatting, the preview seems to make everything look really clumped together.

locationPathName should contain a filename

e.g. locationPathName = “WindowsProdBuild/myProject.exe”;