Reproduction steps:
1. Open the “BuildPlayerCache” project, and open the “Scene1" scene
2. File → Build StandaloneWindows
3. File → Build And Run, and select “Player1” as the folder
4. Close the Player, and delete the “Player1" folder
5. File → Build StandaloneWindows, and observe the Console
Expected result: “Player2” build succeeded
Actual result: “Player2” build failed because “Player1” does not exist
Reproduced in: 2020.3.46f1, 2021.3.21f1, 2022.2.9f1, 2023.1.0b9, 2023.2.0a6
Reproduced using: Windows 10
Not reproduced using: macOS 13.2.1 (Intel)
Full error:
DirectoryNotFoundException: The path D:/BuildPlayerCache/Player1 does not exist.
NiceIO.NPath+WindowsFileSystem.Directory_GetFiles (NiceIO.NPath path, System.String filter, System.IO.SearchOption searchOptions) (at <5894d11b90944d1ebef5d2c59e539009>:0)
NiceIO.NPath.Files (System.String filter, System.Boolean recurse) (at <5894d11b90944d1ebef5d2c59e539009>:0)
NiceIO.NPath.Contents (System.String filter, System.Boolean recurse) (at <5894d11b90944d1ebef5d2c59e539009>:0)
NiceIO.NPath.Contents (System.Boolean recurse) (at <5894d11b90944d1ebef5d2c59e539009>:0)
UnityEditor.WindowsStandalone.WinPlayerPostProcessor.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTarget target) (at C:/build/output/unity/unity/PlatformDependent/WinPlayer/Extensions/Managed/WinPlayerPostProcessor.cs:57)
UnityEditor.PostprocessBuildPlayer.PrepareForBuild (UnityEditor.BuildOptions options, UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target) (at <5894d11b90944d1ebef5d2c59e539009>:0)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
Builder:BuildWindows() (at Assets/Editor/Builder.cs:16)