Procházet zdrojové kódy

兼容rider跟vs的pdb文件路径

tanghai před 7 roky
rodič
revize
b9071f9ab4
1 změnil soubory, kde provedl 23 přidání a 16 odebrání
  1. 23 16
      Unity/Assets/Editor/BuildEditor/BuildHotifxEditor.cs

+ 23 - 16
Unity/Assets/Editor/BuildEditor/BuildHotifxEditor.cs

@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using System;
 using System.IO;
 using System.IO;
 using ETModel;
 using ETModel;
 using UnityEditor;
 using UnityEditor;
@@ -9,7 +9,6 @@ namespace ETEditor
     public class Startup
     public class Startup
     {
     {
         private const string ScriptAssembliesDir = "Library/ScriptAssemblies";
         private const string ScriptAssembliesDir = "Library/ScriptAssemblies";
-        private const string DebugDir = "Temp/UnityVS_bin/Debug";
         private const string CodeDir = "Assets/Res/Code/";
         private const string CodeDir = "Assets/Res/Code/";
         private const string HotfixDll = "Unity.Hotfix.dll";
         private const string HotfixDll = "Unity.Hotfix.dll";
         private const string HotfixPdb = "Unity.Hotfix.pdb";
         private const string HotfixPdb = "Unity.Hotfix.pdb";
@@ -17,24 +16,32 @@ namespace ETEditor
 
 
         static Startup()
         static Startup()
         {
         {
-            string batPath = $"Tools{Path.DirectorySeparatorChar}pdb2mdb.exe";
-            
-            ProcessStartInfo info = new ProcessStartInfo
+            // Copy最新的pdb文件
+            string[] pdbDirs = 
             {
             {
-                FileName = batPath,
-                WindowStyle = ProcessWindowStyle.Hidden,
-                ErrorDialog = true,
-                UseShellExecute = true,
-                Arguments = Path.Combine(ScriptAssembliesDir, HotfixDll)
+                "Temp/UnityVS_bin/Debug", 
+                "Temp/UnityVS_bin/Release", 
+                "Temp/Debug", 
+                "Temp/Release"
             };
             };
-            
-            Process p = Process.Start ( info );
-            p.WaitForExit ();
-            
 
 
-            if (File.Exists(Path.Combine(DebugDir, HotfixPdb)))
+            DateTime dateTime = DateTime.MinValue;
+            string newestPdb = "";
+            foreach (string pdbDir in pdbDirs)
+            {
+                string pdbPath = Path.Combine(pdbDir, HotfixPdb);
+                FileInfo fi = new FileInfo(pdbPath);
+                DateTime lastWriteTimeUtc = fi.LastWriteTimeUtc;
+                if (lastWriteTimeUtc > dateTime)
+                {
+                    newestPdb = pdbPath;
+                    dateTime = lastWriteTimeUtc;
+                }
+            }
+            
+            if (newestPdb != "")
             {
             {
-                File.Copy(Path.Combine(DebugDir, HotfixPdb), Path.Combine(CodeDir, "Hotfix.pdb.bytes"), true);
+                File.Copy(Path.Combine(newestPdb), Path.Combine(CodeDir, "Hotfix.pdb.bytes"), true);
                 Log.Info($"复制Hotfix.pdb到Res/Code完成");
                 Log.Info($"复制Hotfix.pdb到Res/Code完成");
             }
             }