error CS0006: cannot find metadata file Assembly-CSharp-firstpass.dll

Hi, I have written an editor script to automate building of several scenes into bundles, and then the main web player. It works fine on PCs, but has started failing on Macs with this message visible in the editor log.

-----CompilerOutput:-stdout–exitcode:1–compilationhadfailure:True–outfile:Temp/3b1c3f43cee534541b1b323ae8759ffa.dll
Compilation failed: 1 error(s), 0 warnings
-----CompilerOutput:-stderr----------
error CS0006: cannot find metadata file `Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll’

(and how about this for odd… usually this ‘metadata’ error does not appear in the console, but twice I have seen it appear in the console output but then no longer exist in the console output when I scroll back up to look for it.)

Another oddity is that this error does not occur if a particular one of the scenes is open (and I make sure it is saved) when I run the editor menu command. It also works if I build scenes individually.

I still have things to investigate, such as removing elements from that one scene to see if one particular element is causing the problem, but was wondering
(a) if someone had any experience with an error like this or
(b) general suggestions of how to attack it, and
(c) if I was taking a bad approach anyway, (using an editor menu command for building) and there were suggestions for a better way to do custom builds.

I’ve had something similar on a mac while building although it didn’t seem to cause problems in the build (if I pressed cancel on the error window that opened) and didn’t show again when rebuilding the scene (I presume it was then saved as you have mentioned).

I remember it was Assembly-Csharp but I’m not sure if it was the firstpass.dll or another.

Unfortunately it is causing my call to BuildPipeline.buildPlayer to fail.

Hey, I just realised a possible clue. Every time I call BuildPlayer all the scripts are recompiled for some reason. But I am running one of those scripts. Put that way it seems surprising that the PC version works at all.

(edit: I have also notice that The Mac immediately recompiles scripts when I save them, whereas on the PC it waits until the unity editor gains focus)

This is the function to build a scene. It gets called repeatedly. Im splitting it into a bundle (to be loaded first) and a scene file to be loaded last. The intention was to let some assets be loaded before the scene was loaded. Also I was intending to extend this to having a bundle of assets shared between scenes at some point.

This function is inside my own class which encapsulates everything we need to know about building a single scene.

public void BuildScene()
    {
        string currScene = this.GetFullScenePath();
        // Returns the path to the unity scene asset file

        Debug.Log("### Build Scene Bundle:" + currScene);

        string sceneName = Path.GetFileNameWithoutExtension(currScene);
        string baseOutputPath = EditorHelpers.AssetbundlePath;
        // the path that I am saving my bundles to.

        string bundleOutputPath
            = baseOutputPath + sceneName + "_BUNDLE.unity3d";
        string sceneOutputPath
            = baseOutputPath + sceneName + "_SCENE.unity3d";

        List<Object> assetList
            = this.GetAssetsToBundle(); 
        //the objects I intend to put into the bundle instead of the scene.

        SceneBundleHeader sceneHeader = CreateSceneBundleHeader(assetList); 
        //a simple object I put into the bundle.
        //Its the first thing I load when actually using the bundle.

        BuildAssetBundleOptions bundleOptions =
            BuildAssetBundleOptions.CollectDependencies |
            BuildAssetBundleOptions.CompleteAssets;

        {   //Build both bundles,
            //with the scene bundle not including dependencies
            //already in the asset bundle
            BuildPipeline.PushAssetDependencies();

			Debug.Log("### (1) Bundle:" + bundleOutputPath);
            BuildPipeline.BuildAssetBundle(
                sceneHeader,
                assetList.ToArray(),
                bundleOutputPath,
                bundleOptions);

			Debug.Log("### (2) Player:" + sceneOutputPath);
            string[] scenesToBuild = { currScene };
            BuildPipeline.BuildPlayer(
                scenesToBuild,
                sceneOutputPath,
                BuildTarget.WebPlayer,
                BuildOptions.BuildAdditionalStreamedScenes);

            BuildPipeline.PopAssetDependencies();
            DeleteSceneBundleHeader(sceneHeader);
        }
    }

Still not resolved.
I stumbled across two functions:
EditorApplication.LockReloadAssemblies() UnlockReloadAssemblies()
but these did not solve the problem, so it might not be related to rebuilding scripts after all.