Skip to content

Commit

Permalink
Fixed issue with Sitecore 9.3 property API change
Browse files Browse the repository at this point in the history
  • Loading branch information
cturano committed Dec 20, 2019
1 parent 61553c7 commit a871080
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>d16e1b30-7fa4-456b-8dfe-45dfa4ec7900</ProjectGuid>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<SourceWebPhysicalPath>..\SitecorePackageDeployer.Web</SourceWebPhysicalPath>
<SourceWebProject>{ae330004-b9ae-465c-aec2-a5a22cde8f97}|SitecorePackageDeployer.Web\Hhogdev.SitecorePackageDeployer.Web.csproj</SourceWebProject>
<SourceWebVirtualPath>/Hhogdev.SitecorePackageDeployer.Web.csproj</SourceWebVirtualPath>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
Expand All @@ -23,6 +20,12 @@
<ManageRoles>False</ManageRoles>
<SitecoreDatabase>master</SitecoreDatabase>
<AssemblyStatus>Exclude</AssemblyStatus>
<EnableAssemblyValidation>True</EnableAssemblyValidation>
<EnablePackageValidation>False</EnablePackageValidation>
<SourceWebVirtualPath>/Hhogdev.SitecorePackageDeployer.Web.csproj</SourceWebVirtualPath>
<SourceWebProject>{ae330004-b9ae-465c-aec2-a5a22cde8f97}|SitecorePackageDeployer.Web\Hhogdev.SitecorePackageDeployer.Web.csproj</SourceWebProject>
<SourceWebPhysicalPath>..\SitecorePackageDeployer.Web</SourceWebPhysicalPath>
<CompactSitecoreItemsInProjectFile>False</CompactSitecoreItemsInProjectFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -37,7 +40,7 @@
<PackageAuthor>Charles Turano</PackageAuthor>
<PackagePublisher>Hedgehog Development</PackagePublisher>
<PackageReadme>Installs packages using a folder</PackageReadme>
<PackageVersion>1.9</PackageVersion>
<PackageVersion>1.11</PackageVersion>
<SitecoreAssemblyPath>
</SitecoreAssemblyPath>
</PropertyGroup>
Expand All @@ -54,7 +57,8 @@
<PackagePublisher>Hedgehog Development</PackagePublisher>
<PackageReadme>Installs packages using a folder</PackageReadme>
<PackageVersion>1.10</PackageVersion>
<SitecoreAssemblyPath>..\packages\SitecoreKernel.7.0.0.131127\lib</SitecoreAssemblyPath>
<SitecoreAssemblyPath>
</SitecoreAssemblyPath>
</PropertyGroup>
<ItemGroup>
<AssemblyAttributes Include="AssemblyFileVersion">
Expand All @@ -72,6 +76,7 @@
</ItemGroup>
<ItemGroup>
<ExcludedAssemblies Include="newtonsoft.json.dll" />
<ExcludedAssemblies Include="Sitecore.%2a" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets" Condition="Exists('$(MSBuildExtensionsPath)\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets')" />
</Project>
4 changes: 2 additions & 2 deletions SitecorePackageDeployer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
49 changes: 47 additions & 2 deletions SitecorePackageDeployer/Tasks/InstallPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

/// <summary>
Expand All @@ -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 });
}
}

/// <summary>
Expand Down

0 comments on commit a871080

Please sign in to comment.