Skip to content

Commit

Permalink
kevinobee#66 Sitecore.Ship does not work with Sitecore 8.2 Update 1 f…
Browse files Browse the repository at this point in the history
…or Azure Deployment
  • Loading branch information
dharnitski committed Jan 4, 2017
1 parent c23a8ea commit 053c436
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Reflection;
using Sitecore.Update;

namespace Sitecore.Ship.Infrastructure.Extensions
{
public static class PackageInstallationInfoExtensions
{
public static void SetProcessingMode(this PackageInstallationInfo info)
{
var prop = info.GetType().GetProperty("ProcessingMode", BindingFlags.Public | BindingFlags.Instance);
if (prop == null || !prop.CanWrite)
{
//Pre Sitecore 8.2 Update 2 Versions have no such property
return;
}

// ProcessingMode.All = 2147483647
prop.SetValue(info, 2147483647);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Compile Include="Configuration\PackageInstallationConfigurationProvider.cs" />
<Compile Include="DataAccess\PackageHistoryRepository.cs" />
<Compile Include="Diagnostics\Logger.cs" />
<Compile Include="Extensions\PackageInstallationInfoExtensions.cs" />
<Compile Include="Install\PackageManifestReader.cs" />
<Compile Include="IO\TempPackager.cs" />
<Compile Include="Web\HttpRequestChecker.cs" />
Expand Down
17 changes: 13 additions & 4 deletions src/Sitecore.Ship.Infrastructure/Update/UpdatePackageRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Sitecore.Ship.Core;
using Sitecore.Ship.Core.Contracts;
using Sitecore.Ship.Core.Domain;
using Sitecore.Ship.Infrastructure.Extensions;
using Sitecore.Update;
using Sitecore.Update.Installer;
using Sitecore.Update.Installer.Exceptions;
Expand Down Expand Up @@ -116,16 +117,24 @@ public PackageManifest Execute(string packagePath, bool disableIndexing)

private PackageInstallationInfo GetInstallationInfo(string packagePath)
{
if (string.IsNullOrEmpty(packagePath))
{
throw new Exception("Package is not selected.");
}

var info = new PackageInstallationInfo
{
Mode = InstallMode.Install,
Action = UpgradeAction.Upgrade,
Path = packagePath
};
if (string.IsNullOrEmpty(info.Path))
{
throw new Exception("Package is not selected.");
}

// this is what we need to do in Sitecore 8.2 Update 2
// info.ProcessingMode = ProcessingMode.All
// Unfortunately that code is not compilable in previous versions
// .SetProcessingMode() assigns that property using reflection
info.SetProcessingMode();

return info;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Should;
using Sitecore.Ship.Infrastructure.Extensions;
using Sitecore.Update;
using Xunit;

#if SITECORE822
using Sitecore.Update.Utils;
#endif


namespace Sitecore.Ship.Infrastructure.Intg.Test.Extensions
{
public class PackageInstallationInfoExtensionsTests
{
[Fact]
public void SetProcessingMode_sets_Mode_All()
{
//Arrange
var sut = new PackageInstallationInfo();

//Act
sut.SetProcessingMode();

//Assert
#if SITECORE822
sut.ProcessingMode.ShouldEqual(ProcessingMode.All);
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
Expand All @@ -42,6 +42,9 @@
<Reference Include="Should">
<HintPath>..\..\..\packages\Should.1.1.20\lib\Should.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Update">
<HintPath>..\..\..\lib\Sitecore.Update.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down Expand Up @@ -69,6 +72,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions\PackageInstallationInfoExtensionsTests.cs" />
<Compile Include="PackageReaderTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down

0 comments on commit 053c436

Please sign in to comment.