LinkSlnHelper.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using UnityEditor;
  6. namespace ET
  7. {
  8. public static class LinkSlnHelper
  9. {
  10. [MenuItem("ET/Loader/LinkSln")]
  11. public static void Run()
  12. {
  13. string etslnPath = Path.Combine(Directory.GetCurrentDirectory(), "ET.sln");
  14. if (File.Exists(etslnPath))
  15. {
  16. File.Delete(etslnPath);
  17. }
  18. List<string> slns = new List<string>();
  19. FileHelper.GetAllFiles(slns, "./Packages", "ET.sln");
  20. if (slns.Count == 0)
  21. {
  22. throw new Exception("not found ET.sln in et packages!");
  23. }
  24. Process process = ProcessHelper.PowerShell($"-c New-Item -ItemType HardLink -Target {slns[0]} ./ET.sln", waitExit: true);
  25. UnityEngine.Debug.Log(process.StandardOutput.ReadToEnd());
  26. // link xml
  27. string xmlFile = Path.Combine(Path.GetDirectoryName(slns[0]), "link.xml");
  28. if (File.Exists(xmlFile))
  29. {
  30. UnityEngine.Debug.LogWarning("not found link.xml !!!!");
  31. Process process2 = ProcessHelper.PowerShell($"-c New-Item -ItemType HardLink -Target {xmlFile} ./Assets/link.xml", waitExit: true);
  32. UnityEngine.Debug.Log(process2.StandardOutput.ReadToEnd());
  33. }
  34. }
  35. }
  36. }