We are using TeamCity for automatically building our game + running tests.
Analyzing errors in our automated pipieline is very important for us - if an error occurs we want to be able to easily understand what went wrong.
I would like to add some code to monitor Unity’s log (for errors / exceptions) and store it somewhere or report it in a different format (TeamCity has an internal message format that is used for displaying stuff in its UI).
The problem is - in case a developer pushes code with compiler errors - will my editor code still execute? (this code registers itself on log messages, kinda like this):
public static class UnityLogListener
{
[InitializeOnLoadMethod]
private static void Init()
{
Application.logMessageReceived += OnLogMessageReceived;
}
private static void OnLogMessageReceived(string condition, string stackTrace, LogType type)
{
if (type == LogType.Error || type == LogType.Exception)
{
// TODO: send to TeamCityLogger
}
}
}
Is there any way to ensure this code will execute, even if compiler errors are present ?
OK answering myself here, maybe firstpass assemblies is the way to go?
Is there any way to mimic this behaviour with asmdef?
I’m not sure that compilation pipeline results get loaded if there are compile errors, even for the assemblies that did compile successfully. You might need to store this ‘always-executable’ code in a precompiled assembly in the project.
I put the code in assembly-csharp-editor-firstpass, isn’t it enough? i assumed it will be compiled and loaded before other assemblies and so any errors in them would allow me to peek into that
Tested - looks a bit inconclusive - sometimes the changes were not reflected immediately.
Even precompiled didn’t help (i need to enforce this gets loaded - but i think with compilation errors it may not be loaded to memory).
I think i’ll still with Assembly-CSharp-Editor-Firstpass as its the closest thing to what i want (load early on, also in case of error)
I’m surprised to hear that precompiled didn’t help - I believe that’s the mechanism that Cloud Build uses.
Precompiled DLL - but where do you drop it? i only looked at the “firstpass” approach to make sure the thing is loaded into memory before anything else
I don’t think it should matter whereabouts in the project it is - the firstpass stuff only affects compilation order, not assembly load order.