Add reference to .net standard csproj

So, I’m working on a little tool, with which I hope I can reference .net standard 2.0 projects from a unity solution. I know this is not currently possible, and the usual approach is to have the project in a separate solution and then copy the dll to the unity project folder. The problem is that in my opinion version controling dlls is not a paticurally good idea.

So my solution is to hook on the the Edit AssetProcessor, and when the sln and csprojs are created, I modify the sln and csproj to reference my project

using System.Globalization;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Random = System.Random;

namespace MyNamespace.Editor
{
    public class ProjectReferencePostProcessor : AssetPostprocessor
    {
        private static readonly string[] _references = { @"..\PathToMyProcet\MyProjectIWantToReference.csproj" };

        private static readonly Random _randomForHex = new Random();

        public static void OnGeneratedCSProjectFiles()
        {
            var projectPath = Path.Combine(Application.dataPath, "..");
            var slnPath = Directory.GetFiles(projectPath, "*.sln")[0];

            var slnContent = File.ReadAllLines(slnPath).ToList();

            const string projectTypeGuid = "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
            var csprojGuid = CreateVisualStudioGuid();
            // Add project to solution
            for (var i = 0; i < slnContent.Count; i++)
            {
                if (slnContent[i] != "Global") continue;

                var content = new[]
                {
                    $"Project(\"{{{projectTypeGuid}}}\") = \"{Path.GetFileName(_references[0])}\", \"{_references[0]}\", \"{{{csprojGuid}}}\"",
                    "EndProject"
                };

                slnContent.InsertRange(i, content);

                break;
            }
            // Add configs for project
            for (var i = 0; i < slnContent.Count - 1; i++)
            {
                if (!slnContent[i].Contains("EndGlobalSection") || !slnContent[i + 1].Contains("GlobalSection(SolutionProperties) = preSolution")) continue;

                var content = new[]
                {
                    $"\t\t{{{csprojGuid}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU",
                    $"\t\t{{{csprojGuid}}}.Debug|Any CPU.Build.0 = Debug|Any CPU",
                    $"\t\t{{{csprojGuid}}}.Release|Any CPU.ActiveCfg = Release|Any CPU",
                    $"\t\t{{{csprojGuid}}}.Release|Any CPU.Build.0 = Release|Any CPU",
                };

                slnContent.InsertRange(i, content);

                break;
            }

            File.WriteAllLines(slnPath, slnContent);

            var csprojPath = Directory.GetFiles(projectPath, "MyUnityProjectIWantToAddTheReference.csproj")[0];
            var csprojContent = File.ReadAllLines(csprojPath).ToList();
            const string pattern = "ProjectReference";
            // Reference library from unity project
            for (var i = 0; i < csprojContent.Count; i++)
            {
                if (!csprojContent[i].Contains(pattern)) continue;

                var content = new[]
                {
                    $"     <ProjectReference Include=\"{Path.GetFileName(_references[0])}\">",
                    $"       <Project>{{{csprojGuid}}}</Project>",
                    "       <Name>MyProjectIWantToReference</Name>",
                    "     </ProjectReference>",
                };

                csprojContent.InsertRange(i, content);

                break;
            }

            File.WriteAllLines(csprojPath, csprojContent);
        }

        private static string CreateVisualStudioGuid()
        {
            return GetRandomHexNumber(8) + "-" + GetRandomHexNumber(4) + "-" + GetRandomHexNumber(4) + "-" + GetRandomHexNumber(4) + "-" + GetRandomHexNumber(12);

            string GetRandomHexNumber(int digits)
            {
                var buffer = new byte[digits / 2];
                _randomForHex.NextBytes(buffer);
                var result = string.Concat(buffer.Select(x => x.ToString("X2", CultureInfo.InvariantCulture)).ToArray());

                if (digits % 2 == 0) return result;

                return result + _randomForHex.Next(16).ToString("X", CultureInfo.InvariantCulture);
            }
        }

        public override int GetPostprocessOrder() => 21;
    }
}

// Sorry for messy code this is a WIP
The .sln and .csproj files are modified as expected, I can see the project added to the generated solution, and the unity project is referencing the .net standard library, ReSharper also can see it, the API compatibility level is set to .Net Standard 2.0, with mono as scripting backend.

The problem is that it does not work. I get The type or namespace name ‘MySubNameSpace’ does not exist in the namespace ‘MyProjectIWantToReference’ (are you missing an assembly reference?)

At this point I don’t know what to do, it seems as there are some other steps needed to compile the unity project and it is not directly linked to the generated solution (as the unity editor can run without ever generating them)

Anyone who have maybe managed to do this, or someone from the unity team can give me some hints what am I missig?

PS: I hope this is the right place to ask these questions

Also tried to reference a .Net Framework 4.7.2 library, didn’t work either