From 2780e4d02936826ad2a07b19d8d0bf56cbc33847 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Wed, 21 Apr 2021 19:31:02 -0400 Subject: [PATCH] modify nuget package installer to support satellite assemblies in subfolders --- .../Themes/OqtaneTheme/Themes/Default.razor | 6 +- .../OqtaneTheme/Themes/ThemeSettings.razor | 4 +- .../Infrastructure/InstallationManager.cs | 59 ++++++++++--------- .../Oqtane.Themes.OqtaneTheme/Theme.css | 1 + 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Oqtane.Client/Themes/OqtaneTheme/Themes/Default.razor b/Oqtane.Client/Themes/OqtaneTheme/Themes/Default.razor index e2ff2270..3de4b465 100644 --- a/Oqtane.Client/Themes/OqtaneTheme/Themes/Default.razor +++ b/Oqtane.Client/Themes/OqtaneTheme/Themes/Default.razor @@ -93,10 +93,14 @@ @if (_footer) { - diff --git a/Oqtane.Client/Themes/OqtaneTheme/Themes/ThemeSettings.razor b/Oqtane.Client/Themes/OqtaneTheme/Themes/ThemeSettings.razor index baaa940f..05d0351b 100644 --- a/Oqtane.Client/Themes/OqtaneTheme/Themes/ThemeSettings.razor +++ b/Oqtane.Client/Themes/OqtaneTheme/Themes/ThemeSettings.razor @@ -7,10 +7,10 @@
- + - diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index 3962baf5..ef3b0b7e 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -38,7 +38,7 @@ namespace Oqtane.Infrastructure public static bool InstallPackages(string folders, string webRootPath, string contentRootPath) { bool install = false; - string binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); + string binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); foreach (string folder in folders.Split(',')) { @@ -82,40 +82,37 @@ namespace Oqtane.Infrastructure List assets = new List(); bool manifest = false; - // module and theme packages must be in form of name.1.0.0.nupkg + // packages are in form of name.1.0.0.nupkg or name.culture.1.0.0.nupkg string name = Path.GetFileNameWithoutExtension(packagename); string[] segments = name?.Split('.'); - if (segments != null) name = string.Join('.', segments, 0, segments.Length - 3); + if (segments != null) name = string.Join('.', segments, 0, segments.Length - 3); // remove version information // deploy to appropriate locations foreach (ZipArchiveEntry entry in archive.Entries) { - string foldername = Path.GetDirectoryName(entry.FullName).Split(Path.DirectorySeparatorChar)[0]; - string filename = Path.GetFileName(entry.FullName); + string filename = ""; - if (!manifest && filename == "assets.json") + // evaluate entry root folder + switch (entry.FullName.Split('/')[0]) { - manifest = true; + case "lib": // lib/net5.0/... + filename = ExtractFile(entry, binPath, 2); + break; + case "wwwroot": // wwwroot/... + filename = ExtractFile(entry, webRootPath, 1); + break; + case "runtimes": // runtimes/name/... + filename = ExtractFile(entry, binPath, 0); + break; } - switch (foldername) + if (filename != "") { - case "lib": - filename = Path.Combine(binFolder, filename); - ExtractFile(entry, filename); - assets.Add(filename.Replace(contentRootPath, "")); - break; - case "wwwroot": - filename = Path.Combine(webRootPath, Utilities.PathCombine(entry.FullName.Replace("wwwroot/", "").Split('/'))); - ExtractFile(entry, filename); - assets.Add(filename.Replace(contentRootPath, "")); - break; - case "runtimes": - var destSubFolder = Path.GetDirectoryName(entry.FullName); - filename = Path.Combine(binFolder, destSubFolder, filename); - ExtractFile(entry, filename); - assets.Add(filename.Replace(contentRootPath, "")); - break; + assets.Add(filename.Replace(contentRootPath, "")); + if (!manifest && Path.GetFileName(filename) == "assets.json") + { + manifest = true; + } } } @@ -145,21 +142,25 @@ namespace Oqtane.Infrastructure return install; } - private static void ExtractFile(ZipArchiveEntry entry, string filename) + private static string ExtractFile(ZipArchiveEntry entry, string folder, int ignoreLeadingSegments) { - if (!Directory.Exists(Path.GetDirectoryName(filename))) - { - Directory.CreateDirectory(Path.GetDirectoryName(filename)); - } + string[] segments = entry.FullName.Split('/'); // ZipArchiveEntries always use unix path separator + string filename = Path.Combine(folder, string.Join(Path.DirectorySeparatorChar, segments, ignoreLeadingSegments, segments.Length - ignoreLeadingSegments)); try { + if (!Directory.Exists(Path.GetDirectoryName(filename))) + { + Directory.CreateDirectory(Path.GetDirectoryName(filename)); + } entry.ExtractToFile(filename, true); } catch { // an error occurred extracting the file + filename = ""; } + return filename; } public void UpgradeFramework() diff --git a/Oqtane.Server/wwwroot/Themes/Oqtane.Themes.OqtaneTheme/Theme.css b/Oqtane.Server/wwwroot/Themes/Oqtane.Themes.OqtaneTheme/Theme.css index a4c5f957..e95b6d11 100644 --- a/Oqtane.Server/wwwroot/Themes/Oqtane.Themes.OqtaneTheme/Theme.css +++ b/Oqtane.Server/wwwroot/Themes/Oqtane.Themes.OqtaneTheme/Theme.css @@ -55,6 +55,7 @@ div.app-moduleactions a.dropdown-toggle, div.app-moduleactions div.dropdown-menu min-height: 40px; text-align: center; color: #ffffff; + z-index: 1000; } @media (max-width: 767px) {