Why does Unity add cecil.mono

Hi, When I try and build a project in unity, it always adds the library cecil.mono, but then the build fails complaining that " The type or namespace name ‘Mono’ could not be found (are you missing a using directive or an assembly reference?)".

My question is, why is Unity adding this by itself. I need to delete the line in the code for the build to finally successfully build. I dont understand why unity adds it.

Cecil is a core library of Unity for as long as i can remember.

The error you get is unrelated to that, might stem from one of your scripts or perhaps a package that needs an update.

Could you post it in full including stacktrace from the Console?

I have been getting the issue for every project I have tried to build over the past year or so, both using Unity 6 and 2022 versions, would that not be odd if it was a package that needed updated? (I assume they are updated with every unity install?)

I have cleared the errors now by removing the lines from the scripts, so i dont have the errors in the console anymore. But I do have the editor log. I am not sure how much I should paste, so will just show everything I think is relevant to the stacktrace.

##### Output
Assets\Scripts\ActivateEndOfDayScreen.cs(1,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)

Assets\Scripts\Managers\IncidentManager.cs(2,19): error CS0234: The type or namespace name 'Rendering' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

Assets\Scripts\Managers\metricsManager.cs(7,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
*** Tundra build failed (43.00 seconds), 568 items updated, 707 evaluated
STDOUT:
[ApiUpdater] Total time: 2587ms, Parse response file: 105ms, Collect updater configs: 829ms, Update: 1653ms, Save: 0ms Files: 0 modified / 3 visited / 68 total (Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.dll).
STDERR:
[Script Updater] Assets/Scripts/ActivateEndOfDayScreen.cs(1,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
[Script Updater] Assets/Scripts/Managers/IncidentManager.cs(2,19): error CS0234: The type or namespace name 'Rendering' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
[Script Updater] Assets/Scripts/Managers/metricsManager.cs(7,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
## Script Compilation Error for: Csc Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.dll (+2 others)
## CmdLine: "E:\Unity\Editors\6000.0.50f1\Editor\Data\NetCoreRuntime\dotnet.exe" exec "E:/Unity/Editors/6000.0.50f1/Editor/Data/DotNetSdkRoslyn/csc.dll" /nostdlib /noconfig /shared "@Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.rsp" "@Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.rsp2"
## Output:
Assets\Scripts\ActivateEndOfDayScreen.cs(1,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\Managers\IncidentManager.cs(2,19): error CS0234: The type or namespace name 'Rendering' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
Assets\Scripts\Managers\metricsManager.cs(7,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)

Script updater for Library\Bee\artifacts\1900b0aP.dag\Assembly-CSharp.dll failed to produce updates.txt file (response file: Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.rsp, MovedFromCache: E:/Unity/Projects/OneMinuteMayor2D/Library/Bee/artifacts/1900b0aP.dag/Assembly-CSharp.dll.mvfrm
Assets\Scripts\ActivateEndOfDayScreen.cs(1,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\Managers\IncidentManager.cs(2,19): error CS0234: The type or namespace name 'Rendering' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
Assets\Scripts\Managers\metricsManager.cs(7,7): error CS0246: The type or namespace name 'Mono' could not be found (are you missing a using directive or an assembly reference?)
Failed to compile player scripts
UnityEngine.Debug:ExtractStackTraceNoAlloc (byte*,int,string)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScriptsNative (UnityEditor.Build.Player.ScriptCompilationSettings,string,bool)
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScriptsInternal (UnityEditor.Build.Player.ScriptCompilationSettings,string,bool)
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScripts (UnityEditor.Build.Player.ScriptCompilationSettings,string)
UnityEditor.Build.Pipeline.Tasks.BuildPlayerScripts:Run () (at ./Library/PackageCache/com.unity.scriptablebuildpipeline@7e8a1cf5a47d/Editor/Tasks/BuildPlayerScripts.cs:41)
UnityEditor.Build.Pipeline.BuildTasksRunner:Run (System.Collections.Generic.IList`1<UnityEditor.Build.Pipeline.Interfaces.IBuildTask>,UnityEditor.Build.Pipeline.Interfaces.IBuildContext) (at ./Library/PackageCache/com.unity.scriptablebuildpipeline@7e8a1cf5a47d/Editor/Shared/BuildTasksRunner.cs:56)
UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles (UnityEditor.Build.Pipeline.Interfaces.IBundleBuildParameters,UnityEditor.Build.Pipeline.Interfaces.IBundleBuildContent,UnityEditor.Build.Pipeline.Interfaces.IBundleBuildResults&,System.Collections.Generic.IList`1<UnityEditor.Build.Pipeline.Interfaces.IBuildTask>,UnityEditor.Build.Pipeline.Interfaces.IContextObject[]) (at ./Library/PackageCache/com.unity.scriptablebuildpipeline@7e8a1cf5a47d/Editor/ContentPipeline.cs:156)
UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:DoBuild<UnityEditor.AddressableAssets.Build.AddressablesPlayerBuildResult> (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput,UnityEditor.AddressableAssets.Build.DataBuilders.AddressableAssetsBuildContext) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:343)
UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:BuildDataImplementation<UnityEditor.AddressableAssets.Build.AddressablesPlayerBuildResult> (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/DataBuilders/BuildScriptPackedMode.cs:133)
UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase:BuildData<UnityEditor.AddressableAssets.Build.AddressablesPlayerBuildResult> (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/DataBuilders/BuildScriptBase.cs:103)
UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContentImpl (UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput,bool) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Settings/AddressableAssetSettings.cs:3061)
UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent (UnityEditor.AddressableAssets.Build.AddressablesPlayerBuildResult&,UnityEditor.AddressableAssets.Build.AddressablesDataBuilderInput) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Settings/AddressableAssetSettings.cs:2970)
UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor:BuildAddressablesWithResult (UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor/BuildMenuContext) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/GUI/AddressableAssetsSettingsGroupEditor.cs:579)
AddressablesPlayerBuildProcessor:DefaultBuild (UnityEditor.AddressableAssets.Settings.AddressableAssetSettings) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/AddressablesPlayerBuildProcessor.cs:143)
AddressablesPlayerBuildProcessor:PrepareForPlayerbuild (UnityEditor.AddressableAssets.Settings.AddressableAssetSettings,UnityEditor.Build.BuildPlayerContext,bool) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/AddressablesPlayerBuildProcessor.cs:100)
AddressablesPlayerBuildProcessor:PrepareForBuild (UnityEditor.Build.BuildPlayerContext) (at ./Library/PackageCache/com.unity.addressables@2581a6be7421/Editor/Build/AddressablesPlayerBuildProcessor.cs:79)
UnityEditor.Build.BuildPipelineInterfaces:PreparePlayerBuild (UnityEditor.Build.BuildPlayerContext)
UnityEditor.BuildPipeline:PreparePlayerBuild (UnityEditor.BuildPlayerOptions)
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[],bool)
UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
UnityEditor.Build.Profile.BuildProfileModuleUtil:CallInternalBuildMethods (bool,UnityEditor.BuildOptions)
UnityEditor.Build.Profile.BuildProfileWindow/<>c__DisplayClass41_0:<OnBuildButtonClicked>b__0 ()
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

So I guess the auto updater has updated some of your old scripts and may have introduced some errors on the way. It’s hard to tell and the auto-updater can’t perform miracles. Generally different Unity versions are not necessarily compatible with each other, especially when your project was on a very old version of Unity a lot things could have changed in the mean time.

Did you backup your project before opening it in a new Unity version? In any case you would need to fix your scripts in any case. If the Updater added those namespaces, have you tried remove them again? Did the updater replace some code that relies on those namespaces? From the given errors we can’t really tell. Can you post one of the script, for example the first one " ActivateEndOfDayScreen.cs"?

Though some errors seems a bit strange like why is the IncidentManager using the UnityEditor namespace? That seems to be a runtime script and as such can never use the UnityEditor namespace. Was that also a change that the Auto-Updater introduced? For this it would be great to have the original scripts before the update for comparison. Using any kind of source control by any change? git?

I myself did not backup or put many of my small test projects into source control, but they are not that important. Once a project grows to a certain size, you definitely want to use source control. If you actually start a serious project, you usually want to use source control from day one. This also serves as a dev log for yourself. Such auto upgrade issues could then be directly viewed in git as a diff view to see what was changed,

Sorry I might have explained this in a not clear way. What I meant with ‘it happens over different versions’ is that it happened with different projects in those unity versions. I have not opened the project created in an old version and then moved it to a new version. I have one project in Unity 2022 that I tried to build and got the same errors, and then another project built solely in Unity 6, and that has the same errors too.

I have no idea why IncidentManager is using the UnityEditor, that namespace does not seem to even be in the script :face_with_diagonal_mouth: .

Sounds like intellisense to me. When using Visual Studio, I ALWAYS end up with a file somewhere that accidentally included the NUnit edit-time only libs instead of Unity’s runtime one because as soon as I type the word ‘Assert’ Visual Studio immediately decided that’s the namespace I want to use even if I specify otherwise. It’s basically become a new step for me every time I want to make a build. Build. Watch it fail. Search for Nunit libs in runtime files. Remove them. Rebuild. Profit.

Yes, certainly possible. While the automatic namespace resolver is quite useful in many cases, you should be aware that namespaces exist because there are name collisions and if you have 10 versions of a type name your IDE can not guess the “right” one.

Some AI rant

AI is getting better, but it’s far from reading minds and personally I don’t really like how most AI is integrated because it means the AI may adapt over time to what is more commonly used to appear smart. Though that means the behaviour gets more unpredictable. I like tools I can trust, even if I can trust that it does the same thing wrong all the time. Automatic assistants that are unpredictable are kinda useless because you essentially need to check their work every time to be sure. It’s like an unreliable employee that causes more work than it finishes ^^.

The auto selection of namespace almost falls into that category. When I use it in the IDE I usually go for manually resolving the missing namespaces. Most IDEs will suggest a list of potential candidates. But in the end I like to be the one who is selecting the namespace. So the AI is literally just assisting me.

@Bunny83

I have disabled the auto resolve feature many times but eventually Microsoft always helpfully notices that I disabled things like that, along with copilot, Code Lens, and a host of other wonder features that “boost my productivity” by massively slowing down my computer and generally auto-completing the wrong thing every time I dare touch the keyboard. I know a lot of people are upset about the latest update with Windows 11, but hey, I got to experience that last spring on Windows 10 when I spent a whole weekend trouble shooting why my machine was running like a PentiumII despite every tool telling it it definitely wasn’t something wrong with my SSD. I’ve since setup my Linux dual boot and plan to be moving over permanently as soon as a can the software I need to continue doing what I do. As much as I’ve stood with Microsoft’s stuff over the years because I genuinely preferred it and thought it was just the easier way to go, they have really just crushed the camel in the last year or so for me.

That’s so funny to read your reply :slight_smile: That’s because I’m in the same boat. I’m a windows child from day one. Got my first PC in 1995 (when I was 11, I think). I know windows and the ecosystem inside out. Each version jump brought a lot of pain and relieve at the same time. So the pros and cons kinda balanced each other out and you just get used to the new one over time. I was always a late adopter.

I haven’t yet started my Linux desktop setup and haven’t decided on a distro but I did a lot of evaluation what software is available, what alternatives for some of the smaller tools I use are there for Linux and I prepared an external 2TB drive for my first attempt. I’m not that linux savvy yet, though I do have my Raspberry pi as a training tool for some years now :). At my job (not game dev related) I also setup and maintain some ubuntu servers, so just more practise. I’m still on Win10 and I don’t plan on upgrading to 11.

MS did quite a few tiny steps I’m not really comfortable with. The extreme push towards SaS for literally everything, the patronization of users as if the hardware belongs to them and a general drop in backwards compatibility and quality when it comes to the basic OS features.

It’s kinda funny that GabeN left MS to be more free in game dev and Valve’s Linux support is one of the major factors for people switching over. Though I fear Valve’s slowly becoming the new MS and people have to push back early before it’s too late.

Anyways I think we went a bit off track here :slight_smile:

I really wish it would CONSISTENTLY do that and ACTUALLY adapt. Yet, nine out of ten times it will autosuggest the right type … but … every once in a while … it’s a System.Dildo :smiling_face_with_sunglasses:


I’ve been sensitized to that particular issue but it’s so aggravating that even after manually choosing the desired type multiple times recently and that type already being used within the context of the edited file, if not type, it would STILL insists on suggesting the System.Dildo.

And that’s Rider whose autosuggest I can really rather rely on. But that particular issue .. it’s been around for 20+ years now and to this day even with AI no IDE has managed to improve these suggestions to consider what makes most sense in the given context.

I do sometimes (rarely) tweak namespaces I don’t want to get autosuggested ever again. I just worry that if I do that, it might come back and haunt me when I actually would need that type/namespace.