protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { if (!(GetGlobalService(typeof(DTE)) is DTE dte)) { throw new ArgumentNullException(Core.Resources.Resource.ErrorMessage_ErrorAccessingDTE); } GetUserOptions(dte); StartupTasks.Run(); ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingExtension, LogLevel.Info); AdviseSolutionEvents(); var events = dte.Events; BindSolutionEvents(events); await MenuHandler.InitializeAsync(this, dte); } catch (Exception ex) { ExceptionHandler.LogException(Logger, null, ex); throw; } }
protected override void Initialize() { base.Initialize(); _dte = GetGlobalService(typeof(DTE)) as DTE; if (_dte == null) { return; } StartupTasks.Run(_dte); ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingExtension, LogLevel.Info); AdviseSolutionEvents(); var events = _dte.Events; BindSolutionEvents(events); if (!(GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)) { return; } //Plug-in Deployer CommandID pdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginDeployerWindow); OleMenuCommand pdWindowItem = new OleMenuCommand(ShowToolWindow <PluginDeployerHost>, pdWindowCommandId); mcs.AddCommand(pdWindowItem); //Web Resource Deployer CommandID wrdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidWebResourceDeployerWindow); OleMenuCommand wrdWindowItem = new OleMenuCommand(ShowToolWindow <WebResourceDeployerHost>, wrdWindowCommandId); mcs.AddCommand(wrdWindowItem); //Solution Packager CommandID spWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidSolutionPackagerWindow); OleMenuCommand spWindowItem = new OleMenuCommand(ShowToolWindow <SolutionPackagerHost>, spWindowCommandId); mcs.AddCommand(spWindowItem); //Plug-in Trace Viewer CommandID ptvWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginTraceViewerWindow); OleMenuCommand ptvWindowItem = new OleMenuCommand(ShowToolWindow <PluginTraceViewerHost>, ptvWindowCommandId); mcs.AddCommand(ptvWindowItem); //CRM Intellisense On CommandID crmIntellisenseOnCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOn); OleMenuCommand crmIntellisenseOnItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOnCommandId) { Visible = false }; crmIntellisenseOnItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOnItem); //CRM Intellisense Off CommandID crmIntellisenseOffCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOff); OleMenuCommand crmIntellisenseOffItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOffCommandId) { Visible = false }; crmIntellisenseOffItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOffItem); //NuGet SDK Tools - Core Tools CommandID nugetSdkToolsCoreCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsCore); OleMenuCommand nugetSdkToolsCoreItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsCoreCommandId); mcs.AddCommand(nugetSdkToolsCoreItem); //NuGet SDK Tools - Plug-in Registration Tool CommandID nugetSdkToolsPrtCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsPrt); OleMenuCommand nugetSdkToolsPrtItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsPrtCommandId); mcs.AddCommand(nugetSdkToolsPrtItem); }