| | |
| | | using System.Linq;
|
| | | using System.Windows.Forms;
|
| | | using Microsoft.VisualStudio;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using Microsoft.VisualStudio.Shell.Interop;
|
| | | using Microsoft.VisualStudio.VCProjectEngine;
|
| | | using QtVsTools.Core;
|
| | | using QtVsTools.VisualStudio;
|
| | |
|
| | | namespace QtVsTools
|
| | | {
|
| | | using Core;
|
| | | using VisualStudio;
|
| | |
|
| | | static class QtMsBuildConverter
|
| | | {
|
| | | public static bool SolutionToQtMsBuild()
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | var solution = QtVsToolsPackage.Instance.Dte.Solution;
|
| | | if (solution == null)
|
| | | return ErrorMessage(string.Format(SR.GetString("ErrorConvertingProject"), ""));
|
| | |
| | | return WarningMessage(SR.GetString("NoProjectsToConvert"));
|
| | |
|
| | | foreach (EnvDTE.Project project in allProjects) {
|
| | | if ((HelperFunctions.IsQtProject(project)
|
| | | || HelperFunctions.IsQMakeProject(project))
|
| | | if ((HelperFunctions.IsVsToolsProject(project)
|
| | | || HelperFunctions.IsQtProject(project))
|
| | | && !QtProject.IsQtMsBuildEnabled(project)) {
|
| | | projects.Add(project);
|
| | | }
|
| | |
| | | MessageBoxButtons.YesNo) != DialogResult.Yes)
|
| | | return WarningMessage(SR.GetString("CancelConvertingProject"));
|
| | |
|
| | | if (projects.Where(project => project.IsDirty).Any()) {
|
| | | bool hasDirtyProjects = projects
|
| | | .Where(project =>
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | | return project.IsDirty;
|
| | | })
|
| | | .Any();
|
| | | if (hasDirtyProjects) {
|
| | | if (MessageBox.Show(
|
| | | SR.GetString("ConvertSaveConfirmation"),
|
| | | SR.GetString("ConvertTitle"),
|
| | |
| | | return WarningMessage(SR.GetString("CancelConvertingProject"));
|
| | | }
|
| | |
|
| | | var projectPaths = projects.Select(x => x.FullName).ToList();
|
| | | var projectPaths = projects
|
| | | .Select(x =>
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | | return x.FullName;
|
| | | })
|
| | | .ToList();
|
| | |
|
| | | string solutionPath = solution.FileName;
|
| | | solution.Close(true);
|
| | |
| | |
|
| | | public static bool ProjectToQtMsBuild(EnvDTE.Project project, bool askConfirmation = true)
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | if (project == null)
|
| | | return ErrorMessage(string.Format(SR.GetString("ErrorConvertingProject"), ""));
|
| | | var pathToProject = project.FullName;
|
| | |
| | | try {
|
| | | if (solution.UnloadProject(
|
| | | ref projectGuid,
|
| | | (uint)_VSProjectUnloadStatus.UNLOADSTATUS_LoadPendingIfNeeded)
|
| | | (uint)_VSProjectUnloadStatus.UNLOADSTATUS_UnloadedByUser)
|
| | | != VSConstants.S_OK)
|
| | | return ErrorMessage(
|
| | | string.Format(SR.GetString("ErrorConvertingProject"), projectName));
|