private async Task ExecuteAsync(object sender, EventArgs e) { Telemetry.TrackUserTask("installdialogopened"); ProjectItem item = await VsHelpers.GetSelectedItemAsync().ConfigureAwait(false); if (item != null) { string target = item.FileNames[1]; Project project = await VsHelpers.GetProjectOfSelectedItemAsync().ConfigureAwait(false); if (project != null) { string rootFolder = await project.GetRootFolderAsync().ConfigureAwait(false); string configFilePath = Path.Combine(rootFolder, Constants.ConfigFileName); IDependencies dependencies = Dependencies.FromConfigFile(configFilePath); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); UI.InstallDialog dialog = new UI.InstallDialog(dependencies, _libraryCommandService, configFilePath, target, rootFolder); var dte = (DTE)Package.GetGlobalService(typeof(SDTE)); int hwnd = dte.MainWindow.HWnd; WindowInteropHelper windowInteropHelper = new WindowInteropHelper(dialog); // Set visual studio window's handle as the owner of the dialog. // This will remove the dialog from alt-tab list and will not allow the user to switch the dialog box to the background windowInteropHelper.Owner = new IntPtr(hwnd); dialog.ShowDialog(); } } }
private async Task ExecuteAsync(object sender, EventArgs e) { Telemetry.TrackUserTask("Execute-InstallLibraryCommand"); ProjectItem item = await VsHelpers.GetSelectedItemAsync().ConfigureAwait(false); Project project = await VsHelpers.GetProjectOfSelectedItemAsync().ConfigureAwait(false); if (project != null) { string target = string.Empty; string rootFolder = await project.GetRootFolderAsync().ConfigureAwait(false); // Install command was invoked from a folder. // So the initial target location should be name of the folder from which // the command was invoked. if (item != null) { target = item.FileNames[1]; } else { // Install command was invoked from project scope. // If wwwroot exists, initial target location should be - wwwroot/lib. // Else, target location should be - lib if (Directory.Exists(Path.Combine(rootFolder, "wwwroot"))) { target = Path.Combine(rootFolder, "wwwroot", "lib") + Path.DirectorySeparatorChar; } else { target = Path.Combine(rootFolder, "lib") + Path.DirectorySeparatorChar; } } string configFilePath = Path.Combine(rootFolder, Constants.ConfigFileName); IDependencies dependencies = Dependencies.FromConfigFile(configFilePath); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); UI.InstallDialog dialog = new UI.InstallDialog(dependencies, _libraryCommandService, configFilePath, target, rootFolder); var dte = (DTE)Package.GetGlobalService(typeof(SDTE)); int hwnd = dte.MainWindow.HWnd; WindowInteropHelper windowInteropHelper = new WindowInteropHelper(dialog); // Set visual studio window's handle as the owner of the dialog. // This will remove the dialog from alt-tab list and will not allow the user to switch the dialog box to the background windowInteropHelper.Owner = new IntPtr(hwnd); dialog.ShowDialog(); Telemetry.TrackUserTask("Open-InstallDialog"); } }
private void ExecuteAsync(object sender, EventArgs e) { Telemetry.TrackUserTask("installdialogopened"); ProjectItem item = VsHelpers.DTE.SelectedItems.Item(1).ProjectItem; string target = item.FileNames[1]; Project project = VsHelpers.DTE.SelectedItems.Item(1).ProjectItem.ContainingProject; string rootFolder = project.GetRootFolder(); string configFilePath = Path.Combine(rootFolder, Constants.ConfigFileName); IDependencies dependencies = Dependencies.FromConfigFile(configFilePath); UI.InstallDialog dialog = new UI.InstallDialog(dependencies, configFilePath, target); dialog.ShowDialog(); }
private async Task ExecuteAsync(object sender, EventArgs e) { Telemetry.TrackUserTask("Execute-InstallLibraryCommand"); ProjectItem item = await VsHelpers.GetSelectedItemAsync().ConfigureAwait(false); Project project = await VsHelpers.GetProjectOfSelectedItemAsync().ConfigureAwait(false); if (project != null) { string rootFolder = await project.GetRootFolderAsync().ConfigureAwait(false); string configFilePath = Path.Combine(rootFolder, Constants.ConfigFileName); IDependencies dependencies = Dependencies.FromConfigFile(configFilePath); Manifest manifest = await GetManifestAsync(configFilePath, dependencies).ConfigureAwait(false); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // If the manifest contains errors, we will not invoke the "Add Client-Side libraries" dialog // Instead we will display a message box indicating the syntax errors in manifest file. if (manifest == null) { IVsUIShell shell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; int result; shell.ShowMessageBox(dwCompRole: 0, rclsidComp: Guid.Empty, pszTitle: null, pszText: PredefinedErrors.ManifestMalformed().Message, pszHelpFile: null, dwHelpContextID: 0, msgbtn: OLEMSGBUTTON.OLEMSGBUTTON_OK, msgdefbtn: OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, msgicon: OLEMSGICON.OLEMSGICON_WARNING, fSysAlert: 0, pnResult: out result); return; } string target = string.Empty; // Install command was invoked from a folder. // So the initial target location should be name of the folder from which // the command was invoked. if (item != null) { target = item.FileNames[1]; } else { // Install command was invoked from project scope. // If wwwroot exists, initial target location should be - wwwroot/lib. // Else, target location should be - lib if (Directory.Exists(Path.Combine(rootFolder, "wwwroot"))) { target = Path.Combine(rootFolder, "wwwroot", "lib") + Path.DirectorySeparatorChar; } else { target = Path.Combine(rootFolder, "lib") + Path.DirectorySeparatorChar; } } UI.InstallDialog dialog = new UI.InstallDialog(dependencies, _libraryCommandService, configFilePath, target, rootFolder, project); var dte = (DTE)Package.GetGlobalService(typeof(SDTE)); int hwnd = dte.MainWindow.HWnd; WindowInteropHelper windowInteropHelper = new WindowInteropHelper(dialog); // Set visual studio window's handle as the owner of the dialog. // This will remove the dialog from alt-tab list and will not allow the user to switch the dialog box to the background windowInteropHelper.Owner = new IntPtr(hwnd); dialog.ShowDialog(); Telemetry.TrackUserTask("Open-InstallDialog"); } }