Last active
May 16, 2022 18:52
-
-
Save SolidAlloy/68b02da3c774c6691da7dab2eba190cc to your computer and use it in GitHub Desktop.
Workaround for when Unity complains about the missing RoslynAnalysisRunner folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.Text.RegularExpressions; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
internal static class RoslynDirectoryCreator | |
{ | |
static RoslynDirectoryCreator() => Application.logMessageReceived += OnLogMessageReceived; | |
private static void OnLogMessageReceived(string message, string _, LogType logType) | |
{ | |
if (logType != LogType.Exception) | |
return; | |
const string pattern = | |
@"^DirectoryNotFoundException: Could not find " + | |
@"a part of the path ('|"")Temp(\\|/)RoslynAnalysisRunner"; | |
if (Regex.IsMatch(message, pattern)) | |
{ | |
Directory.CreateDirectory("Temp/RoslynAnalysisRunner"); | |
} | |
} | |
} |
@Mol0ko
Hey, you just put the script in an Editor folder, and it starts working and prevents Roslyn-related errors.
Thanks a lot, it works
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please provide some explanation how to use this?