Пример #1
0
        public static bool Build(Project pProj, OutputWindowPane pPane, string pTarget, NameValueCollection pParams)
        {
            Microsoft.Build.BuildEngine.Engine buildEngine = new Microsoft.Build.BuildEngine.Engine();
              BuildExecutor executor = new BuildExecutor(pPane);

              RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework", false);
              if (key == null) {
            throw new Exception("Failed to determine .NET Framework install root - no .NETFramework key");
              }
              string installRoot = key.GetValue("InstallRoot") as string;
              if (installRoot == null) {
            throw new Exception("Failed to determine .NET Framework install root - no InstallRoot value");
              }
              key.Close();

              buildEngine.BinPath = Path.Combine(installRoot, string.Format("v{0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build));
              buildEngine.RegisterLogger(executor);

              executor.Verbosity = LoggerVerbosity.Normal;

              BuildPropertyGroup properties = new BuildPropertyGroup();
              foreach (string propKey in pParams.Keys) {
            string val = pParams[propKey];

            properties.SetProperty(propKey, val, true);
              }

              return buildEngine.BuildProjectFile(pProj.FileName, new string[]{pTarget}, properties);
        }
        public void ProjectFinishedGenerating(EnvDTE.Project project)
        {
            _project = project;
            var p = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(_project.FullName).ElementAt(0);
            String artifactoryConfLocation = Path.Combine(project.FullName, "..\\.artifactory");
            System.IO.Directory.CreateDirectory(Path.Combine(_solutionDir, ".artifactory"));
            Project folder = ((Solution2)_dte.Solution).AddSolutionFolder(".artifactory");

            File.Copy(Path.Combine(artifactoryConfLocation, @"Artifactory.build"), Path.Combine(_solutionDir, @".artifactory\Artifactory.build"));
            folder.ProjectItems.AddFromFile(Path.Combine(_solutionDir, @".artifactory\Artifactory.build"));

            File.Copy(Path.Combine(artifactoryConfLocation, "Deploy.targets"), Path.Combine(_solutionDir, @".artifactory\Deploy.targets"));
            folder.ProjectItems.AddFromFile(Path.Combine(_solutionDir, @".artifactory\Deploy.targets"));

            File.Copy(Path.Combine(artifactoryConfLocation, "Resolve.targets"), Path.Combine(_solutionDir, @".artifactory\Resolve.targets"));
            folder.ProjectItems.AddFromFile(Path.Combine(_solutionDir, @".artifactory\Resolve.targets"));

            Directory.Delete(artifactoryConfLocation, true);

            foreach(ProjectItem pi in project.ProjectItems)
            {
                if(pi.Name.Equals(".artifactory"))
                {
                    pi.Delete();
                }
            }
        }
Пример #3
0
 public static bool IsObjectModelSupported(Project value)
 {
   Contract.Requires(value != null);
   return
       value.Kind == prjKindCSharpProject ||
       value.Kind == prjKindVBProject;
 }
Пример #4
0
        private void removeProject(Project project)
        {

            var list = (List<Project>)gridControl1.DataSource;
            list.Remove(project);
            gridControl1.RefreshDataSource();

        }
Пример #5
0
 public Compiler(EnvDTE.Project proj, string file, IVsOutputWindowPane pane)
 {
     taskTimer = new TaskTimer("Compile " + file);
     project = proj;
     clTool = new VCCompilerHelper(project);
     filename = file;
     buildPane = pane;
 }
        public VisualStudioProject(EnvDTE.Project nativeProject,
			SolutionConfigurations solutionConfigurations)
        {
            this.nativeProject = nativeProject;

            Name = nativeProject.Name;
            SetAvailableConfigurations(solutionConfigurations);
        }
Пример #7
0
 private static Node GetSolutionFolderNode(Project folder)
 {
     var node = new Node(folder.Name);
     var childs = folder.ProjectItems.Cast<ProjectItem>().Where(x => x.SubProject != null)
         .Select(x => GetProjectItemNode(x.SubProject)).ToList();
     node.AddChilds(childs);
     return node;
 }
Пример #8
0
 private QtProject(EnvDTE.Project project)
 {
     if (project == null)
         throw new Qt4VSException(SR.GetString("QtProject_CannotConstructWithoutValidProject"));
     envPro = project;
     dte = envPro.DTE;
     vcPro = envPro.Object as VCProject;
 }
        public VisualStudioInstance(SolutionFile solution) {
            _solution = solution;
            _app = new VisualStudioApp();
            Project = _app.OpenProject(solution.Filename);

            ThreadHelper.Generic.Invoke(Keyboard.Reset);
            _solutionExplorer = _app.OpenSolutionExplorer();
            SelectSolutionNode();
        }
Пример #10
0
 public BuildProfiler(EnvDTE.Project proj, int stackMaxSize, IVsOutputWindowPane bpane, IVsOutputWindowPane ppane, Action onFinished, string singleFile = null)
 {
     if (singleFile != null)
         onlyFile = singleFile;
     project = proj;
     clTool = new VCCompilerHelper(project);
     profilePane = ppane;
     buildPane = bpane;
     profiler = new ActiveObject(stackMaxSize);
     signalFinished = onFinished;
     Initialize();
     profiler.Signal();
 }
Пример #11
0
    public static bool TryGetHierarchyForProject(
        IServiceProvider serviceProvider,
        Project project,
        out IVsHierarchy hierarchy)
    {
      Contract.Requires(serviceProvider != null);
      Contract.Requires(project != null);

      string uniqueName;
      try
      {
        uniqueName = project.UniqueName;
      }
      catch (Exception ex)
      {
        ContractsVsPackage.SwallowedException(ex);
        uniqueName = null;
      }

      if (uniqueName == null)
      {
        hierarchy = null;
        return false;
      }
      else
      {
        try
        {
          hierarchy = HierarchyFromUniqueName(
              serviceProvider,
              project.UniqueName);

          if (hierarchy == null)
          {
            return false;
          }

          return true;
        }
        catch (Exception ex)
        {
          ContractsVsPackage.SwallowedException(ex);
          hierarchy = null;
          return false;
        }
      }
    }
Пример #12
0
        public TemplateProfiler(EnvDTE.Project proj, string file, int stackMaxSize, IVsOutputWindowPane pane, Action onFinished)
        {
            project = proj;
            clTool = new VCCompilerHelper(project);
            filename = file;
            profilePane = pane;
            try
            {
                profiler = new ActiveObject(stackMaxSize);
            }
            catch (System.OutOfMemoryException /*ex*/)
            {
                string message = "The Tools->Meta->Options page specifies a " + stackMaxSize + " byte stack reserve size. This exceeds available memory."
                    + Environment.NewLine + "Please try again with a lower stack size reserve value.";
                string caption = "Stack Reserve Size Too Large...";
                MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                cancelProfile = true;
                return;
            }

            signalFinished = onFinished;
            Initialize();
            profiler.Signal();
        }
Пример #13
0
 bool IsWeb(Project startUpProject)
 {
     return(startUpProject.ProjectItems.OfType <ProjectItem>().Any(item => item.Name.ToLower() == "web.config"));
 }
Пример #14
0
 public static EnvDTE.ProjectItem FindProjectItem(EnvDTE.Project project, string file)
 {
     return(FindProjectItem(project.ProjectItems, file));
 }
Пример #15
0
 public static bool TryGetFullPath(this EnvDTE.Project project, out string fullPath)
 {
     fullPath = project.Properties.Item("FullPath").Value as string;
     return(fullPath != null);
 }
Пример #16
0
 public static bool ProjectExists(Project project) {
     IEnumerable<string> allProjectPaths =
         Options.Storage.GetGroupedKeys(Options.ProjectPaths).SelectMany(
             s => Options.Storage.ReadStrings(Options.ProjectPaths, s));
     return allProjectPaths.Where(MatchProjectName(project)).FirstOrDefault() != null;
 }
Пример #17
0
        public void CreatePlatform(string oldPlatform, string newPlatform,
                                   VersionInformation viOld, VersionInformation viNew, ref bool newProjectCreated)
        {
            try
            {
                ConfigurationManager cfgMgr = envPro.ConfigurationManager;
                cfgMgr.AddPlatform(newPlatform, oldPlatform, true);
                vcPro.AddPlatform(newPlatform);
                newProjectCreated = false;
            }
            catch
            {
                // That stupid ConfigurationManager can't handle platform names
                // containing dots (e.g. "Windows Mobile 5.0 Pocket PC SDK (ARMV4I)")
                // So we have to do it the nasty way...
                string projectFileName = envPro.FullName;
                envPro.Save(null);
                dte.Solution.Remove(envPro);
                AddPlatformToVCProj(projectFileName, oldPlatform, newPlatform);
                envPro = dte.Solution.AddFromFile(projectFileName, false);
                vcPro = (VCProject)envPro.Object;
                newProjectCreated = true;
            }

            // update the platform settings
            foreach (VCConfiguration config in (IVCCollection)vcPro.Configurations)
            {
                VCPlatform vcplatform = (VCPlatform)config.Platform;
                if (vcplatform.Name == newPlatform)
                {
                    if (viOld != null)
                        RemovePlatformDependencies(config, viOld);
                    SetupConfiguration(config, viNew);
                }
            }

            SelectSolutionPlatform(newPlatform);
        }
Пример #18
0
 private bool FileExistsInProject(string path)
 {
     return(Project.GetProjectItem(path) != null);
 }
Пример #19
0
 /// <summary>
 /// Enumerates all files in the project traversing into sub folders
 /// and items that have child elements.
 /// </summary>
 public IEnumerable <string> GetProjectFiles(EnvDTE.Project project) => EnumerateProjectFiles(project?.ProjectItems);
Пример #20
0
 void IWizard.ProjectFinishedGenerating(EnvDTE.Project project)
 {
     // Do nothing
 }
Пример #21
0
        public static bool IsProjectExecutable(EnvDTE.Project project)
        {
            var buildProjects = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(project.FileName);

            return(buildProjects.Any(x => x.GetPropertyValue("SiliconStudioProjectType") == "Executable"));
        }
Пример #22
0
        /// <summary>实现 IDTCommandTarget 接口的 Exec 方法。此方法在调用该命令时调用。</summary>
        /// <param term='commandName'>要执行的命令的名称。</param>
        /// <param term='executeOption'>描述该命令应如何运行。</param>
        /// <param term='varIn'>从调用方传递到命令处理程序的参数。</param>
        /// <param term='varOut'>从命令处理程序传递到调用方的参数。</param>
        /// <param term='handled'>通知调用方此命令是否已被处理。</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
        {
            handled = false;
            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                if (commandName == "ThkDevEnc.Connect.ProeAttach" || commandName == "ThkDevEnc.Connect.CatiaAttach")
                {
                    handled = true;
                    bool bCatia = false;
                    if (commandName == "ThkDevEnc.Connect.CatiaAttach")
                    {
                        bCatia = true;
                    }

                    ArrayList procList = new ArrayList();

                    foreach (Process proc in _applicationObject.Debugger.LocalProcesses)
                    {
                        string strname = proc.Name;
                        strname = strname.ToLower();
                        if (bCatia)
                        {
                            if (strname.Contains("cnext.exe"))
                            {
                                procList.Add(proc);
                            }
                        }
                        else
                        {
                            if (strname.Contains("xtop.exe"))
                            {
                                procList.Add(proc);
                            }
                        }
                    }

                    int iNum = procList.Count;

                    if (iNum > 0)
                    {
                        if (iNum > 1)
                        {
                            SelForm sel = new SelForm();
                            sel.DebugCatia = bCatia;

                            if (sel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                AttachProcess(sel.PROCESSES);
                            }
                        }
                        else
                        {
                            //Engine[] eng = new Engine[2];
                            //Debugger3 dbg = (Debugger3)_applicationObject.Debugger;
                            //Transport tras = dbg.Transports.Item("default");
                            //eng[0] = tras.Engines.Item("native");
                            //eng[1] = tras.Engines.Item("Managed");

                            ((Process)procList[0]).Attach();
                        }
                    }
                    else
                    {
                        if (bCatia)
                        {
                            MessageBox.Show("当前没有运行Catia程序");
                        }
                        else
                        {
                            MessageBox.Show("当前没有运行PROE/CREO程序");
                        }
                    }

                    return;
                }
                if (commandName == "ThkDevEnc.Connect.ProUnlock")
                {
                    handled = true;

                    ProUnLock pu = new ProUnLock();
                    pu.m_envcfgs = m_envcfgs;
                    pu.ShowDialog();
                    return;
                }
                if (commandName == "ThkDevEnc.Connect.CopyFile")
                {
                    handled = true;

                    LP_SC.FileCopyForm fm = new LP_SC.FileCopyForm(_applicationObject);
                    fm.ResetTree();
                    fm.ShowDialog();
                    return;
                }
                if (commandName == "ThkDevEnc.Connect.DevEnvCfg")
                {
                    handled = true;

                    EncSet sel = new EncSet();
                    if (DialogResult.OK == sel.ShowDialog())
                    {
                        m_envcfgs.LoadConfig();
                        EnvDTE.Projects curprj = _applicationObject.DTE.Solution.Projects;
                        if (curprj == null || curprj.Count == 0)
                        {
                            return;
                        }
                        for (int i = 0; i < curprj.Count; i++)
                        {
                            EnvDTE.Project prj = curprj.Item(i);
                        }
                    }

                    return;
                }
                if (commandName == "ThkDevEnc.Connect.VCSet")
                {
                    handled = true;

                    VcInfoSet sel = new VcInfoSet();
                    sel.ShowDialog();

                    return;
                }
                if (commandName == "ThkDevEnc.Connect.UnAttach")
                {
                    handled = true;

                    if (_applicationObject.Debugger.CurrentMode == dbgDebugMode.dbgDesignMode)
                    {
                        return;
                    }
                    _applicationObject.Debugger.DetachAll();

                    //try
                    //{
                    //    Project prj;
                    //    Configuration config;
                    //    OutputGroups outPGs;
                    //    Properties props;
                    //    if (_applicationObject.Solution.Projects.Count > 0)
                    //    {
                    //        prj = _applicationObject.Solution.Projects.Item(1);
                    //        config = prj.ConfigurationManager.ActiveConfiguration;
                    //        // Return a collection of OutputGroup objects that contain
                    //        // the names of files that are outputs for the project.
                    //        outPGs = config.OutputGroups;
                    //        MessageBox.Show(outPGs.Count.ToString());
                    //        // Returns the project for the config.
                    //        MessageBox.Show(((Project)config.Owner).Name);
                    //        // Returning the platform name for the Configuration.
                    //        MessageBox.Show(config.PlatformName);
                    //        // Returning all properties for Configuration object.
                    //        props = config.Properties;
                    //        string p = "";
                    //        foreach (Property prop in props)
                    //        {
                    //            p = p + prop.Name + "<:>"+prop.Value+"\n";
                    //        }
                    //        MessageBox.Show(p);
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    MessageBox.Show(ex.Message);
                    //}
                    return;
                }
            }
        }
Пример #23
0
        public override void Exec()
        {
            if (MessageBox.Show("Are you sure you want to change any hardcoded paths pointing to files in the packages directory to relative paths?\r\n\r\nThis command impacts configurations and connection managers.", "BIDS Helper - Fix Relative Paths", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }

            try
            {
                this.ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationFind);
                this.ApplicationObject.StatusBar.Text = "Fixing relative paths...";

                EnvDTE.Project proj = GetSelectedProjectReference();
                Microsoft.DataWarehouse.Interfaces.IConfigurationSettings settings = (Microsoft.DataWarehouse.Interfaces.IConfigurationSettings)((System.IServiceProvider)proj).GetService(typeof(Microsoft.DataWarehouse.Interfaces.IConfigurationSettings));
                DataWarehouseProjectManager projectManager = (DataWarehouseProjectManager)settings.GetType().InvokeMember("ProjectManager", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy, null, settings, null);

                this.ApplicationObject.ToolWindows.OutputWindow.Parent.SetFocus();
                IOutputWindowFactory service      = ((System.IServiceProvider)proj).GetService(typeof(IOutputWindowFactory)) as IOutputWindowFactory;
                IOutputWindow        outputWindow = service.GetStandardOutputWindow(StandardOutputWindow.Deploy);
                outputWindow.Activate();
                outputWindow.Clear();
                outputWindow.ReportStatusMessage("BIDS Helper is fixing relative paths in all open packages...\r\n");

                bool          bFoundOpenPackage = false;
                StringBuilder sb = new StringBuilder();
                string        sPackageDirectory = string.Empty;
                foreach (ProjectItem item in proj.ProjectItems)
                {
                    try
                    {
                        if (!item.get_IsOpen(BIDSViewKinds.Designer))
                        {
                            continue;
                        }
                    }
                    catch
                    {
                        continue;
                    }
                    if (!bFoundOpenPackage)
                    {
                        bFoundOpenPackage = true;

                        sPackageDirectory = System.IO.Path.GetDirectoryName(item.get_FileNames(0));
                        outputWindow.ReportStatusMessage("The current working directory is:");
                        outputWindow.ReportStatusMessage(System.IO.Directory.GetCurrentDirectory());
                        outputWindow.ReportStatusMessage(string.Empty);
                        outputWindow.ReportStatusMessage("The directory for the packages is:");
                        outputWindow.ReportStatusMessage(sPackageDirectory);
                        outputWindow.ReportStatusMessage(string.Empty);

                        if (string.Compare(sPackageDirectory, System.IO.Directory.GetCurrentDirectory(), true) != 0)
                        {
                            outputWindow.ReportStatusMessage("PROBLEM:");
                            outputWindow.ReportStatusMessage("Since the packages are not in the current working directory, no changes to configurations will be made. Please start Visual Studio by double clicking on the .sln file for the project, and make sure the .sln file is in the same directory as the packages.");
                            return;
                        }
                    }

                    Window w = item.Open(BIDSViewKinds.Designer); //opens the designer
                    w.Activate();

                    IDesignerHost designer = w.Object as IDesignerHost;
                    if (designer == null)
                    {
                        continue;
                    }
                    EditorWindow win     = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                    Package      package = win.PropertiesLinkComponent as Package;
                    if (package == null)
                    {
                        continue;
                    }

                    outputWindow.ReportStatusMessage("Package " + item.Name);

                    #if DENALI || SQL2014
                    Cud.Transaction trans = Cud.BeginTransaction(package);
                    #endif

                    bool bChanged = false;
                    foreach (Microsoft.SqlServer.Dts.Runtime.Configuration config in package.Configurations)
                    {
                        if (config.ConfigurationType == DTSConfigurationType.ConfigFile)
                        {
                            if (string.Compare(System.IO.Path.GetDirectoryName(config.ConfigurationString), System.IO.Directory.GetCurrentDirectory(), true) == 0)
                            {
                                config.ConfigurationString = System.IO.Path.GetFileName(config.ConfigurationString);
                                outputWindow.ReportStatusMessage("  Configuration " + config.Name + " changed to relative path");
                                bChanged = true;

                                #if DENALI || SQL2014
                                trans.ChangeProperty(config, "ConfigurationString");
                                #endif
                            }
                        }
                    }
                    foreach (ConnectionManager conn in package.Connections)
                    {
                        if (string.IsNullOrEmpty(conn.GetExpression("ConnectionString")) && string.Compare(System.IO.Path.GetDirectoryName(conn.ConnectionString), System.IO.Directory.GetCurrentDirectory(), true) == 0)
                        {
                            conn.ConnectionString = System.IO.Path.GetFileName(conn.ConnectionString);
                            outputWindow.ReportStatusMessage("  Connection " + conn.Name + " changed to relative path");
                            bChanged = true;

                            #if DENALI || SQL2014
                            trans.ChangeProperty(conn, "ConnectionString");
                            #endif
                        }
                    }
                    if (bChanged)
                    {
                        SSISHelpers.MarkPackageDirty(package);
                    }
                    else
                    {
                        outputWindow.ReportStatusMessage("  No changes");
                    }
                }

                if (!bFoundOpenPackage)
                {
                    outputWindow.ReportStatusMessage("PROBLEM:");
                    outputWindow.ReportStatusMessage("No packages in this project were open.");
                    return;
                }

                outputWindow.Activate();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
            finally
            {
                this.ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationFind);
                this.ApplicationObject.StatusBar.Text = string.Empty;
            }
        }
Пример #24
0
 bool IsWeb(Project startUpProject) {
     return startUpProject.ProjectItems.OfType<ProjectItem>().Where(item => item.Name.ToLower() == "web.config").Count() > 0;
 }
Пример #25
0
		private void GetSelectedItemPath()
		{
			try
			{
				var items = (Array)_dte.ToolWindows.SolutionExplorer.SelectedItems;
				foreach (UIHierarchyItem selItem in items)
				{
					var item = selItem.Object as ProjectItem;
					if (item != null && item.Properties != null)
					{
						_project = item.ContainingProject;
						_vsWebsite = _project.Kind == "{E24C65DC-7377-472b-9ABA-BC803B73C61A}";
						_fullPath = item.Properties.Item("FullPath").Value.ToString();
						_fileName = item.Properties.Item("FileName").Value.ToString();
					}
				}
			}
			catch { /* Something weird is happening. Ignore this and return null */}
		}
 internal PythonProjectCodeModel(DteProject project)
 {
     this.projectItem = project;
 }
Пример #27
0
 private int addProject(Project project)
 {
     return ((IList)gridControl1.DataSource).Add(project);
 }
Пример #28
0
        public static string GetProjectPlatform(EnvDTE.Project project)
        {
            var buildProjects = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(project.FileName);

            return(buildProjects.Select(x => x.GetPropertyValue("SiliconStudioPlatform")).FirstOrDefault(x => !string.IsNullOrEmpty(x)));
        }
Пример #29
0
 // ReSharper restore RedundantOverridenMember
 #endregion
 private ProjectItem getModelItem(Project project)
 {
     return project.ProjectItems.Cast<ProjectItem>().Where(item => item.Name.EndsWith(".xafml")).FirstOrDefault();
 }
Пример #30
0
        private static UnconfiguredProject GetUnconfiguredProject(EnvDTE.Project project)
        {
            var context = project as IVsBrowseObjectContext;

            return(context?.UnconfiguredProject);
        }
Пример #31
0
 public override IEnumerable <string> GetFiles(string path, string filter)
 {
     // Get all physical files
     return(from p in Project.GetChildItems(path, filter, VsConstants.VsProjectItemKindPhysicalFile)
            select p.Name);
 }
Пример #32
0
 public void BeforeOpeningFile(ProjectItem projectItem)
 {
     EnvDTE.Project project = projectItem.ContainingProject;
 }
Пример #33
0
        private static async Task CleanIntermediateAsset(DTE2 dte, Project project)
        {
            if (project.FileName == null || Path.GetExtension(project.FileName) != ".csproj")
                return;

            // Find current project active configuration
            var configManager = project.ConfigurationManager;
            var activeConfig = configManager.ActiveConfiguration;

            // Get global parameters for Configuration and Platform
            var globalProperties = new Dictionary<string, string>();
            globalProperties["Configuration"] = activeConfig.ConfigurationName;
            globalProperties["Platform"] = activeConfig.PlatformName == "Any CPU" ? "AnyCPU" : activeConfig.PlatformName;

            // Check if project has a SiliconStudioCurrentPackagePath
            var projectInstance = new ProjectInstance(project.FileName, globalProperties, null);
            var packagePathProperty = projectInstance.Properties.FirstOrDefault(x => x.Name == "SiliconStudioCurrentPackagePath");
            if (packagePathProperty == null)
                return;

            // Prepare build request
            var request = new BuildRequestData(project.FileName, globalProperties, null, new[] { "SiliconStudioCleanAsset" }, null);
            var pc = new Microsoft.Build.Evaluation.ProjectCollection();
            var buildParameters = new BuildParameters(pc);
            var buildLogger = new IDEBuildLogger(GetOutputPane(), new TaskProvider(ServiceProvider), VsHelper.ToHierarchy(project));
            buildParameters.Loggers = new[] { buildLogger };

            // Trigger async build
            buildLogger.OutputWindowPane.OutputStringThreadSafe(string.Format("Cleaning assets for project {0}...\r\n", project.Name));
            BuildManager.DefaultBuildManager.BeginBuild(buildParameters);
            var submission = BuildManager.DefaultBuildManager.PendBuildRequest(request);
            BuildResult buildResult = await submission.ExecuteAsync();
            BuildManager.DefaultBuildManager.EndBuild();
            buildLogger.OutputWindowPane.OutputStringThreadSafe("Done\r\n");
        }
Пример #34
0
 public void ProjectFinishedGenerating(EnvDTE.Project project)
 {
 }
Пример #35
0
 bool IsWeb(Project startUpProject) {
     return startUpProject.ProjectItems.OfType<ProjectItem>().Any(item => item.Name.ToLower() == "web.config");
 }
Пример #36
0
 /// <summary>
 /// Implements <see cref="IWizard.ProjectFinishedGenerating"/>
 /// </summary>
 protected void ProjectFinishedGenerating(EnvDTE.Project project)
 {
 }
Пример #37
0
        /// <summary>
        /// Adds the projects.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="path">The path.</param>
        /// <param name="projectsInfos">The projects infos.</param>
        /// <param name="referenceFirstProject">if set to <c>true</c> [reference first project].</param>
        /// <param name="includeLibFolderInProjects">if set to <c>true</c> [include lib folder in projects].</param>
        /// <returns>The messages.</returns>
        public static IEnumerable <string> AddProjects(
            this Solution2 instance,
            string path,
            IEnumerable <ProjectTemplateInfo> projectsInfos,
            bool referenceFirstProject,
            bool includeLibFolderInProjects)
        {
            string message = string.Format(
                "SolutionExtensions::AddProjects project count={0} path={1}", projectsInfos.Count(), path);

            TraceService.WriteLine(message);

            Project firstProject = null;

            Solution solution = instance as Solution;

            List <string> messages = new List <string>();

            foreach (ProjectTemplateInfo projectInfo in projectsInfos)
            {
                try
                {
                    //// Project may actually already exist - if so just skip it!

                    string projectPath = string.Format(@"{0}\{1}\", path, projectInfo.Name);

                    if (Directory.Exists(projectPath) == false)
                    {
                        try
                        {
                            string template = instance.GetProjectTemplate(projectInfo.TemplateName);
                            solution.AddProjectToSolution(projectPath, template, projectInfo.Name);

                            //// remove the lib folder if that's what the developer wants to happen.
                            //// if the develop has selected use nuget then also remove the project
                            if (includeLibFolderInProjects == false ||
                                projectInfo.UseNuget)
                            {
                                Project project = instance.GetProject(projectInfo.Name);

                                if (project != null)
                                {
                                    ProjectItem projectItem = project.RemoveFolder("Lib");

                                    //// remove the local files if we are going to use nuget.
                                    if (projectInfo.UseNuget)
                                    {
                                        projectItem.DeleteFolder();
                                    }
                                }
                            }

                            if (projectInfo.UseNuget)
                            {
                                //// now execute Nuget command.

                                DTE2 dte2 = instance.DTE as DTE2;

                                dte2.ExecuteNugetCommand(projectInfo.NugetCommand);
                            }

                            messages.Add(projectInfo.Name + " project successfully added.");
                        }
                        catch (Exception exception)
                        {
                            string exceptionMessage = string.Format(
                                "Unsupported project {0} not added to the solution.", projectInfo.Name);

                            TraceService.WriteError(exceptionMessage + " exception=" + exception.Message);

                            messages.Add(exceptionMessage);
                        }
                    }

                    if (referenceFirstProject)
                    {
                        Project project = instance.GetProject(projectInfo.Name);

                        if (project != null)
                        {
                            if (firstProject == null)
                            {
                                firstProject = project;
                            }
                            else
                            {
                                try
                                {
                                    project.AddProjectReference(firstProject);
                                }
                                catch (Exception exception)
                                {
                                    string exceptionMessage = "SolutionExtensions::AddProjects Error=" + exception.Message;

                                    TraceService.WriteError(exceptionMessage);
                                    messages.Add(exceptionMessage);
                                }
                            }
                        }
                    }
                }
                catch (FileNotFoundException exception)
                {
                    //// if template not found just miss it out for now.
                    message = string.Format(
                        "Template not found for {0} Error {1}", projectInfo.TemplateName, exception.Message);

                    TraceService.WriteError(message);
                    messages.Add(message);
                }
            }

            return(messages);
        }
Пример #38
0
 void IWizard.ProjectFinishedGenerating(EnvDTE.Project project)
 {
     ProjectFinishedGenerating(project);
 }
Пример #39
0
 public static ProjectItem FindItem(this EnvDTE.Project project, string itemName, StringComparer comparer)
 {
     return(project.ProjectItems.FindItem(itemName, comparer));
 }
Пример #40
0
 protected virtual void AddGacReference(string name)
 {
     Project.GetReferences().Add(name);
 }
Пример #41
0
        private static ICollection <VsHierarchyItem> GetExpandedProjectHierarchyItems(EnvDTE.Project project)
        {
            VsHierarchyItem      projectHierarchyItem   = GetHierarchyItemForProject(project);
            IVsUIHierarchyWindow solutionExplorerWindow = GetSolutionExplorerHierarchyWindow();

            if (solutionExplorerWindow == null)
            {
                // If the solution explorer is collapsed since opening VS, this value is null. In such a case, simply exit early.
                return(new VsHierarchyItem[0]);
            }

            var expandedItems = new List <VsHierarchyItem>();

            // processCallback return values:
            //     0   continue,
            //     1   don't recurse into,
            //    -1   stop
            projectHierarchyItem.WalkDepthFirst(
                fVisible: true,
                processCallback:
                (VsHierarchyItem vsItem, object callerObject, out object newCallerObject) =>
            {
                newCallerObject = null;
                if (IsVsHierarchyItemExpanded(vsItem, solutionExplorerWindow))
                {
                    expandedItems.Add(vsItem);
                }
                return(0);
            },
                callerObject: null);

            return(expandedItems);
        }
Пример #42
0
        public virtual void AddReference(string referencePath, Stream stream)
        {
            string name = Path.GetFileNameWithoutExtension(referencePath);

            try
            {
                // Get the full path to the reference
                string fullPath = PathUtility.GetAbsolutePath(Root, referencePath);

                string assemblyPath = fullPath;
                bool   usedTempFile = false;

                // There is a bug in Visual Studio whereby if the fullPath contains a comma,
                // then calling Project.Object.References.Add() on it will throw a COM exception.
                // To work around it, we copy the assembly into temp folder and add reference to the copied assembly
                if (fullPath.Contains(","))
                {
                    string tempFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(fullPath));
                    File.Copy(fullPath, tempFile, true);
                    assemblyPath = tempFile;
                    usedTempFile = true;
                }

                // Add a reference to the project
                dynamic reference = Project.GetReferences().Add(assemblyPath);

                // if we copied the assembly to temp folder earlier, delete it now since we no longer need it.
                if (usedTempFile)
                {
                    try
                    {
                        File.Delete(assemblyPath);
                    }
                    catch
                    {
                        // don't care if we fail to delete a temp file
                    }
                }

                if (reference != null)
                {
                    // This happens if the assembly appears in any of the search paths that VS uses to locate assembly references.
                    // Most commonly, it happens if this assembly is in the GAC or in the output path.
                    if (reference.Path != null && !reference.Path.Equals(fullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        // Get the msbuild project for this project
                        MsBuildProject buildProject = Project.AsMSBuildProject();

                        if (buildProject != null)
                        {
                            // Get the assembly name of the reference we are trying to add
                            AssemblyName assemblyName = AssemblyName.GetAssemblyName(fullPath);

                            // Try to find the item for the assembly name
                            MsBuildProjectItem item = (from assemblyReferenceNode in buildProject.GetAssemblyReferences()
                                                       where AssemblyNamesMatch(assemblyName, assemblyReferenceNode.Item2)
                                                       select assemblyReferenceNode.Item1).FirstOrDefault();

                            if (item != null)
                            {
                                // Add the <HintPath> metadata item as a relative path
                                item.SetMetadataValue("HintPath", referencePath);

                                // Set <Private> to true
                                item.SetMetadataValue("Private", "True");

                                // Save the project after we've modified it.
                                Project.Save(this);
                            }
                        }
                    }
                    else
                    {
                        TrySetSpecificVersion(reference);
                        TrySetCopyLocal(reference);
                    }
                }

                Logger.Log(MessageLevel.Debug, VsResources.Debug_AddReference, name, ProjectName);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, VsResources.FailedToAddReference, name), e);
            }
        }
Пример #43
0
        private void TestImplicitNestedProjectReload(IServiceProvider sp, ProjectNode project, int dialogAnswer)
        {
            // Save everything.
            IVsSolution solutionService = (IVsSolution)sp.GetService(typeof(IVsSolution));

            solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, project, 0);

            IVsProject3 nestedProject = Utilities.GetNestedHierarchy(project, "ANestedProject") as IVsProject3;

            if (nestedProject == null)
            {
                throw new InvalidOperationException("The nested project has not been loaded corectly");
            }

            string nestedProjectFileName = null;

            nestedProject.GetMkDocument(VSConstants.VSITEMID_ROOT, out nestedProjectFileName);

            if (nestedProjectFileName == null)
            {
                throw new InvalidOperationException("The nested project file name could not been retrieved corectly");
            }

            string resourceText = Utilities.GetResourceStringFromTheProjectAssembly("QueryReloadNestedProject");

            // Create the messageBoxListener Thread. This will bring up the reload of the nested project file.
            // In this scenario we will answer dialogAnswer. Also we rely on the exact messagebox text here.
            string message = String.Format(System.Globalization.CultureInfo.CurrentCulture, resourceText, nestedProjectFileName);

            DialogBoxPurger purger = new DialogBoxPurger(dialogAnswer, message);
            bool            result = false;

            try
            {
                purger.Start();
                this.AddReferenceExternallyToTheProjectFile(nestedProjectFileName);
            }
            finally
            {
                result = purger.WaitForDialogThreadToTerminate();
            }

            if (!result)
            {
                throw new InvalidOperationException("The messagebox for relaoding the nested project file has never popped up");
            }

            // Check to see if the nested project is there.
            EnvDTE.Project     projectDTE = Utilities.GetAutomationObject(project);
            EnvDTE.ProjectItem item       = projectDTE.ProjectItems.Item("ANestedProject");

            Assert.IsNotNull(item, "The nested project has not been loaded correctly.");
            EnvDTE.Project nestedAutomationProject = item.SubProject;

            // Now check to see if we can find the added reference
            VSLangProj.VSProject automationProject = nestedAutomationProject.Object as VSLangProj.VSProject;
            if (nestedAutomationProject == null)
            {
                throw new InvalidOperationException("The nested project is not a vs language project");
            }

            // Get references collection
            VSLangProj.References references = automationProject.References;

            IEnumerator enumerator = references.GetEnumerator();
            bool        found      = false;

            while (enumerator.MoveNext())
            {
                VSLangProj.Reference reference = enumerator.Current as VSLangProj.Reference;
                if (reference.Name == BuildEngineRef)
                {
                    found = true;
                }
            }

            if (dialogAnswer == NativeMethods.IDYES)
            {
                Assert.IsTrue(found, "The nested project file has not been reloaded correctly");
            }
            else
            {
                Assert.IsFalse(found, "The nested project file has been reloaded but was asked not to do that.");
            }
        }
Пример #44
0
 public virtual bool FileExistsInProject(string path)
 {
     return(Project.ContainsFile(path));
 }
Пример #45
0
        /// <summary>
        /// Gets the active configuration for the given project.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <returns>Returns the active configuration.</returns>
        internal static StyleCop.Configuration GetProjectConfiguration(Project project)
        {
            Param.AssertNotNull(project, "project");

            try
            {
                // Make sure the project has a configuration manager.
                if (project != null && project.ConfigurationManager != null)
                {
                    if (!ProjectHasPropertyMissing(project, "DefineConstants"))
                    {
                        // Check whether there is an active configuration.
                        Configuration activeConfiguration = project.ConfigurationManager.ActiveConfiguration;
                        if (activeConfiguration != null)
                        {
                            // Make sure the configuration has properties.
                            if (activeConfiguration.Properties != null)
                            {
                                // Get the constants.
                                Property property = activeConfiguration.Properties.Item("DefineConstants");
                                if (property != null && property.Value != null)
                                {
                                    string constantList = property.Value as string;
                                    if (constantList != null)
                                    {
                                        // Add each constants from this configuration and return it.
                                        return new StyleCop.Configuration(constantList.Split(';'));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (COMException)
            {
            }
            catch (ArgumentException)
            {
                // For certain types of projects, the ConfigurationManager.ActiveConfiguration
                // property will throw an ArgumentException immediately when you try to access 
                // the property. This just means there is no configuration defined.
            }

            // If we get here we've either not got the property or had an exception
            AddMissingPropertyForProject(project, "DefineConstants");

            // There is no active configuration. Just return an empty configuration object.
            return new StyleCop.Configuration(null);
        }
Пример #46
0
 public static bool Build(Project pProj, OutputWindowPane pPane, string pTarget)
 {
     return Build(pProj, pPane, pTarget, new NameValueCollection());
 }
Пример #47
0
        private void openModelEditor(Project project)
        {

            Configuration configuration = project.ConfigurationManager.ActiveConfiguration;
            Property outputPathProperty = configuration.FindProperty(ConfigurationProperty.OutputPath);
            Property outputFileProperty = project.FindProperty(ProjectProperty.OutputFileName);
            Property outputDiffsProperty = project.FindProperty(ProjectProperty.FullPath);

            string outputFileName = outputFileProperty.Value.ToString();
            if (outputFileName.ToLower().EndsWith(".exe"))
                outputFileName += ".config";


            ProjectItem modelItem = getModelItem(project);

            if (modelItem != null)
                using (var storage = new DecoupledStorage(typeof(Options)))
                {
                    string path = storage.ReadString(Options.GetPageName(), "modelEditorPath");
                    if (!string.IsNullOrEmpty(path))
                    {
                        string assemblyName = Path.Combine(outputDiffsProperty.Value.ToString(),
                                                           Path.Combine(outputPathProperty.Value.ToString(),
                                                                        outputFileName));
                        if (!File.Exists(assemblyName))
                        {
                            MessageBox.Show("Assembly " + assemblyName + " not found", null, MessageBoxButtons.OK);
                            return;
                        }
                        string arguments = string.Format("\"{0}\" \"{1}\"",
                                                         assemblyName,
                                                         outputDiffsProperty.Value);
                        if (File.Exists(path))
                            Process.Start(path, arguments);
                        else
                            MessageBox.Show("Model editor not found at " + path);
                    }
                    else
                        MessageBox.Show("ModelEditorPath path is empty");
                }
        }
        /// <summary>
        /// Add a project to the cache.
        /// </summary>
        /// <param name="project">project to add to the cache.</param>
        /// <returns>The project name of the added project.</returns>
        public EnvDTEProjectName AddProject(EnvDTEProject project, VSNuGetProjectFactory factory)
        {
            // First create a project name from the project
            var EnvDTEProjectName = new EnvDTEProjectName(project);

            // Do nothing if we already have an entry
            if (_envDTEProjectCache.ContainsKey(EnvDTEProjectName))
            {
                return EnvDTEProjectName;
            }

            AddShortName(EnvDTEProjectName);

            _projectNamesCache[EnvDTEProjectName.CustomUniqueName] = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.UniqueName] = EnvDTEProjectName;
            _projectNamesCache[EnvDTEProjectName.FullName] = EnvDTEProjectName;

            // Add the entry mapping project name to the actual project
            _envDTEProjectCache[EnvDTEProjectName] = project;
            _nuGetProjectCache[EnvDTEProjectName] = factory.CreateNuGetProject(project);

            return EnvDTEProjectName;
        }
Пример #49
0
 public VsProjectSystem(Project project)
     : base(project.GetFullPath())
 {
     Project = project;
 }
Пример #50
0
        /// <summary>
        /// Enumerates through the given project.
        /// </summary>
        /// <param name="project">The project to enumerate.</param>
        /// <param name="projectCallback">Called on each project enumerated through.</param>
        /// <param name="projectItemCallback">Called on each project item enumerated through.</param>
        /// <param name="projectContext">Project-specific context information.</param>
        /// <param name="fileContext">File-specific context information.</param>
        /// <returns>If an object is returned, enumeration should end.</returns>
        private static object EnumerateProject(
            Project project,
            ProjectInvoker projectCallback,
            ProjectItemInvoker projectItemCallback,
            object projectContext,
            object fileContext)
        {
            Param.AssertNotNull(project, "project");
            Param.Ignore(projectCallback);
            Param.Ignore(projectItemCallback);
            Param.Ignore(projectContext);
            Param.Ignore(fileContext);

            DTE applicationObject = GetDTE();

            if (project.Kind == Constants.vsProjectKindSolutionItems)
            {
                // Figure out the path to the solution.
                string solutionPath = Path.GetDirectoryName(applicationObject.Solution.FullName);

                // Invoke the callback method on the project if necessary.
                if (projectCallback != null)
                {
                    // These types of projects are all located at the root of the solution, so we need
                    // to tack on the project name in order to differentiate between them.
                    string projectId = Path.Combine(applicationObject.Solution.FullName, project.Name);

                    object callbackResult = projectCallback(project, projectId.GetHashCode(), solutionPath, ref projectContext, ref fileContext);

                    if (callbackResult != null)
                    {
                        return callbackResult;
                    }
                }

                if (project.ProjectItems != null)
                {
                    // Enumerate the items under this solution project.
                    object temp = EnumerateSolutionProjectItems(
                        applicationObject.Solution, project.ProjectItems, solutionPath, projectCallback, projectItemCallback, projectContext, fileContext);

                    if (temp != null)
                    {
                        return temp;
                    }
                }
            }
            else
            {
                // Invoke the callback method on the project if necessary.
                if (projectCallback != null)
                {
                    string projectPath = GetProjectPath(project);
                    if (projectPath != null)
                    {
                        object callbackResult = projectCallback(project, projectPath.GetHashCode(), projectPath, ref projectContext, ref fileContext);
                        if (callbackResult != null)
                        {
                            return callbackResult;
                        }
                    }
                }

                if (project.ProjectItems != null)
                {
                    // Enumerate the items under this project.
                    object temp = EnumerateProjectItems(project.ProjectItems, project.Name, projectCallback, projectItemCallback, projectContext, fileContext);

                    if (temp != null)
                    {
                        return temp;
                    }
                }
            }

            return null;
        }
Пример #51
0
 public override IEnumerable <string> GetDirectories(string path)
 {
     // Get all physical folders
     return(from p in Project.GetChildItems(path, "*.*", VsConstants.VsProjectItemKindPhysicalFolder)
            select p.Name);
 }
Пример #52
0
        // REVIEW: This might be inefficient, see what we can do with caching projects until references change
        internal static IEnumerable <EnvDTEProject> GetDependentEnvDTEProjects(IDictionary <string, List <EnvDTEProject> > dependentEnvDTEProjectsDictionary, EnvDTEProject envDTEProject)
        {
            Debug.Assert(ThreadHelper.CheckAccess());

            if (envDTEProject == null)
            {
                throw new ArgumentNullException(nameof(envDTEProject));
            }

            List <Project> dependents;

            if (dependentEnvDTEProjectsDictionary.TryGetValue(EnvDTEProjectUtility.GetUniqueName(envDTEProject), out dependents))
            {
                return(dependents);
            }

            return(Enumerable.Empty <EnvDTEProject>());
        }
Пример #53
0
        private static IEnumerable<Project> GetSolutionFolderProjects(Project solutionFolder)
        {
            var projects = new List<Project>();

            for (var i = 1; i <= solutionFolder.ProjectItems.Count; i++)
            {
                var subProject = solutionFolder.ProjectItems.Item(i).SubProject;
                if (subProject == null)
                    continue;

                if (subProject.Kind == ProjectKinds.vsProjectKindSolutionFolder)
                {
                    // Solution folder: recursive call
                    projects.AddRange(GetSolutionFolderProjects(subProject));
                }
                else
                {
                    // Project: add it
                    projects.Add(subProject);
                }
            }

            return projects;
        }
 public static bool IsProjectLoaded(Project project)
 {
     return(string.Compare(Constants.vsProjectKindUnmodeled, project.Kind,
                           StringComparison.OrdinalIgnoreCase) != 0);
 }
Пример #55
0
 Project FindProject(UIHierarchyItem uiHierarchyItem, Project project=null) {
     var proj = project;
     foreach (UIHierarchyItem hierarchyItem in uiHierarchyItem.UIHierarchyItems) {
         var findProject = proj ?? hierarchyItem.Object as Project;
         if (hierarchyItem.UIHierarchyItems.Count > 0) {
             if (hierarchyItem.UIHierarchyItems.Expanded&&FindProject(hierarchyItem, findProject)!=null)
                 return findProject;
         }
         else if (hierarchyItem.IsSelected)
             return findProject;
     }
     throw new NotImplementedException();
 }
Пример #56
0
        public TreeNode CreateVirtualEnvironment(EnvDTE.Project project, out string envName)
        {
            string dummy;

            return(CreateVirtualEnvironment(project, out envName, out dummy));
        }
Пример #57
0
 static Func<string, bool> MatchProjectName(Project project) {
     string fileName = Path.GetFileName(project.FileName) + "";
     string pattern = Options.ReadString(Options.GacUtilRegex);
     return s => {
         string s1 = s.Split('|')[0];
         return s1 == project.FileName && (!string.IsNullOrEmpty(pattern) && !Regex.IsMatch(fileName, pattern));
     };
 }
Пример #58
0
 public static Property FindProperty(this Project project, ProjectProperty projectProperty)
 {
     return(project.Properties.Cast <Property>().Where(property => property.Name == projectProperty.ToString()).Single());
 }
Пример #59
0
 private void EnsureCheckedOutIfExists(string path)
 {
     Project.EnsureCheckedOutIfExists(this, path);
 }
Пример #60
0
        /// <summary>
        /// Changes the Qt version of this project.
        /// </summary>
        /// <param name="oldVersion">the current Qt version</param>
        /// <param name="newVersion">the new Qt version we want to change to</param>
        /// <param name="newProjectCreated">is set to true if a new Project object has been created</param>
        /// <returns>true, if the operation performed successfully</returns>
        public bool ChangeQtVersion(string oldVersion, string newVersion, ref bool newProjectCreated)
        {
            newProjectCreated = false;
            QtVersionManager versionManager = QtVersionManager.The();
            versionManager.SetPlatform(Project.ConfigurationManager.ActiveConfiguration.PlatformName);

            VersionInformation viOld = versionManager.GetVersionInfo(oldVersion);
            VersionInformation viNew = versionManager.GetVersionInfo(newVersion);

            string vsPlatformNameOld = null;
            if (viOld != null)
                vsPlatformNameOld = viOld.GetVSPlatformName();
            string vsPlatformNameNew = viNew.GetVSPlatformName();
            bool bRefreshMocSteps = (vsPlatformNameNew != vsPlatformNameOld);

            try
            {
                if (vsPlatformNameOld != vsPlatformNameNew)
                {
                    if (!SelectSolutionPlatform(vsPlatformNameNew) || !HasPlatform(vsPlatformNameNew))
                    {
                        CreatePlatform(vsPlatformNameOld, vsPlatformNameNew, viOld, viNew, ref newProjectCreated);
                        bRefreshMocSteps = false;
                        UpdateMocSteps(QtVSIPSettings.GetMocDirectory(envPro));
                    }
                }
                ConfigurationManager configManager = envPro.ConfigurationManager;
                if (configManager.ActiveConfiguration.PlatformName != vsPlatformNameNew)
                {
                    string projectName = envPro.FullName;
                    envPro.Save(null);
                    dte.Solution.Remove(envPro);
                    envPro = dte.Solution.AddFromFile(projectName, false);
                    dte = envPro.DTE;
                    vcPro = envPro.Object as VCProject;
                }
            }
            catch
            {
                Messages.DisplayErrorMessage(SR.GetString("CannotChangeQtVersion"));
                return false;
            }

            // We have to delete the generated files because of
            // major differences between the platforms or Qt-Versions.
            if (vsPlatformNameOld != vsPlatformNameNew || viOld.qtPatch != viNew.qtPatch
                || viOld.qtMinor != viNew.qtMinor || viOld.qtMajor != viNew.qtMajor)
            {
                DeleteGeneratedFiles();
                Clean();
            }

            if (bRefreshMocSteps)
                RefreshMocSteps();

            SetQtEnvironment(newVersion);
            UpdateModules(viOld, viNew);
            versionManager.SaveProjectQtVersion(envPro, newVersion, vsPlatformNameNew);
            return true;
        }