From bc9bbb4ecc05e7f8e480d80702ee0f57f115f1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Wed, 24 May 2017 22:01:27 +0100 Subject: [PATCH] Fixed project properties bug. --- Setup/Cosmos.iss | 4 ++-- .../CosmosProjectNode.cs | 20 +++++++++++++++++++ .../PropertyPages/CosmosPage.cs | 3 +-- .../PropertyPages/CustomPropertyPage.cs | 11 ++++++---- source/MPF/12.0/ProjectNode.cs | 7 ++++++- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Setup/Cosmos.iss b/Setup/Cosmos.iss index 2ba3e04dd..0491cdb87 100644 --- a/Setup/Cosmos.iss +++ b/Setup/Cosmos.iss @@ -144,8 +144,8 @@ Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /a Cosmos.VS ;Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /a XSharp.VS.vsix"; WorkingDir: "{app}\VSIX\"; Description: "Install Cosmos X# Language"; StatusMsg: "Installing Visual Studio Extension: Cosmos X# Language" [UninstallRun] -Filename: "{code:GetVsixInstallCommand}"; Parameters: "{code:GetVsixUninstallParams|Cosmos.VS.ProjectSystem}" -;Filename: "{code:GetVsixInstallCommand}"; Parameters: "{code:GetVsixUninstallParams|XSharp.VS}" +Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /a /u:Cosmos.VS.ProjectSystem"; Description: "Remove Cosmos Project System"; StatusMsg: "Removing Visual Studio Extension: Cosmos Project System" +;Filename: "{app}\Build\Tools\VSIXBootstrapper.exe"; Parameters: "/q /a /u:XSharp.VS"; Description: "Remove Cosmos X# Language"; StatusMsg: "Removing Visual Studio Extension: Cosmos X# Language" [Code] function ExecWithResult(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; diff --git a/source/Cosmos.VS.ProjectSystem/CosmosProjectNode.cs b/source/Cosmos.VS.ProjectSystem/CosmosProjectNode.cs index 785316008..eec305c57 100644 --- a/source/Cosmos.VS.ProjectSystem/CosmosProjectNode.cs +++ b/source/Cosmos.VS.ProjectSystem/CosmosProjectNode.cs @@ -189,6 +189,26 @@ namespace Cosmos.VS.ProjectSystem } } + protected override void SetMSBuildProjectProperty(string propertyName, string propertyValue) + { + var xPropertyGroupsCount = BuildProject.Xml.PropertyGroups.Count; + + if (xPropertyGroupsCount == 0) + { + throw new Exception("The Cosmos project is invalid."); + } + + if (xPropertyGroupsCount == 1) + { + var xPropertyGroup = BuildProject.Xml.AddPropertyGroup(); + xPropertyGroup.SetProperty(propertyName, propertyValue); + } + else + { + BuildProject.Xml.PropertyGroups.ElementAt(xPropertyGroupsCount - 1).SetProperty(propertyName, propertyValue); + } + } + #region IVsReferenceManagerUser methods public void ChangeReferences(uint operation, IVsReferenceProviderContext changedContext) diff --git a/source/Cosmos.VS.ProjectSystem/PropertyPages/CosmosPage.cs b/source/Cosmos.VS.ProjectSystem/PropertyPages/CosmosPage.cs index 610afdca1..1b8defa2b 100644 --- a/source/Cosmos.VS.ProjectSystem/PropertyPages/CosmosPage.cs +++ b/source/Cosmos.VS.ProjectSystem/PropertyPages/CosmosPage.cs @@ -475,7 +475,6 @@ namespace Cosmos.VS.ProjectSystem.PropertyPages else if (mProps.Profile == "PXE") { chckEnableDebugStub.Checked = false; - } else if (mProps.Profile == "Bochs") { @@ -695,7 +694,7 @@ namespace Cosmos.VS.ProjectSystem.PropertyPages FillNetworkInterfaces(); } - protected BuildProperties mProps = new BuildProperties(); + protected BuildProperties mProps = new BuildProperties(); public override PropertiesBase Properties { diff --git a/source/Cosmos.VS.ProjectSystem/PropertyPages/CustomPropertyPage.cs b/source/Cosmos.VS.ProjectSystem/PropertyPages/CustomPropertyPage.cs index b49102820..35cf229aa 100644 --- a/source/Cosmos.VS.ProjectSystem/PropertyPages/CustomPropertyPage.cs +++ b/source/Cosmos.VS.ProjectSystem/PropertyPages/CustomPropertyPage.cs @@ -276,10 +276,13 @@ namespace Cosmos.VS.ProjectSystem.PropertyPages foreach (var pair in properties) { string propertyName = pair.Key; - if (independentProperties.Contains(propertyName)) - SetProjectProperty(pair.Key, pair.Value); - else - SetConfigProperty(pair.Key, pair.Value); + + //if (independentProperties.Contains(propertyName)) + // SetProjectProperty(pair.Key, pair.Value); + //else + // SetConfigProperty(pair.Key, pair.Value); + + SetProjectProperty(pair.Key, pair.Value); } IsDirty = false; diff --git a/source/MPF/12.0/ProjectNode.cs b/source/MPF/12.0/ProjectNode.cs index 8ce20ff72..9d94396ff 100644 --- a/source/MPF/12.0/ProjectNode.cs +++ b/source/MPF/12.0/ProjectNode.cs @@ -2198,7 +2198,7 @@ namespace Microsoft.VisualStudio.Project throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } - this.buildProject.SetProperty(propertyName, propertyValue); + SetMSBuildProjectProperty(propertyName, propertyValue); RaiseProjectPropertyChanged(propertyName, oldValue, propertyValue); // property cache will need to be updated @@ -2208,6 +2208,11 @@ namespace Microsoft.VisualStudio.Project return; } + protected virtual void SetMSBuildProjectProperty(string propertyName, string propertyValue) + { + this.buildProject.SetProperty(propertyName, propertyValue); + } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] public virtual ProjectOptions GetProjectOptions(string config = null) {