Build Failed - file has already been registered with different contents.

Hi!
I'm trying to build my project for WebGL and am getting the following error:

Internal build system error. BuildProgram exited with code -2147024809.
System.ArgumentException: Library/Bee/artifacts/csharpactions/d41d8cd98f00b204e9800998ecf8427e.js.unityweb_gq44.info has already been registered with different file contents
   at Bee.TundraBackend.TundraBackend.AddWriteTextAction(NPath file, String contents, String actionName, NPath[] filesThatMightBeIncluded)
   at Bee.TundraBackend.TundraBackend.AddCSharpActionImpl(String actionName, NPath[] targetFiles, NPath[] inputs, Object argument, NPath[] targetDirectories, MethodInfo method)
   at Bee.TundraBackend.TundraBackend.AddCSharpAction(String actionName, NPath[] targetFiles, NPath[] inputs, Action`1 csharpAction, NPath[] targetDirectories)
   at WebGLPlayerBuildProgram.GzipMarker.Setup(NPath inputPath, NPath outputPath)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupCompressAndMarkGzip(NPath input, NPath output)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupCompression(NPath input, NPath output)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPostProcessBuildFile(NPath path)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPlayerExecutable()+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.ConcatNIterator`1.LazyToArray()
   at System.Linq.Enumerable.ConcatNIterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.RunBuildProgram()
   at PlayerBuildProgramTypeWrapper.Run(String[] args)
   at Program.Main(String[] args)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)

I previously was able to build just fine, but I'm not sure what's changed. I tried updating and downgrading multiple times between versions with no luck. I'm currently using 2021.3.19.

An empty project builds fine, so it's a problem with my project, but I don't know what, and the error isn't very helpful. I'm not sure how to debug this.

I tried deleting the Bee folder, BuildCache folder, Library folder, both with no luck.
I also tried removing the WebGL build module, reinstalling the Unity version I'm using, and still nothing worked.

If I look at the Editor.log file, I can see the steps of building, and it does go through basically everything, but after the final step, it fails with that error.

Any other ideas? I just started a new job that requires my project to build for WebGL, so this isn't a great start...

EDIT:
I changed the compression format from GZip to Disabled out of curiosity, and now I'm getting a different error:

Internal build system error. BuildProgram exited with code -2147024809.
System.ArgumentException: You're trying to copy to WebGLBuilds/Build/d41d8cd98f00b204e9800998ecf8427e.js more than once. Previously from Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.framework.js and now from Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.worker.framework.js
   at Bee.Core.CopyTool.Setup(NPath target, NPath from)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupCompression(NPath input, NPath output)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPostProcessBuildFile(NPath path)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPlayerExecutable()+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.ConcatNIterator`1.LazyToArray()
   at System.Linq.Enumerable.ConcatNIterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.RunBuildProgram()
   at PlayerBuildProgramTypeWrapper.Run(String[] args)
   at Program.Main(String[] args)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

[quote=“JudahMantell”, post:1, topic: 910777]
updating and downgrading multiple times between versions
[/quote]
Hopefully you didn’t do that with the same project but copies of the original project. Especially when it comes to “downgrading” there is no such thing. This could easily destroy your project.

If you actually did that, and don’t have the original project (before any up/downgrading) in source control, you may want to try re-applying the project into a newly created Unity project and try building for WebGL after every step (ie adding assets, adding scripts, assigning references to scripts and so on). Hopefully that doesn’t take more than a day.

But first, and generally for WebGL builds, be sure to test with the latest tech stream ie 2022.2 too.

And you could try resetting Project Settings and specifically Player settings to defaults, probably easiest to do by deleting the associated settings file. But as always: in a copy of the project.

Attached is the editor.log file:
[quote=“CodeSmile”, post:2, topic: 910777]
Hopefully you didn’t do that with the same project but copies of the original project. Especially when it comes to “downgrading” there is no such thing. This could easily destroy your project.

If you actually did that, and don’t have the original project (before any up/downgrading) in source control, you may want to try re-applying the project into a newly created Unity project and try building for WebGL after every step (ie adding assets, adding scripts, assigning references to scripts and so on). Hopefully that doesn’t take more than a day.

But first, and generally for WebGL builds, be sure to test with the latest tech stream ie 2022.2 too.

And you could try resetting Project Settings and specifically Player settings to defaults, probably easiest to do by deleting the associated settings file. But as always: in a copy of the project.
[/quote]
Thank you for the suggestions!
I’ve been using version control to always revert back to my pre-up/downgrade project, so no worries there.

I did try with the latest tech stream, but still had the same issue, so I went back to LTS. That’s why I think it’s a project-specific thing :frowning:

I’ll try resetting the Player Settings and see if that works, thank you!

Oh, also: check any non-Unity (code) assets you imported into the project whether they are compatible with WebGL. Maybe you can try removing some of the most potentially conflicting assets in a project copy, it doesn't matter if the build is usable, only whether you can make a build after that and if you can narrow down a suspect, try removing just that from another project copy, and if that makes the build succeed think about how you can work without that asset.

[quote=“CodeSmile”, post:4, topic: 910777]
Oh, also: check any non-Unity (code) assets you imported into the project whether they are compatible with WebGL. Maybe you can try removing some of the most potentially conflicting assets in a project copy, it doesn’t matter if the build is usable, only whether you can make a build after that and if you can narrow down a suspect, try removing just that from another project copy, and if that makes the build succeed think about how you can work without that asset.
[/quote]
I will definitely give that a try!

I reset the project settings, and now I get the following error: Maybe something isn’t set up correctly? I’m not sure how to fix it though.

Internal build system error. BuildProgram exited with code -2147024809.
Old commandline for WebGLBuilds/Build/WebGLBuilds.framework.js.unityweb:
  -o "WebGLBuilds/Build/WebGLBuilds.framework.js.unityweb" -i "Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.worker.framework.js" --comment
  "UnityWeb Compressed Content (brotli)"

New commandline for WebGLBuilds/Build/WebGLBuilds.framework.js.unityweb:
  -o "WebGLBuilds/Build/WebGLBuilds.framework.js.unityweb" -i "Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.framework.js" --comment
  "UnityWeb Compressed Content (brotli)"
System.ArgumentException: AddAction invocation conflicts with earlier invocation for "WebGLBuilds\Build\WebGLBuilds.framework.js.unityweb": commandLineArguments differ
Previous AddAction was here:
<stack trace disabled - set BEE_DEBUG to '1' to trace the source of a conflict>

   at Bee.Core.Backend.<>c__DisplayClass36_0.<AddAction>b__2(String msg)
   at Bee.Core.Backend.AddAction(String actionName, NPath[] targetFiles, NPath[] inputs, String executableStringFor, String[] commandLineArguments, Boolean supportResponseFile, Dictionary`2 environmentVariables, NPath[] rspAndBatchFiles, Boolean allowUnexpectedOutput, Boolean allowUnwrittenOutputFiles, Boolean banContentDigestForInputs, String[] allowedOutputSubstrings, NPath[] unavoidableOutputs, NPath[] targetDirectories, String[] sharedResources, Nullable`1 deleteOutputsBeforeRun, NPath[] filesThatMightBeIncluded, CachingMode cachingMode, NPath[] cachingInputIgnoreList, NPath profilerOutput, String responseFileSeparator)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupCompressAndMarkBrotli(NPath input, NPath output)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupCompression(NPath input, NPath output)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPostProcessBuildFile(NPath path)
   at WebGLPlayerBuildProgram.WebGLPlayer.SetupPlayerExecutable()+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.ConcatNIterator`1.LazyToArray()
   at System.Linq.Enumerable.ConcatNIterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.RunBuildProgram()
   at PlayerBuildProgramTypeWrapper.Run(String[] args)
   at Program.Main(String[] args)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

In the log above, the existence of a file mentioned as "build.worker.framework.js" reads wrong. Such a file should not exist as part of the build pipeline anywhere.

That is, there should be a file "build.framework.js", and additionally if C/C++ multithreading is enabled, there should also be a file "build.worker.js"; but there should never be a file "build.worker.framework.js".

So the presence of that file where both ".worker" and ".framework" exist simultaneously as a suffix does immediately suggest some kind of a bug.

Additionally the build lists ".unityweb" suffixes, so I presume the build options you have active are
- Release build (as opposed to Development)
- Native C/C++ multithreading enabled (this is disabled by default, I wonder if you were experimenting with WebGL multithreading in this project?)
- Decompression Fallback enabled (this is also disabled by default)

If you are still experiencing the issue, try to see if flipping any one (or more) of the above settings works around the issue?

I tried to locally reproduce the issue, but wasn't able to set up the conditions to see the bug. If you are still seeing the problem, please submit a test repro project as a bug against Unity, so it should then get to the team's backlog to investigate.

I am very sorry to pollute this thread with my comment as it doesn't add anything constructive but...

@jukka_j - Hope everything is well! Happy to see you back posting on the forums. Welcome back and thank you for your continued contributions! :)