Skip to content

Instantly share code, notes, and snippets.

@SolidAlloy
Last active May 16, 2022 18:52
Show Gist options
  • Save SolidAlloy/68b02da3c774c6691da7dab2eba190cc to your computer and use it in GitHub Desktop.
Save SolidAlloy/68b02da3c774c6691da7dab2eba190cc to your computer and use it in GitHub Desktop.
Workaround for when Unity complains about the missing RoslynAnalysisRunner folder.
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
Copy link

Mol0ko commented Sep 6, 2021

Could you please provide some explanation how to use this?

@SolidAlloy
Copy link
Author

@Mol0ko
Hey, you just put the script in an Editor folder, and it starts working and prevents Roslyn-related errors.

@Mol0ko
Copy link

Mol0ko commented Sep 6, 2021

Thanks a lot, it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment