SyncSolution
This commit is contained in:
parent
450bc133b8
commit
259075c83a
5
.idea/.idea.AsmdefHelper/.idea/workspace.xml
generated
5
.idea/.idea.AsmdefHelper/.idea/workspace.xml
generated
@ -2,9 +2,8 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="f71251e0-52ab-4cea-859f-4c363c01a121" name="Default Changelist" comment="">
|
<list default="true" id="f71251e0-52ab-4cea-859f-4c363c01a121" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/contentModel.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.AsmdefHelper/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Assets/AsmdefHelper/Unity.InternalAPIEditorBridgeDev.001/Unity.InternalAPIEditorBridgeDev.001.asmdef" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/AsmdefHelper/Unity.InternalAPIEditorBridgeDev.001/Unity.InternalAPIEditorBridgeDev.001.asmdef" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Assets/AsmdefHelper/SyncSolution/Editor/SyncSolutionUtilities.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/AsmdefHelper/SyncSolution/Editor/SyncSolutionUtilities.cs" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -82,7 +81,7 @@
|
|||||||
<workItem from="1586792539676" duration="101000" />
|
<workItem from="1586792539676" duration="101000" />
|
||||||
<workItem from="1586793017650" duration="506000" />
|
<workItem from="1586793017650" duration="506000" />
|
||||||
<workItem from="1586793564564" duration="160000" />
|
<workItem from="1586793564564" duration="160000" />
|
||||||
<workItem from="1586793758449" duration="679000" />
|
<workItem from="1586793758449" duration="1552000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,93 +1,62 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.VisualStudioIntegration;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
// https://forum.unity.com/threads/solved-unity-not-generating-sln-file-from-assets-open-c-project.538487/
|
// https://forum.unity.com/threads/solved-unity-not-generating-sln-file-from-assets-open-c-project.538487/
|
||||||
namespace EditorUtilities.Solution
|
// Thank you Flexford!
|
||||||
{
|
namespace AsmdeffHelper.SyncSolution {
|
||||||
public static class SyncSolutionUtilities
|
public static class SyncSolutionUtilities {
|
||||||
{
|
static SolutionSynchronizer synchronizer;
|
||||||
private static Type _syncVSType;
|
|
||||||
private static MethodInfo _syncSolutionMethodInfo;
|
|
||||||
|
|
||||||
private static FieldInfo _synchronizerField;
|
static SyncSolutionUtilities() {
|
||||||
private static object _synchronizerObject;
|
synchronizer = SyncVS.Synchronizer;
|
||||||
private static Type _synchronizerType;
|
|
||||||
private static MethodInfo _synchronizerSyncMethodInfo;
|
|
||||||
|
|
||||||
static SyncSolutionUtilities()
|
|
||||||
{
|
|
||||||
_syncVSType = Type.GetType("UnityEditor.SyncVS,UnityEditor");
|
|
||||||
_synchronizerField = _syncVSType.GetField("Synchronizer", BindingFlags.NonPublic | BindingFlags.Static);
|
|
||||||
_syncSolutionMethodInfo = _syncVSType.GetMethod("SyncSolution", BindingFlags.Public | BindingFlags.Static);
|
|
||||||
|
|
||||||
_synchronizerObject = _synchronizerField.GetValue(_syncVSType);
|
|
||||||
_synchronizerType = _synchronizerObject.GetType();
|
|
||||||
_synchronizerSyncMethodInfo = _synchronizerType.GetMethod("Sync", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Sync C# Solution", priority = 1000000)]
|
[MenuItem("Window/Asmdef Helper/Sync C# Solution", priority = 1000000)]
|
||||||
public static void Sync()
|
public static void Sync() {
|
||||||
{
|
|
||||||
Sync(true);
|
Sync(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Sync(bool logsEnabled)
|
static void Sync(bool logsEnabled) {
|
||||||
{
|
|
||||||
CleanOldFiles(logsEnabled);
|
CleanOldFiles(logsEnabled);
|
||||||
Call_SyncSolution(logsEnabled);
|
Call_SyncSolution(logsEnabled);
|
||||||
Call_SynchronizerSync(logsEnabled);
|
Call_SynchronizerSync(logsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CleanOldFiles(bool logsEnabled)
|
static void CleanOldFiles(bool logsEnabled) {
|
||||||
{
|
var assetsDirectoryInfo = new DirectoryInfo(Application.dataPath);
|
||||||
DirectoryInfo assetsDirectoryInfo = new DirectoryInfo(Application.dataPath);
|
var projectDirectoryInfo = assetsDirectoryInfo.Parent;
|
||||||
DirectoryInfo projectDirectoryInfo = assetsDirectoryInfo.Parent;
|
|
||||||
|
|
||||||
IEnumerable<FileInfo> files = GetFilesByExtensions(projectDirectoryInfo, "*.sln", "*.csproj");
|
var files = GetFilesByExtensions(projectDirectoryInfo, "*.sln", "*.csproj");
|
||||||
foreach(FileInfo file in files)
|
foreach (var file in files) {
|
||||||
{
|
if (logsEnabled) {
|
||||||
if(logsEnabled)
|
|
||||||
{
|
|
||||||
Debug.Log($"Remove old solution file: {file.Name}");
|
Debug.Log($"Remove old solution file: {file.Name}");
|
||||||
}
|
}
|
||||||
file.Delete();
|
file.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Call_SyncSolution(bool logsEnabled)
|
static void Call_SyncSolution(bool logsEnabled) {
|
||||||
{
|
if (logsEnabled) {
|
||||||
if(logsEnabled)
|
|
||||||
{
|
|
||||||
Debug.Log($"Coll method: SyncVS.Sync()");
|
Debug.Log($"Coll method: SyncVS.Sync()");
|
||||||
}
|
}
|
||||||
|
SyncVS.SyncSolution();
|
||||||
_syncSolutionMethodInfo.Invoke(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Call_SynchronizerSync(bool logsEnabled)
|
static void Call_SynchronizerSync(bool logsEnabled) {
|
||||||
{
|
if (logsEnabled) {
|
||||||
if(logsEnabled)
|
|
||||||
{
|
|
||||||
Debug.Log($"Coll method: SyncVS.Synchronizer.Sync()");
|
Debug.Log($"Coll method: SyncVS.Synchronizer.Sync()");
|
||||||
}
|
}
|
||||||
|
synchronizer?.Sync();
|
||||||
_synchronizerSyncMethodInfo.Invoke(_synchronizerObject, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions)
|
static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) {
|
||||||
{
|
|
||||||
extensions = extensions ?? new[] { "*" };
|
extensions = extensions ?? new[] { "*" };
|
||||||
IEnumerable<FileInfo> files = Enumerable.Empty<FileInfo>();
|
var files = Enumerable.Empty<FileInfo>();
|
||||||
foreach(string ext in extensions)
|
return extensions.Aggregate(files, (current, ext) => current.Concat(dir.GetFiles(ext)));
|
||||||
{
|
|
||||||
files = files.Concat(dir.GetFiles(ext));
|
|
||||||
}
|
|
||||||
return files;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user