enhancement to check version compatibility
This commit is contained in:
parent
e25bbe2e24
commit
72c7f4abb0
|
@ -3,6 +3,9 @@ using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using System.Xml;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
|
@ -32,21 +35,47 @@ namespace Oqtane.Infrastructure
|
||||||
Directory.CreateDirectory(folder);
|
Directory.CreateDirectory(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterate through theme packages
|
// iterate through packages
|
||||||
foreach (string packagename in Directory.GetFiles(folder, "*.nupkg"))
|
foreach (string packagename in Directory.GetFiles(folder, "*.nupkg"))
|
||||||
{
|
{
|
||||||
string name = Path.GetFileNameWithoutExtension(packagename);
|
string name = Path.GetFileNameWithoutExtension(packagename);
|
||||||
string[] segments = name.Split('.');
|
string[] segments = name.Split('.');
|
||||||
name = string.Join('.', segments, 0, segments.Length - 3);
|
name = string.Join('.', segments, 0, segments.Length - 3);
|
||||||
|
|
||||||
// iterate through files and deploy to appropriate locations
|
// iterate through files
|
||||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||||
{
|
{
|
||||||
|
string frameworkversion = "";
|
||||||
|
// locate nuspec
|
||||||
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
if (entry.FullName.ToLower().EndsWith(".nuspec"))
|
||||||
|
{
|
||||||
|
// open nuspec
|
||||||
|
XmlTextReader reader = new XmlTextReader(entry.Open());
|
||||||
|
reader.Namespaces = false; // remove namespace
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.Load(reader);
|
||||||
|
// get framework dependency
|
||||||
|
XmlNode node = doc.SelectSingleNode("/package/metadata/dependencies/dependency[@id='Oqtane.Framework']");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
frameworkversion = node.Attributes["version"].Value;
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if compatible with framework version
|
||||||
|
if (frameworkversion == "" || Version.Parse(Constants.Version).CompareTo(Version.Parse(frameworkversion)) >= 0)
|
||||||
|
{
|
||||||
|
// deploy to appropriate locations
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
{
|
{
|
||||||
string filename = Path.GetFileName(entry.FullName);
|
string filename = Path.GetFileName(entry.FullName);
|
||||||
switch (Path.GetExtension(filename).ToLower())
|
switch (Path.GetExtension(filename).ToLower())
|
||||||
{
|
{
|
||||||
|
case ".pdb":
|
||||||
case ".dll":
|
case ".dll":
|
||||||
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
||||||
break;
|
break;
|
||||||
|
@ -67,6 +96,7 @@ namespace Oqtane.Infrastructure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// remove package
|
// remove package
|
||||||
File.Delete(packagename);
|
File.Delete(packagename);
|
||||||
install = true;
|
install = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user