diff --git a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor index 88fcbeebb..68046beb1 100644 --- a/Oqtane.Client/Modules/Admin/Upgrade/Index.razor +++ b/Oqtane.Client/Modules/Admin/Upgrade/Index.razor @@ -51,7 +51,7 @@ List packages = await PackageService.GetPackagesAsync("framework"); if (packages != null) { - _package = packages.FirstOrDefault(); + _package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault(); if (_package != null) { _upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0); @@ -89,7 +89,7 @@ try { await PackageService.DownloadPackageAsync(packageid, version, "Packages"); - await PackageService.DownloadPackageAsync("Oqtane.Upgrade", version, "Packages"); + await PackageService.DownloadPackageAsync(Constants.UpdaterPackageId, version, "Packages"); AddModuleMessage(Localizer["Framework Downloaded Successfully... Please Select Upgrade To Complete the Process"], MessageType.Success); } catch (Exception ex) diff --git a/Oqtane.Package/Oqtane.Upgrade.nuspec b/Oqtane.Package/Oqtane.Updater.nuspec similarity index 84% rename from Oqtane.Package/Oqtane.Upgrade.nuspec rename to Oqtane.Package/Oqtane.Updater.nuspec index b4ff15069..fcd54d86f 100644 --- a/Oqtane.Package/Oqtane.Upgrade.nuspec +++ b/Oqtane.Package/Oqtane.Updater.nuspec @@ -1,7 +1,7 @@  - Oqtane.Upgrade + Oqtane.Updater 2.1.0 Shaun Walker .NET Foundation @@ -14,10 +14,10 @@ https://github.com/oqtane/oqtane.framework https://github.com/oqtane/oqtane.framework/releases/tag/v2.1.0 icon.png - oqtane upgrade + oqtane - + \ No newline at end of file diff --git a/Oqtane.Package/release.cmd b/Oqtane.Package/release.cmd index 63c76cdbf..2da130b65 100644 --- a/Oqtane.Package/release.cmd +++ b/Oqtane.Package/release.cmd @@ -5,7 +5,6 @@ copy /Y/B/V "..\Oqtane.Server\bin\Release\net5.0\System.Drawing.Common.dll" "..\ nuget.exe pack Oqtane.Client.nuspec nuget.exe pack Oqtane.Server.nuspec nuget.exe pack Oqtane.Shared.nuspec -nuget.exe pack Oqtane.Upgrade.nuspec nuget.exe pack Oqtane.Framework.nuspec del /F/Q/S "..\Oqtane.Server\bin\Release\net5.0\publish" > NUL rmdir /Q/S "..\Oqtane.Server\bin\Release\net5.0\publish" @@ -14,7 +13,10 @@ del "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.json" ren "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.release.json" "appsettings.json" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\install.ps1" del "..\Oqtane.Server\bin\Release\net5.0\publish\appsettings.json" -del "..\Oqtane.Server\bin\Release\net5.0\publish\Oqtane.Upgrade.*" C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ".\upgrade.ps1" +dotnet clean -c Release ..\Oqtane.Updater.sln +dotnet build -c Release ..\Oqtane.Updater.sln +dotnet publish ..\Oqtane.Updater\Oqtane.Updater.csproj /p:Configuration=Release +nuget.exe pack Oqtane.Updater.nuspec pause diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index d40d63c15..f8536a4fa 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -264,14 +264,18 @@ public void UpgradeFramework() // ensure package version is greater than or equal to current framework version if (packageversion != "" && Version.Parse(Constants.Version).CompareTo(Version.Parse(packageversion)) <= 0 && packageurl != "") { - // install upgrade nuget package + // install Oqtane.Framework and Oqtane.Updater nuget packages InstallPackages(); // download upgrade zip package var client = new WebClient(); Uri uri = new Uri(packageurl); - client.DownloadFile(packageurl, Path.Combine(folder, uri.Segments[uri.Segments.Length - 1])); - // install upgrade zip package - FinishUpgrade(); + string upgradepackage = Path.Combine(folder, uri.Segments[uri.Segments.Length - 1]); + client.DownloadFile(packageurl, upgradepackage); + // install Oqtane.Upgrade zip package + if (File.Exists(upgradepackage)) + { + FinishUpgrade(); + } } } } @@ -279,19 +283,19 @@ public void UpgradeFramework() private void FinishUpgrade() { - // check if upgrade application exists - string Upgrader = "Oqtane.Upgrade.dll"; + // check if updater application exists + string Updater = Constants.UpdaterPackageId + ".dll"; string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); - if (folder == null || !File.Exists(Path.Combine(folder, Upgrader))) return; + if (folder == null || !File.Exists(Path.Combine(folder, Updater))) return; - // run upgrade application + // run updater application using (var process = new Process()) { process.StartInfo = new ProcessStartInfo { WorkingDirectory = folder, FileName = "dotnet", - Arguments = Path.Combine(folder, Upgrader) + " \"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"", + Arguments = Path.Combine(folder, Updater) + " \"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"", UseShellExecute = false, ErrorDialog = false, CreateNoWindow = true, diff --git a/Oqtane.Server/Oqtane.Server.csproj b/Oqtane.Server/Oqtane.Server.csproj index 422d9618e..c1f39b2df 100644 --- a/Oqtane.Server/Oqtane.Server.csproj +++ b/Oqtane.Server/Oqtane.Server.csproj @@ -48,18 +48,12 @@ - - - - - - diff --git a/Oqtane.Shared/Shared/Constants.cs b/Oqtane.Shared/Shared/Constants.cs index 7d384e086..7590fcf69 100644 --- a/Oqtane.Shared/Shared/Constants.cs +++ b/Oqtane.Shared/Shared/Constants.cs @@ -3,9 +3,10 @@ namespace Oqtane.Shared { public class Constants { - public const string PackageId = "Oqtane.Framework"; public static readonly string Version = "2.1.0"; public const string ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,2.0.0,2.0.1,2.0.2,2.1.0"; + public const string PackageId = "Oqtane.Framework"; + public const string UpdaterPackageId = "Oqtane.Updater"; public const string DefaultDBType = "Oqtane.Database.SqlServer.SqlServerDatabase, Oqtane.Database.SqlServer"; diff --git a/Oqtane.Updater.sln b/Oqtane.Updater.sln new file mode 100644 index 000000000..ee633e202 --- /dev/null +++ b/Oqtane.Updater.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28822.285 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{77EECA8C-B58E-469E-B8C5-D543AFC9A654}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitignore = .gitignore + README.md = README.md + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Updater", "Oqtane.Updater\Oqtane.Updater.csproj", "{2E8C6889-37CF-4C8D-88B1-505547F25098}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1FB11796-35DE-4AED-9A52-17733557FCC4} + EndGlobalSection +EndGlobal diff --git a/Oqtane.Upgrade/Oqtane.Upgrade.csproj b/Oqtane.Updater/Oqtane.Updater.csproj similarity index 74% rename from Oqtane.Upgrade/Oqtane.Upgrade.csproj rename to Oqtane.Updater/Oqtane.Updater.csproj index 6a380a5e3..66df439f9 100644 --- a/Oqtane.Upgrade/Oqtane.Upgrade.csproj +++ b/Oqtane.Updater/Oqtane.Updater.csproj @@ -18,11 +18,4 @@ false - - ..\Oqtane.Server\bin\Release\ - - - ..\Oqtane.Server\bin\Debug\ - - diff --git a/Oqtane.Upgrade/Program.cs b/Oqtane.Updater/Program.cs similarity index 81% rename from Oqtane.Upgrade/Program.cs rename to Oqtane.Updater/Program.cs index cb6247045..183f4d991 100644 --- a/Oqtane.Upgrade/Program.cs +++ b/Oqtane.Updater/Program.cs @@ -4,10 +4,14 @@ using System.IO.Compression; using System.Threading; -namespace Oqtane.Upgrade +namespace Oqtane.Updater { class Program { + /// + /// This console application is responsible for extracting the contents of a previously downloaded Oqtane Upgrade package + /// + /// static void Main(string[] args) { // requires 2 arguments - the ContentRootPath and the WebRootPath of the site @@ -22,11 +26,12 @@ static void Main(string[] args) string contentrootfolder = args[0]; string webrootfolder = args[1]; string deployfolder = Path.Combine(contentrootfolder, "Packages"); + string backupfolder = Path.Combine(contentrootfolder, "Backup"); if (Directory.Exists(deployfolder)) { string packagename = ""; - string[] packages = Directory.GetFiles(deployfolder, "Oqtane.Framework.*.nupkg"); + string[] packages = Directory.GetFiles(deployfolder, "Oqtane.Upgrade.*.zip"); if (packages.Length > 0) { packagename = packages[packages.Length - 1]; // use highest version @@ -40,7 +45,7 @@ static void Main(string[] args) File.Copy(Path.Combine(webrootfolder, "app_offline.bak"), Path.Combine(contentrootfolder, "app_offline.htm"), true); } - // get list of files in package + // get list of files in package with local paths List files = new List(); using (ZipArchive archive = ZipFile.OpenRead(packagename)) { @@ -55,18 +60,22 @@ static void Main(string[] args) { try { - // create backup + //clear out backup folder + if (Directory.Exists(backupfolder)) + { + Directory.Delete(backupfolder, true); + } + Directory.CreateDirectory(backupfolder); + + // backup files foreach (string file in files) { - if (File.Exists(file)) + string filename = Path.Combine(backupfolder, file.Replace(contentrootfolder, "")); + if (!Directory.Exists(Path.GetDirectoryName(filename))) { - // remove previous backup if it exists - if (File.Exists(file + ".bak")) - { - File.Delete(file + ".bak"); - } - File.Move(file, file + ".bak"); + Directory.CreateDirectory(Path.GetDirectoryName(filename)); } + File.Copy(file, filename); } // extract files @@ -96,14 +105,7 @@ static void Main(string[] args) if (success) { // clean up backup - foreach (string file in files) - { - if (File.Exists(file + ".bak")) - { - File.Delete(file + ".bak"); - } - } - + Directory.Delete(backupfolder, true); // delete package File.Delete(packagename); } @@ -112,15 +114,11 @@ static void Main(string[] args) // restore on failure foreach (string file in files) { - if (File.Exists(file)) - { - File.Delete(file); - } - if (File.Exists(file + ".bak")) - { - File.Move(file + ".bak", file); - } + string filename = Path.Combine(backupfolder, file.Replace(contentrootfolder, "")); + File.Copy(filename, file); } + // clean up backup + Directory.Delete(backupfolder, true); } } catch (Exception ex) diff --git a/Oqtane.sln b/Oqtane.sln index 70e85123e..f82fa77c1 100644 --- a/Oqtane.sln +++ b/Oqtane.sln @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Client", "Oqtane.Cli EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Shared", "Oqtane.Shared\Oqtane.Shared.csproj", "{19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Upgrade", "Oqtane.Upgrade\Oqtane.Upgrade.csproj", "{2E8C6889-37CF-4C8D-88B1-505547F25098}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oqtane.Test", "Oqtane.Test\Oqtane.Test.csproj", "{823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{77EECA8C-B58E-469E-B8C5-D543AFC9A654}" @@ -38,10 +36,6 @@ Global {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {19D67A9D-3F2E-41BD-80E6-0B50CA83C3AE}.Release|Any CPU.Build.0 = Release|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E8C6889-37CF-4C8D-88B1-505547F25098}.Release|Any CPU.Build.0 = Release|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Debug|Any CPU.Build.0 = Debug|Any CPU {823B556D-8D4E-4BB8-A65A-C4EB5E7E7424}.Release|Any CPU.ActiveCfg = Release|Any CPU