-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsln_csproj_generator.cs
More file actions
35 lines (29 loc) · 1011 Bytes
/
sln_csproj_generator.cs
File metadata and controls
35 lines (29 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public static class VSProjectGenerator
{
static bool enableLogs = false;
public static void Log(string msg)
{
if (!enableLogs) return;
Debug.Log(msg);
}
[InitializeOnLoadMethod]
public static void GenerateSLN()
{
Assembly vsEditorAssembly = AppDomain.CurrentDomain.GetAssemblies()
.FirstOrDefault(a => a.GetName().Name == "Unity.VisualStudio.Editor");
Type cliType = vsEditorAssembly?.GetType("Microsoft.Unity.VisualStudio.Editor.Cli", false, false);
MethodInfo generateSolutionMethod = cliType?.GetMethod("GenerateSolution", BindingFlags.Static | BindingFlags.NonPublic);
if (generateSolutionMethod != null)
{
generateSolutionMethod.Invoke(null, null);
Log("Successfully invoked GenerateSolution.");
return;
}
Log($"Failed - Targeted Method is null");
}
}