Beispiel #1
0
        private void ShowManageLibraryPackageDialog(object sender, EventArgs e)
        {
            string parameterString   = null;
            OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;

            if (null != args)
            {
                parameterString = args.InValue as string;
            }

            if (VsMonitorSelection.GetIsSolutionNodeSelected())
            {
                ShowManageLibraryPackageDialog(null, parameterString);
            }
            else
            {
                Project project = VsMonitorSelection.GetActiveProject();
                if (project != null && !project.IsUnloaded() && project.IsSupported())
                {
                    ShowManageLibraryPackageDialog(project, parameterString);
                }
                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, VsResources.DTE_ProjectUnsupported, projectName);

                    MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle);
                }
            }
        }
Beispiel #2
0
        private void ShowManageLibraryPackageDialog(object sender, EventArgs e)
        {
            if (VsMonitorSelection.GetIsSolutionNodeSelected())
            {
                ShowManageLibraryPackageDialog(null);
            }
            else
            {
                Project project = VsMonitorSelection.GetActiveProject();
                if (project != null && !project.IsUnloaded() && project.IsSupported())
                {
                    ShowManageLibraryPackageDialog(project);
                }
                else
                {
                    // show error message when no supported project is selected.
                    string projectName = project != null ? project.Name : String.Empty;

                    string errorMessage;
                    if (String.IsNullOrEmpty(projectName))
                    {
                        errorMessage = Resources.NoProjectSelected;
                    }
                    else
                    {
                        errorMessage = String.Format(CultureInfo.CurrentCulture, VsResources.DTE_ProjectUnsupported, projectName);
                    }

                    MessageHelper.ShowWarningMessage(errorMessage, Resources.ErrorDialogBoxTitle);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets whether the current IDE has an active, supported and non-unloaded project, which is a precondition for
        /// showing the Add Library Package Reference dialog
        /// </summary>
        private async Task <bool> HasActiveLoadedSupportedProjectAsync()
        {
            var project = VsMonitorSelection.GetActiveProject();

            return(project != null && !project.IsUnloaded() &&
                   await EnvDTEProjectUtility.IsSupportedAsync(project));
        }
Beispiel #4
0
        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 = VsMonitorSelection.GetActiveProject();

                if (project != null
                    &&
                    !project.IsUnloaded()
                    &&
                    await EnvDTEProjectUtility.IsSupportedAsync(project))
                {
                    var windowFrame = await FindExistingWindowFrameAsync(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);
                }
            }).PostOnFailure(nameof(NuGetPackage), nameof(ShowManageLibraryPackageDialog));
        }
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void LinkRiaProjectCallback(object sender, EventArgs e)
        {
            Project project = VsMonitorSelection.GetActiveProject();

            if (project != null && !project.IsUnloaded() && project.IsSupported())
            {
                ShowLinkedProjectDialog(project);
            }
            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);
            }
        }
Beispiel #6
0
        private async Task <bool> IsPackagesConfigBasedProjectAsync()
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dteProject = VsMonitorSelection.GetActiveProject();

            var uniqueName   = dteProject.GetUniqueName();
            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);
        }
Beispiel #7
0
        private async Task ExecuteUpgradeNuGetProjectCommandAsync(object sender, EventArgs e)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (ShouldMEFBeInitialized())
            {
                await InitializeMEFAsync();
            }

            var project = VsMonitorSelection.GetActiveProject();

            if (!await NuGetProjectUpgradeUtility.IsNuGetProjectUpgradeableAsync(null, project))
            {
                MessageHelper.ShowWarningMessage(Resources.ProjectMigrateErrorMessage, Resources.ErrorDialogBoxTitle);
                return;
            }

            string uniqueName = await project.GetCustomUniqueNameAsync();

            // Close NuGet Package Manager if it is open for this project
            IVsWindowFrame windowFrame = await FindExistingWindowFrameAsync(project);

            windowFrame?.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_SaveIfDirty);

            IServiceBroker serviceBroker = await ServiceBrokerProvider.Value.GetAsync();

            NuGetProject nuGetProject = await SolutionManager.Value.GetNuGetProjectAsync(uniqueName);

            IProjectContextInfo projectContextInfo = await ProjectContextInfo.CreateAsync(nuGetProject, CancellationToken.None);

            using (INuGetUI uiController = await UIFactory.Value.CreateAsync(serviceBroker, projectContextInfo))
            {
                await uiController.UIContext.UIActionEngine.UpgradeNuGetProjectAsync(uiController, projectContextInfo);

                uiController.UIContext.UserSettingsManager.PersistSettings();
            }
        }