Skip to content

Commit

Permalink
Update package installer to work correctly with Sitecore 9 API change
Browse files Browse the repository at this point in the history
  • Loading branch information
cturano committed Nov 16, 2017
1 parent 077936e commit 8807d38
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion SitecorePackageDeployer/Tasks/InstallPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,30 @@ private void SaveInstallationMessages(string installationHistoryRoot, List<Conti
using (FileStream fileStream = File.Create(messagesFile))
{
XmlEntrySerializer xmlEntrySerializer = new XmlEntrySerializer();
xmlEntrySerializer.Serialize(logMessages, fileStream);

//For some reason, this has changed in Sitecore 9. We are using reflection to get it because the fileStream parameter can be a FileStream or Stream
//xmlEntrySerializer.Serialize(logMessages, fileStream);
Type serializerType = xmlEntrySerializer.GetType();

MethodInfo serializeMethod = serializerType.GetMethod("Serialize",
BindingFlags.Public | BindingFlags.Instance,
null,
new Type[] { logMessages.GetType(), typeof(FileStream) },
null);

if (serializeMethod == null)
{
serializeMethod = serializerType.GetMethod("Serialize",
BindingFlags.Public | BindingFlags.Instance,
null,
new Type[] { logMessages.GetType(), typeof(Stream) },
null);
}

if (serializeMethod != null)
{
serializeMethod.Invoke(xmlEntrySerializer, new object[] { logMessages, fileStream });
}
}
}
catch (Exception ex)
Expand Down

0 comments on commit 8807d38

Please sign in to comment.