Ejemplo n.º 1
0
        private bool OpenWindowsApp(string path, int line)
        {
            var progpath = FileUtility.GetPackageAssetFullPath("Editor", "COMIntegration", "Release", "COMIntegration.exe");

            if (string.IsNullOrWhiteSpace(progpath))
            {
                return(false);
            }

            string absolutePath = "";

            if (!string.IsNullOrWhiteSpace(path))
            {
                absolutePath = Path.GetFullPath(path);
            }

            // We remove all invalid chars from the solution filename, but we cannot prevent the user from using a specific path for the Unity project
            // So process the fullpath to make it compatible with VS
            var solution = GetOrGenerateSolutionFile(path);

            if (!string.IsNullOrWhiteSpace(solution))
            {
                solution = $"\"{solution}\"";
                solution = solution.Replace("^", "^^");
            }

            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = progpath,
                    Arguments              = $"\"{CodeEditor.CurrentEditorInstallation}\" {solution} \"{absolutePath}\" {line}",
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                }
            };
            var result = process.Start();

            while (!process.StandardOutput.EndOfStream)
            {
                var outputLine = process.StandardOutput.ReadLine();
                if (outputLine == "displayProgressBar")
                {
                    EditorUtility.DisplayProgressBar("Opening Visual Studio", "Starting up Visual Studio, this might take some time.", .5f);
                }

                if (outputLine == "clearprogressbar")
                {
                    EditorUtility.ClearProgressBar();
                }
            }

            var errorOutput = process.StandardError.ReadToEnd();

            if (!string.IsNullOrEmpty(errorOutput))
            {
                Console.WriteLine("Error: \n" + errorOutput);
            }

            process.WaitForExit();
            return(result);
        }
Ejemplo n.º 2
0
 public static void FindVSWhere()
 {
     _vsWherePath = FileUtility.GetPackageAssetFullPath("Editor", "VSWhere", "vswhere.exe");
 }