diff options
author | Olli Werwolff <qt-info@nokia.com> | 2011-02-10 11:56:04 +0100 |
---|---|---|
committer | Olli Werwolff <qt-info@nokia.com> | 2011-02-14 11:22:45 +0100 |
commit | d229bf5f5d329c7bdf4d14929df8813dac879091 (patch) | |
tree | 5ddb06dc33b12e1b7fef6bb32ecd4e1f51b52358 | |
parent | 07f7f4ca3b03f740ff662e545b16b4abdad0e163 (diff) |
Do not hardcode Qt directory in PropertySheet in VS2010
Get rid of the Property sheet and save the Qt directory
in the vcxproj.user file
Task-number: QTVSADDINBUG-12
Reviewed-by: joerg
-rw-r--r-- | Qt4VS2003/Qt4VSAddin/AddInEventHandler.cs | 15 | ||||
-rw-r--r-- | Qt4VS2003/Qt4VSAddin/ExtLoader.cs | 1 | ||||
-rw-r--r-- | Qt4VS2003/QtProjectLib/HelperFunctions.cs | 3 | ||||
-rw-r--r-- | Qt4VS2003/QtProjectLib/ProjectImporter.cs | 10 | ||||
-rw-r--r-- | Qt4VS2003/QtProjectLib/ProjectLibStringResources.de.resx | 3 | ||||
-rw-r--r-- | Qt4VS2003/QtProjectLib/ProjectLibStringResources.resx | 3 | ||||
-rw-r--r-- | Qt4VS2003/QtProjectLib/QtProject.cs | 97 |
7 files changed, 24 insertions, 108 deletions
diff --git a/Qt4VS2003/Qt4VSAddin/AddInEventHandler.cs b/Qt4VS2003/Qt4VSAddin/AddInEventHandler.cs index ba35181f..6baa8b7d 100644 --- a/Qt4VS2003/Qt4VSAddin/AddInEventHandler.cs +++ b/Qt4VS2003/Qt4VSAddin/AddInEventHandler.cs @@ -508,7 +508,7 @@ namespace Qt4VSAddin if (qtDir == null) return; - HelperFunctions.SetEnvironmentVariableEx("QTDIR", qtDir); + qtpro.SetQtEnvironment(); HelperFunctions.SetDebuggingEnvironment(project); if (QtVSIPSettings.GetLUpdateOnBuild(project)) @@ -874,14 +874,6 @@ namespace Qt4VSAddin } } } -#if VS2010 - if (HelperFunctions.IsQtProject(project)) - { - QtProject qtPro = QtProject.Create(project); - string qtVersion = QtVersionManager.The().GetProjectQtVersion(project); - qtPro.UpdateQtDirPropertySheet(qtVersion); - } -#endif } void SolutionEvents_ProjectRemoved(Project project) @@ -894,11 +886,6 @@ namespace Qt4VSAddin { if (HelperFunctions.IsQtProject(p)) { -#if VS2010 - QtProject qtPro = QtProject.Create(p); - string qtVersion = QtVersionManager.The().GetProjectQtVersion(p); - qtPro.UpdateQtDirPropertySheet(qtVersion); -#endif RegisterVCProjectEngineEvents(p); } } diff --git a/Qt4VS2003/Qt4VSAddin/ExtLoader.cs b/Qt4VS2003/Qt4VSAddin/ExtLoader.cs index c345b706..48b85340 100644 --- a/Qt4VS2003/Qt4VSAddin/ExtLoader.cs +++ b/Qt4VS2003/Qt4VSAddin/ExtLoader.cs @@ -85,7 +85,6 @@ namespace Qt4VSAddin return; } #endif - HelperFunctions.SetEnvironmentVariableEx("QTDIR", qtDir); if (Connect._applicationObject != null) { ProjectImporter proFileImporter = new ProjectImporter(Connect._applicationObject); diff --git a/Qt4VS2003/QtProjectLib/HelperFunctions.cs b/Qt4VS2003/QtProjectLib/HelperFunctions.cs index be65730f..18b3d40f 100644 --- a/Qt4VS2003/QtProjectLib/HelperFunctions.cs +++ b/Qt4VS2003/QtProjectLib/HelperFunctions.cs @@ -567,9 +567,6 @@ namespace Nokia.QtProjectLib vm.SaveProjectQtVersion(project, qtVersion); QtProject qtPro = QtProject.Create(project); -#if VS2010 - qtPro.UpdateQtDirPropertySheet(qtVersion); -#endif string activeConfig = project.ConfigurationManager.ActiveConfiguration.ConfigurationName; VCConfiguration activeVCConfig = (VCConfiguration)((IVCCollection)qtPro.VCProject.Configurations).Item(activeConfig); diff --git a/Qt4VS2003/QtProjectLib/ProjectImporter.cs b/Qt4VS2003/QtProjectLib/ProjectImporter.cs index 6183cbcb..81c0b600 100644 --- a/Qt4VS2003/QtProjectLib/ProjectImporter.cs +++ b/Qt4VS2003/QtProjectLib/ProjectImporter.cs @@ -99,10 +99,7 @@ namespace Nokia.QtProjectLib { QtVersionManager.The().SaveProjectQtVersion(prj, qtVersion); QtProject qtPro = QtProject.Create(prj); -#if VS2010 - string newQtDir = QtVersionManager.The().GetInstallPath(qtVersion); - qtPro.UpdateQtDirPropertySheet(qtVersion); -#endif + qtPro.SetQtEnvironment(); ApplyPostImportSteps(qtPro); } } @@ -163,16 +160,13 @@ namespace Nokia.QtProjectLib if (pro != null) { QtProject qtPro = QtProject.Create(pro); + qtPro.SetQtEnvironment(); VersionInformation versionInfo = new VersionInformation(null); string platformName = versionInfo.GetVSPlatformName(); if (qtVersion != null) { QtVersionManager.The().SaveProjectQtVersion(pro, qtVersion, platformName); -#if VS2010 - string newQtDir = QtVersionManager.The().GetInstallPath(qtVersion); - qtPro.UpdateQtDirPropertySheet(qtVersion); -#endif } if (!qtPro.SelectSolutionPlatform(platformName) || !qtPro.HasPlatform(platformName)) { diff --git a/Qt4VS2003/QtProjectLib/ProjectLibStringResources.de.resx b/Qt4VS2003/QtProjectLib/ProjectLibStringResources.de.resx index 6a87b87b..2123804d 100644 --- a/Qt4VS2003/QtProjectLib/ProjectLibStringResources.de.resx +++ b/Qt4VS2003/QtProjectLib/ProjectLibStringResources.de.resx @@ -329,4 +329,7 @@ und diese automatisch wieder dem Projekt hinzuzufügen.</value> <data name="QtProject_CannotFindCustomBuildTool" xml:space="preserve"> <value>Kann Custom Build Tool für {0} nicht finden.</value> </data> + <data name="QtProject_CannotAccessUserFile" xml:space="preserve"> + <value>QTDIR konnte nicht zur User Datei von {0} hinzugefügt werden.</value> + </data> </root>
\ No newline at end of file diff --git a/Qt4VS2003/QtProjectLib/ProjectLibStringResources.resx b/Qt4VS2003/QtProjectLib/ProjectLibStringResources.resx index 3ba4405f..3819bb68 100644 --- a/Qt4VS2003/QtProjectLib/ProjectLibStringResources.resx +++ b/Qt4VS2003/QtProjectLib/ProjectLibStringResources.resx @@ -327,4 +327,7 @@ Select 'Yes' to overwrite, select 'No' to keep the existing file and automatical <data name="QtProject_CannotFindCustomBuildTool" xml:space="preserve"> <value>Could not find custom build tool for {0}.</value> </data> + <data name="QtProject_CannotAccessUserFile" xml:space="preserve"> + <value>Could not add QTDIR to {0}'s user file.</value> + </data> </root>
\ No newline at end of file diff --git a/Qt4VS2003/QtProjectLib/QtProject.cs b/Qt4VS2003/QtProjectLib/QtProject.cs index 196b3043..a9bccb3e 100644 --- a/Qt4VS2003/QtProjectLib/QtProject.cs +++ b/Qt4VS2003/QtProjectLib/QtProject.cs @@ -651,12 +651,6 @@ namespace Nokia.QtProjectLib } if ((type & TemplateType.PluginProject) != 0) MarkAsDesignerPluginProject(); -#if VS2010 - if (qtVersion == null) - qtVersion = vm.GetQtVersionFromInstallDir(vi.qtDir); - UpdateQtDirPropertySheet(qtVersion); -#endif - } public void MarkAsDesignerPluginProject() @@ -3114,9 +3108,6 @@ namespace Nokia.QtProjectLib if (bRefreshMocSteps) RefreshMocSteps(); -#if VS2010 - UpdateQtDirPropertySheet(newVersion); -#endif HelperFunctions.SetEnvironmentVariable("QTDIR", viNew.qtDir); UpdateModules(viOld, viNew); @@ -3571,85 +3562,27 @@ namespace Nokia.QtProjectLib return projectItem; } -#if VS2010 - public void UpdateQtDirPropertySheet(string newQtVersion) + public void SetQtEnvironment() { - if (string.IsNullOrEmpty(newQtVersion)) + string qtVersion = QtVersionManager.The().GetProjectQtVersion(envPro); + if (string.IsNullOrEmpty(qtVersion)) return; - string newQtDir = null; - if (newQtVersion != "$(QTDIR)") - newQtDir = QtVersionManager.The().GetInstallPath(newQtVersion); - string propSheetFileName = vcPro.ProjectDirectory + Resources.qtSheetKeyword + ".props"; - if (!File.Exists(propSheetFileName)) - { - StreamWriter sw = new StreamWriter(propSheetFileName); - sw.WriteLine(@"<?xml version=""1.0"" encoding=""utf-8""?>"); - sw.WriteLine(@"<Project ToolsVersion=""4.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"); - sw.WriteLine(@"<ImportGroup Label=""PropertySheets"" />"); - sw.WriteLine(@"<PropertyGroup Label=""UserMacros"" />"); - sw.WriteLine(@"<PropertyGroup />"); - sw.WriteLine(@"<ItemDefinitionGroup />"); - sw.WriteLine(@"<ItemGroup />"); - sw.WriteLine(@"</Project>"); - sw.Close(); + string qtDir = null; + if (qtVersion != "$(QTDIR)") + qtDir = QtVersionManager.The().GetInstallPath(qtVersion); + HelperFunctions.SetEnvironmentVariableEx("QTDIR", qtDir); +#if VS2010 + try + { + var propertyAccess = (IVCBuildPropertyStorage)vcPro; + propertyAccess.SetPropertyValue("QTDIR", null, "UserFile", qtDir); } - - foreach (VCConfiguration vcConfig in vcPro.Configurations as IVCCollection) + catch (Exception) { - VCPropertySheet qtDirSheet = null; - IVCCollection sheets = vcConfig.PropertySheets as IVCCollection; - foreach (VCPropertySheet sheet in sheets) - { - if (sheet.Name == Resources.qtSheetKeyword) - { - qtDirSheet = sheet; - break; - } - } - if (qtDirSheet == null) - { - try - { - qtDirSheet = vcConfig.AddPropertySheet(propSheetFileName); - } - catch (Exception e) - { - Messages.PaneMessage(dte, "Couldn't create property sheet. Exception: " + e.Message); - } - } - - VCUserMacro qtDirMacro = null; - foreach (VCUserMacro macro in qtDirSheet.UserMacros) - { - if (macro.Name == "QTDIR") - { - qtDirMacro = macro; - break; - } - } - // The Qt version to use is not $(QTDIR) - if (newQtDir != null) - { - if (qtDirMacro == null) - { - qtDirMacro = qtDirSheet.AddUserMacro("QTDIR", newQtDir); - qtDirMacro.PerformEnvironmentSet = true; - qtDirSheet.Save(); - } - else if (qtDirMacro.Value != newQtDir) - { - qtDirMacro.Value = newQtDir; - qtDirMacro.PerformEnvironmentSet = true; - qtDirSheet.Save(); - } - } - else if (qtDirMacro != null) - { - qtDirSheet.RemoveUserMacro(qtDirMacro); - } + Messages.PaneMessage(envPro.DTE, SR.GetString("QtProject_CannotAccessUserFile", vcPro.ItemName)); } - } #endif + } } } |