Esempio n. 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 XenkoCommandsProxy.FindXenkoSdkDir(solutionFile, "Xenko.GameStudio");

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

            var mainExecutable = packageInfo.SdkPaths.First(x => Path.GetFileName(x) == "Xenko.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");
            }
        }
Esempio n. 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;

            var xenkoPackageInfo = await XenkoCommandsProxy.FindXenkoSdkDir(solutionPath);

            if (xenkoPackageInfo.LoadedVersion == null)
            {
                return;
            }
            XenkoCommandsProxy.InitializeFromSolution(solutionPath, xenkoPackageInfo);

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

            // Enable UIContext depending on wheter it is a Xenko project. This will show or hide Xenko menus.
            var isXenkoSolution = xenkoPackageInfo.LoadedVersion != null;

            UpdateCommandVisibilityContext(isXenkoSolution);

            // If a package is associated with the solution, check if the correct version was found
            if (xenkoPackageInfo.ExpectedVersion != null && xenkoPackageInfo.ExpectedVersion != xenkoPackageInfo.LoadedVersion)
            {
                if (xenkoPackageInfo.ExpectedVersion < XenkoCommandsProxy.MinimumVersion)
                {
                    // The package version is deprecated
                    generalOutputPane.OutputStringThreadSafe($"Could not initialize Xenko extension for package with version {xenkoPackageInfo.ExpectedVersion}. Versions earlier than {XenkoCommandsProxy.MinimumVersion} are not supported. Loading latest version {xenkoPackageInfo.LoadedVersion} instead.\r\n");
                    generalOutputPane.Activate();
                }
                else if (xenkoPackageInfo.LoadedVersion == null)
                {
                    // No version found
                    generalOutputPane.OutputStringThreadSafe("Could not find Xenko 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 Xenko version {xenkoPackageInfo.ExpectedVersion}. Loading latest version {xenkoPackageInfo.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 = XenkoCommandsProxy.CreateXenkoDomain();
                XenkoCommandsProxy.InitializeFromSolution(solutionPath, xenkoPackageInfo, buildMonitorDomain);
                var remoteCommands = XenkoCommandsProxy.CreateProxy(buildMonitorDomain);
                remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl);
            }
            catch (Exception e)
            {
                generalOutputPane.OutputStringThreadSafe($"Error loading Xenko 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
                {
                    XenkoCommandsProxy.GetProxy();
                }
                catch (Exception ex)
                {
                    generalOutputPane.OutputStringThreadSafe($"Error Initializing Xenko Language Service: {ex.InnerException ?? ex}\r\n");
                    generalOutputPane.Activate();
                    errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            });

            thread.Start();
        }