private async void ExecuteUpgradeNuGetProjectCommandAsync(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (ShouldMEFBeInitialized()) { await InitializeMEFAsync(); } var project = EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection); if (!await NuGetProjectUpgradeUtility.IsNuGetProjectUpgradeableAsync(null, project)) { MessageHelper.ShowWarningMessage(Resources.ProjectMigrateErrorMessage, Resources.ErrorDialogBoxTitle); return; } var uniqueName = await EnvDTEProjectInfoUtility.GetCustomUniqueNameAsync(project); // Close NuGet Package Manager if it is open for this project var windowFrame = FindExistingWindowFrame(project); windowFrame?.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_SaveIfDirty); var nuGetProject = await SolutionManager.Value.GetNuGetProjectAsync(uniqueName); var uiController = ServiceLocator.GetInstance <INuGetUIFactory>().Create(nuGetProject); var settings = uiController.UIContext.UserSettingsManager.GetSettings(GetProjectSettingsKey(nuGetProject)); await uiController.UIContext.UIActionEngine.UpgradeNuGetProjectAsync(uiController, nuGetProject); uiController.UIContext.UserSettingsManager.PersistSettings(); }
private void ShowManageLibraryPackageDialog(object sender, EventArgs e) { NuGetUIThreadHelper.JoinableTaskFactory.RunAsync(async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (ShouldMEFBeInitialized()) { await InitializeMEFAsync(); } string parameterString = null; var args = e as OleMenuCmdEventArgs; if (null != args) { parameterString = args.InValue as string; } var searchText = GetSearchText(parameterString); // *** temp code var project = EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection); if (project != null && !EnvDTEProjectInfoUtility.IsUnloaded(project) && EnvDTEProjectUtility.IsSupported(project)) { var windowFrame = FindExistingWindowFrame(project); if (windowFrame == null) { windowFrame = await CreateNewWindowFrameAsync(project); } if (windowFrame != null) { Search(windowFrame, searchText); windowFrame.Show(); } } else { // show error message when no supported project is selected. var projectName = project != null ? project.Name : string.Empty; var errorMessage = string.IsNullOrEmpty(projectName) ? Resources.NoProjectSelected : string.Format(CultureInfo.CurrentCulture, Resources.DTE_ProjectUnsupported, projectName); MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle); } }).FileAndForget( TelemetryUtility.CreateFileAndForgetEventName( nameof(NuGetPackage), nameof(ShowManageLibraryPackageDialog))); }
private void ShowManageLibraryPackageDialog(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { string parameterString = null; OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs; if (null != args) { parameterString = args.InValue as string; } var searchText = GetSearchText(parameterString); // *** temp code Project project = EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection); if (project != null && !EnvDTEProjectInfoUtility.IsUnloaded(project) && EnvDTEProjectUtility.IsSupported(project)) { var windowFrame = FindExistingWindowFrame(project); if (windowFrame == null) { windowFrame = await CreateNewWindowFrameAsync(project); } if (windowFrame != null) { Search(windowFrame, searchText); windowFrame.Show(); } } else { // show error message when no supported project is selected. string projectName = project != null ? project.Name : String.Empty; string errorMessage = String.IsNullOrEmpty(projectName) ? Resources.NoProjectSelected : String.Format(CultureInfo.CurrentCulture, Resources.DTE_ProjectUnsupported, projectName); MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle); } }); }
private async Task ExecuteUpgradeNuGetProjectCommandImplAsync() { ThreadHelper.ThrowIfNotOnUIThread(); var project = EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection); var uniqueName = await EnvDTEProjectInfoUtility.GetCustomUniqueNameAsync(project); // Close NuGet Package Manager if it is open for this project var windowFrame = FindExistingWindowFrame(project); windowFrame?.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_SaveIfDirty); var nuGetProject = await SolutionManager.Value.GetNuGetProjectAsync(uniqueName); var uiController = ServiceLocator.GetInstance <INuGetUIFactory>().Create(nuGetProject); var settings = uiController.UIContext.UserSettingsManager.GetSettings(GetProjectSettingsKey(nuGetProject)); await uiController.UIContext.UIActionEngine.UpgradeNuGetProjectAsync(uiController, nuGetProject); uiController.UIContext.UserSettingsManager.PersistSettings(); }
int IVsTrackBatchRetargetingEvents.OnBatchRetargetingBegin() { NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var project = EnvDTEProjectInfoUtility.GetActiveProject(_vsMonitorSelection); if (project != null) { _platformRetargetingProject = null; var frameworkName = EnvDTEProjectInfoUtility.GetTargetFrameworkString(project); if (NETCore45.Equals(frameworkName, StringComparison.OrdinalIgnoreCase) || Windows80.Equals(frameworkName, StringComparison.OrdinalIgnoreCase)) { _platformRetargetingProject = project.UniqueName; } } }); return(VSConstants.S_OK); }
private async Task <bool> IsPackagesConfigBasedProjectAsync() { ThreadHelper.ThrowIfNotOnUIThread(); var dteProject = EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection); var uniqueName = EnvDTEProjectInfoUtility.GetUniqueName(dteProject); var nuGetProject = await SolutionManager.Value.GetNuGetProjectAsync(uniqueName); if (nuGetProject == null) { return(false); } var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject; if (msBuildNuGetProject == null || !msBuildNuGetProject.PackagesConfigNuGetProject.PackagesConfigExists()) { return(false); } return(true); }
private async Task <bool> IsProjectUpgradeableAsync() { return(await NuGetProjectUpgradeUtility.IsNuGetProjectUpgradeableAsync(null, EnvDTEProjectInfoUtility.GetActiveProject(VsMonitorSelection))); }