Пример #1
0
        private static async void OpenWithGameStudioMenuCommand_Callback(object sender, EventArgs e)
        {
            var dte = (DTE2)ServiceProvider.GetService(typeof(SDTE));

            var solutionFile = dte.Solution?.FileName;

            // Is there any active solution?
            if (solutionFile == null)
            {
                return;
            }

            // Locate GameStudio
            var packageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionFile, "Stride.GameStudio");

            if (packageInfo.LoadedVersion == null || packageInfo.SdkPaths.Count == 0)
            {
                return;
            }

            var mainExecutable = packageInfo.SdkPaths.First(x => Path.GetFileName(x) == "Stride.GameStudio.exe");

            if (mainExecutable == null)
            {
                throw new InvalidOperationException("Could not locate GameStudio process");
            }
            if (Process.Start(mainExecutable, $"\"{solutionFile}\"") == null)
            {
                throw new InvalidOperationException("Could not start GameStudio process");
            }
        }
Пример #2
0
        private async System.Threading.Tasks.Task InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte          = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;

            // Get General Output pane (for error logging)
            var generalOutputPane = GetGeneralOutputPane();

            try
            {
                StrideCommandsProxy.SetSolution(solutionPath);
                var stridePackageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionPath);

                StrideCommandsProxy.SetPackageInfo(stridePackageInfo);
                if (stridePackageInfo.LoadedVersion is null)
                {
                    return;
                }

                // Enable UIContext depending on wheter it is a Stride project. This will show or hide Stride menus.
                var isStrideSolution = stridePackageInfo.LoadedVersion != null;
                UpdateCommandVisibilityContext(isStrideSolution);

                // If a package is associated with the solution, check if the correct version was found
                if (stridePackageInfo.ExpectedVersion != null && stridePackageInfo.ExpectedVersion != stridePackageInfo.LoadedVersion)
                {
                    if (stridePackageInfo.ExpectedVersion < StrideCommandsProxy.MinimumVersion)
                    {
                        // The package version is deprecated
                        generalOutputPane.OutputStringThreadSafe($"Could not initialize Stride extension for package with version {stridePackageInfo.ExpectedVersion}. Versions earlier than {StrideCommandsProxy.MinimumVersion} are not supported. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                        generalOutputPane.Activate();
                    }
                    else if (stridePackageInfo.LoadedVersion is null)
                    {
                        // No version found
                        generalOutputPane.OutputStringThreadSafe("Could not find Stride SDK directory.");
                        generalOutputPane.Activate();

                        // Don't try to create any services
                        return;
                    }
                    else
                    {
                        // The package version was not found
                        generalOutputPane.OutputStringThreadSafe($"Could not find SDK directory for Stride version {stridePackageInfo.ExpectedVersion}. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                        generalOutputPane.Activate();
                    }
                }

                // Preinitialize the parser in a separate thread
                var thread = new System.Threading.Thread(
                    () =>
                {
                    try
                    {
                        StrideCommandsProxy.GetProxy();
                    }
                    catch (Exception ex)
                    {
                        generalOutputPane.OutputStringThreadSafe($"Error Initializing Stride Language Service: {ex.InnerException ?? ex}\r\n");
                        generalOutputPane.Activate();
                    }
                });
                thread.Start();
            }
            catch (Exception ex)
            {
                // Do not crash VS Plugin if something fails
                generalOutputPane.OutputStringThreadSafe($"Error initializing Stride command proxy: {ex}\r\n");
                generalOutputPane.Activate();

                return;
            }
        }
Пример #3
0
        private async System.Threading.Tasks.Task InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte          = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;

            var stridePackageInfo = await StrideCommandsProxy.FindStrideSdkDir(solutionPath);

            if (stridePackageInfo.LoadedVersion == null)
            {
                return;
            }
            StrideCommandsProxy.InitializeFromSolution(solutionPath, stridePackageInfo);

            // Get General Output pane (for error logging)
            var generalOutputPane = GetGeneralOutputPane();

            // Enable UIContext depending on wheter it is a Stride project. This will show or hide Stride menus.
            var isStrideSolution = stridePackageInfo.LoadedVersion != null;

            UpdateCommandVisibilityContext(isStrideSolution);

            // If a package is associated with the solution, check if the correct version was found
            if (stridePackageInfo.ExpectedVersion != null && stridePackageInfo.ExpectedVersion != stridePackageInfo.LoadedVersion)
            {
                if (stridePackageInfo.ExpectedVersion < StrideCommandsProxy.MinimumVersion)
                {
                    // The package version is deprecated
                    generalOutputPane.OutputStringThreadSafe($"Could not initialize Stride extension for package with version {stridePackageInfo.ExpectedVersion}. Versions earlier than {StrideCommandsProxy.MinimumVersion} are not supported. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                    generalOutputPane.Activate();
                }
                else if (stridePackageInfo.LoadedVersion == null)
                {
                    // No version found
                    generalOutputPane.OutputStringThreadSafe("Could not find Stride SDK directory.");
                    generalOutputPane.Activate();

                    // Don't try to create any services
                    return;
                }
                else
                {
                    // The package version was not found
                    generalOutputPane.OutputStringThreadSafe($"Could not find SDK directory for Stride version {stridePackageInfo.ExpectedVersion}. Loading latest version {stridePackageInfo.LoadedVersion} instead.\r\n");
                    generalOutputPane.Activate();
                }
            }

            // Initialize the build monitor, that will display BuildEngine results in the Build Output pane.
            buildLogPipeGenerator = new BuildLogPipeGenerator(this);

            try
            {
                // Start PackageBuildMonitorRemote in a separate app domain
                if (buildMonitorDomain != null)
                {
                    AppDomain.Unload(buildMonitorDomain);
                }

                buildMonitorDomain = StrideCommandsProxy.CreateStrideDomain();
                StrideCommandsProxy.InitializeFromSolution(solutionPath, stridePackageInfo, buildMonitorDomain);
                var remoteCommands = StrideCommandsProxy.CreateProxy(buildMonitorDomain);
                remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl);
            }
            catch (Exception e)
            {
                generalOutputPane.OutputStringThreadSafe($"Error loading Stride SDK: {e}\r\n");
                generalOutputPane.Activate();

                // Unload domain right away
                AppDomain.Unload(buildMonitorDomain);
                buildMonitorDomain = null;
            }

            // Preinitialize the parser in a separate thread
            var thread = new System.Threading.Thread(
                () =>
            {
                try
                {
                    StrideCommandsProxy.GetProxy();
                }
                catch (Exception ex)
                {
                    generalOutputPane.OutputStringThreadSafe($"Error Initializing Stride Language Service: {ex.InnerException ?? ex}\r\n");
                    generalOutputPane.Activate();
                    errorListProvider?.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            });

            thread.Start();
        }