コード例 #1
0
ファイル: XenkoPackage.cs プロジェクト: joewan/xenko
        private void InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte          = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;

            XenkoCommandsProxy.InitialzeFromSolution(solutionPath);

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

            // If a package is associated with the solution, check if the correct version was found
            var xenkoPackageInfo = XenkoCommandsProxy.CurrentPackageInfo;

            if (xenkoPackageInfo.ExpectedVersion != null && xenkoPackageInfo.ExpectedVersion != xenkoPackageInfo.LoadedVersion)
            {
                if (xenkoPackageInfo.ExpectedVersion < XenkoCommandsProxy.MinimumVersion)
                {
                    // The package version is deprecated
                    generalOutputPane.OutputStringThreadSafe(string.Format("Could not initialize Xenko extension for package with version {0}. Versions earlier than {1} are not supported. Loading latest version {2} instead.\r\n", xenkoPackageInfo.ExpectedVersion, XenkoCommandsProxy.MinimumVersion, xenkoPackageInfo.LoadedVersion));
                    generalOutputPane.Activate();
                }
                else if (xenkoPackageInfo.LoadedVersion == null)
                {
                    // No version found
                    generalOutputPane.OutputStringThreadSafe("Could not find Xenko SDK directory.");
                    generalOutputPane.Activate();
                }
                else
                {
                    // The package version was not found
                    generalOutputPane.OutputStringThreadSafe(string.Format("Could not find SDK directory for Xenko version {0}. Loading latest version {1} instead.\r\n", xenkoPackageInfo.ExpectedVersion, xenkoPackageInfo.LoadedVersion));
                    generalOutputPane.Activate();
                }
            }

            // Initialize the build monitor, that will display BuildEngine results in the Build Output pane.
            // Seems like VS2015 display <Exec> output directly without waiting end of execution, so no need for all this anymore!
            // TODO: Need to find a better way to detect VS version?
            int visualStudioVersion;

            if (!int.TryParse(dte2.Version.Split('.')[0], out visualStudioVersion))
            {
                visualStudioVersion = 12;
            }

            if (visualStudioVersion < 14)
            {
                buildLogPipeGenerator = new BuildLogPipeGenerator(this);

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

                    buildMonitorDomain = XenkoCommandsProxy.CreateXenkoDomain();
                    XenkoCommandsProxy.InitialzeFromSolution(solutionPath, buildMonitorDomain);
                    var remoteCommands = XenkoCommandsProxy.CreateProxy(buildMonitorDomain);
                    remoteCommands.StartRemoteBuildLogServer(new BuildMonitorCallback(), buildLogPipeGenerator.LogPipeUrl);
                }
                catch (Exception e)
                {
                    generalOutputPane.OutputStringThreadSafe(string.Format("Error loading Xenko SDK: {0}\r\n", e));
                    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(string.Format("Error Initializing Xenko Language Service: {0}\r\n", ex.InnerException ?? ex));
                    generalOutputPane.Activate();
                    errorListProvider.Tasks.Add(new ErrorTask(ex.InnerException ?? ex));
                }
            });

            thread.Start();
        }
コード例 #2
0
ファイル: XenkoPackage.cs プロジェクト: h78hy78yhoi8j/xenko
        private void InitializeCommandProxy()
        {
            // Initialize the command proxy from the current solution's package
            var dte = (DTE)GetService(typeof(DTE));
            var solutionPath = dte.Solution.FullName;
            XenkoCommandsProxy.InitialzeFromSolution(solutionPath);

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

            // If a package is associated with the solution, check if the correct version was found
            var xenkoPackageInfo = XenkoCommandsProxy.CurrentPackageInfo;
            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.
            // Seems like VS2015 display <Exec> output directly without waiting end of execution, so no need for all this anymore!
            // TODO: Need to find a better way to detect VS version?
            int visualStudioVersion;
            if (!int.TryParse(dte2.Version.Split('.')[0], out visualStudioVersion))
                visualStudioVersion = 12;

            if (visualStudioVersion < 14)
            {
                buildLogPipeGenerator = new BuildLogPipeGenerator(this);

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

                    buildMonitorDomain = XenkoCommandsProxy.CreateXenkoDomain();
                    XenkoCommandsProxy.InitialzeFromSolution(solutionPath, 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();
        }