From a871080297d2664fafe55644a7bfde8267e596fb Mon Sep 17 00:00:00 2001 From: Charles Turano Date: Fri, 20 Dec 2019 09:35:05 -0500 Subject: [PATCH] Fixed issue with Sitecore 9.3 property API change --- ...Hhogdev.SitecorePackageDeployer.TDS.scproj | 15 ++++-- .../Properties/AssemblyInfo.cs | 4 +- .../Tasks/InstallPackage.cs | 49 ++++++++++++++++++- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/SitecorePackageDeployer.TDS/Hhogdev.SitecorePackageDeployer.TDS.scproj b/SitecorePackageDeployer.TDS/Hhogdev.SitecorePackageDeployer.TDS.scproj index 131e6bd..8ebb601 100644 --- a/SitecorePackageDeployer.TDS/Hhogdev.SitecorePackageDeployer.TDS.scproj +++ b/SitecorePackageDeployer.TDS/Hhogdev.SitecorePackageDeployer.TDS.scproj @@ -7,9 +7,6 @@ 2.0 d16e1b30-7fa4-456b-8dfe-45dfa4ec7900 v2.0 - ..\SitecorePackageDeployer.Web - {ae330004-b9ae-465c-aec2-a5a22cde8f97}|SitecorePackageDeployer.Web\Hhogdev.SitecorePackageDeployer.Web.csproj - /Hhogdev.SitecorePackageDeployer.Web.csproj v2.0 true true @@ -23,6 +20,12 @@ False master Exclude + True + False + /Hhogdev.SitecorePackageDeployer.Web.csproj + {ae330004-b9ae-465c-aec2-a5a22cde8f97}|SitecorePackageDeployer.Web\Hhogdev.SitecorePackageDeployer.Web.csproj + ..\SitecorePackageDeployer.Web + False true @@ -37,7 +40,7 @@ Charles Turano Hedgehog Development Installs packages using a folder - 1.9 + 1.11 @@ -54,7 +57,8 @@ Hedgehog Development Installs packages using a folder 1.10 - ..\packages\SitecoreKernel.7.0.0.131127\lib + + @@ -72,6 +76,7 @@ + \ No newline at end of file diff --git a/SitecorePackageDeployer/Properties/AssemblyInfo.cs b/SitecorePackageDeployer/Properties/AssemblyInfo.cs index 1848956..064b593 100644 --- a/SitecorePackageDeployer/Properties/AssemblyInfo.cs +++ b/SitecorePackageDeployer/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.10.0.0")] -[assembly: AssemblyFileVersion("1.10.0.0")] +[assembly: AssemblyVersion("1.11.0.0")] +[assembly: AssemblyFileVersion("1.11.0.0")] diff --git a/SitecorePackageDeployer/Tasks/InstallPackage.cs b/SitecorePackageDeployer/Tasks/InstallPackage.cs index 7403a16..af29235 100644 --- a/SitecorePackageDeployer/Tasks/InstallPackage.cs +++ b/SitecorePackageDeployer/Tasks/InstallPackage.cs @@ -277,7 +277,29 @@ internal static void SetInstallerState(InstallerState installState) Log.Info(string.Format("Setting installer state to {0}", installState), typeof(InstallPackage)); Database coreDb = Database.GetDatabase("core"); - coreDb.Properties.SetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)installState); + // Use reflection to get the int value because the properties base class changed in 9.3 + if (coreDb.GetType().Assembly.GetName().Version.Major >= 14) + { + //coreDb.PropertyStore.SetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)installState); + + PropertyInfo propertyStorePropertyInfo = coreDb.GetType().GetProperty("PropertyStore"); + MethodInfo propertyStoreGetMethod = propertyStorePropertyInfo.GetGetMethod(); + object propertyStore = propertyStoreGetMethod.Invoke(coreDb, null); + + MethodInfo setIntValueMethodInfo = propertyStore.GetType().GetMethod("SetIntValue"); + setIntValueMethodInfo.Invoke(propertyStore, new object[] { INSTALLER_STATE_PROPERTY + Environment.MachineName, installState }); + } + else + { + //coreDb.Properties.SetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)installState); + + PropertyInfo propertiesPropertyInfo = coreDb.GetType().GetProperty("Properties"); + MethodInfo propertiesGetMethod = propertiesPropertyInfo.GetGetMethod(); + object properties = propertiesGetMethod.Invoke(coreDb, null); + + MethodInfo setIntValueMethodInfo = properties.GetType().GetMethod("SetIntValue"); + setIntValueMethodInfo.Invoke(properties, new object[] { INSTALLER_STATE_PROPERTY + Environment.MachineName, installState }); + } } /// @@ -287,7 +309,30 @@ internal static void SetInstallerState(InstallerState installState) internal static InstallerState GetInstallerState() { Database coreDb = Database.GetDatabase("core"); - return (InstallerState)coreDb.Properties.GetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)InstallerState.Ready); + + // Use reflection to get the int value because the properties base class changed in 9.3 + if (coreDb.GetType().Assembly.GetName().Version.Major >= 14) + { + //return (InstallerState)coreDb.PropertyStore.GetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)InstallerState.Ready); + + PropertyInfo propertyStorePropertyInfo = coreDb.GetType().GetProperty("PropertyStore"); + MethodInfo propertyStoreGetMethod = propertyStorePropertyInfo.GetGetMethod(); + object propertyStore = propertyStoreGetMethod.Invoke(coreDb, null); + + MethodInfo getIntValueMethodInfo = propertyStore.GetType().GetMethod("GetIntValue"); + return (InstallerState)getIntValueMethodInfo.Invoke(propertyStore, new object[] { INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)InstallerState.Ready }); + } + else + { + //return (InstallerState)coreDb.Properties.GetIntValue(INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)InstallerState.Ready); + + PropertyInfo propertiesPropertyInfo = coreDb.GetType().GetProperty("Properties"); + MethodInfo propertiesGetMethod = propertiesPropertyInfo.GetGetMethod(); + object properties = propertiesGetMethod.Invoke(coreDb, null); + + MethodInfo getIntValueMethodInfo = properties.GetType().GetMethod("GetIntValue"); + return (InstallerState)getIntValueMethodInfo.Invoke(properties, new object[] { INSTALLER_STATE_PROPERTY + Environment.MachineName, (int)InstallerState.Ready }); + } } ///