Automatic build - '' is an incorrect path for a scene file. BuildPlayer expects paths relative

I have a problem running a script to automate the build of a project in Unity. The build ends up failing with this error:

BuildPlayerGenerator: Succeeded
DisplayProgressNotification: Build Failed
'' is an incorrect path for a scene file. BuildPlayer expects paths relative to the project folder.
Unloading 11 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 68.7 MB.
System memory in use after: 68.6 MB.

In attach I put screenshots from build settings window and logs from console with information about: scene path, scene guid, scene enabled and looks only path is missing for some reasons.

EditorBuildSettings.asset content:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1045 &1
EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/SampleScene.unity
guid: 2cda990e2423bbf4892e6590ba056729
- enabled: 0
path: Assets/Scenes/BlankScene.unity
guid: a3c3370f197cbae4caf1dc99eec0a14f
m_configObjects: {}

I use Unity version: 2020.3.37f1


8374707--1103967--upload_2022-8-19_11-42-33.png

I have seen this error when I specify a scene in EditorBuildSettings and that scene gets moved or deleted.

But If I build from Unity without any changes with move, delete, rename etc. scenes - they can find path from EditorBuildSettings.asset.

I’m having this issue at the moment, did you find the solution?

This happened to me recently when I deleted a scene but it was still enabled in the EditorBuildSettings.asset. Go to the asset file and manual remove the deleted scene.