(Case 1117939) (Bug) Unity 2018 broke the asset import and therefore our CI/CD setup reproducable

Was not able to reproduce it in a new project yet. Will have to invest more time slowly porting part by part of the other project to the reproduceable project to see when and how it starts to break :frowning:

[MenuItem("Fix Assets")]
public static void FixBrokenAssets()
{
var paths = AssetDatabase.GetAllAssetPaths().Where(p => !IgnoreAssets(p));
var pathArray = paths as string[] ?? paths.ToArray();
var scripts = pathArray.Where(IsScript);
var scriptableObject = pathArray.Where(IsScriptableObject);
var prefabs = pathArray.Where(IsPrefab);
var asmdef = pathArray.Where(IsAsmdef);
foreach (var path in scripts)
    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
foreach (var path in scriptableObject)
    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
foreach (var path in prefabs)
    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
foreach (var path in asmdef)
    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
}

private static bool IgnoreAssets(string path) =>
    string.IsNullOrEmpty(path) || path.StartsWith("Packages") || path.StartsWith("ProjectSettings");

private static bool IsScript(string path) => path.EndsWith(".cs");
private static bool IsScriptableObject(string path) => path.EndsWith(".asset");

private static bool IsPrefab(string path) => path.EndsWith(".prefab");

private static bool IsAsmdef(string path) => path.EndsWith(".asmdef");

This obviously is a horrible solution and increases the time each CI configuration takes by one order of magnitude for us (except actual building a player obviously) but it at least it DOES fix the problem temporarily. I need to see if this fix is table or if batchmode exits before it is done - what I actually fear because I am pretty sure it does so before recompilation.

Edit: Updated the order of imports as scripts and scriptable objects have to be reimported before prefabs using them to fix the prefabs and the asmdef has to be reimported to find the tests after the scripts have been reimported.

Edit2: Added missing helper methods.