Improvements to System Update
This commit is contained in:
parent
bcc33af52b
commit
94f0bdcce9
@ -12,7 +12,7 @@
|
|||||||
@if (_upgradeavailable)
|
@if (_upgradeavailable)
|
||||||
{
|
{
|
||||||
<ModuleMessage Type="MessageType.Info" Message="Select The Upgrade Button To Install a New Framework Version"></ModuleMessage>
|
<ModuleMessage Type="MessageType.Info" Message="Select The Upgrade Button To Install a New Framework Version"></ModuleMessage>
|
||||||
@("Framework") @_package.Version <button type="button" class="btn btn-success" @onclick=@(async () => await Download(Constants.PackageId, Constants.Version))>Upgrade</button>
|
<button type="button" class="btn btn-success" @onclick=@(async () => await Download(Constants.PackageId, @_package.Version))>Upgrade To @_package.Version</button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
DEL "*.nupkg"
|
del "*.nupkg"
|
||||||
dotnet clean -c Release ..\Oqtane.sln
|
dotnet clean -c Release ..\Oqtane.sln
|
||||||
dotnet build -c Release ..\Oqtane.sln
|
dotnet build -c Release ..\Oqtane.sln
|
||||||
|
dotnet publish ..\Oqtane.Server\Oqtane.Server.csproj /p:Configuration=Release
|
||||||
nuget.exe pack Oqtane.Framework.nuspec
|
nuget.exe pack Oqtane.Framework.nuspec
|
||||||
nuget.exe pack Oqtane.Client.nuspec
|
nuget.exe pack Oqtane.Client.nuspec
|
||||||
nuget.exe pack Oqtane.Server.nuspec
|
nuget.exe pack Oqtane.Server.nuspec
|
||||||
|
@ -186,6 +186,7 @@ namespace Oqtane.Infrastructure
|
|||||||
packageversion = node.InnerText;
|
packageversion = node.InnerText;
|
||||||
}
|
}
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,28 +203,26 @@ namespace Oqtane.Infrastructure
|
|||||||
private void FinishUpgrade()
|
private void FinishUpgrade()
|
||||||
{
|
{
|
||||||
// check if upgrade application exists
|
// check if upgrade application exists
|
||||||
|
string Upgrader = "Oqtane.Upgrade.dll";
|
||||||
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
string folder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||||
if (folder == null || !File.Exists(Path.Combine(folder, "Oqtane.Upgrade.exe"))) return;
|
if (folder == null || !File.Exists(Path.Combine(folder, Upgrader))) return;
|
||||||
|
|
||||||
// run upgrade application
|
// run upgrade application
|
||||||
var process = new Process
|
using (var process = new Process())
|
||||||
{
|
{
|
||||||
StartInfo =
|
process.StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = Path.Combine(folder, "Oqtane.Upgrade.exe"),
|
WorkingDirectory = folder,
|
||||||
Arguments = "\"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"",
|
FileName = "dotnet",
|
||||||
ErrorDialog = false,
|
Arguments = Path.Combine(folder, Upgrader) + " \"" + _environment.ContentRootPath + "\" \"" + _environment.WebRootPath + "\"",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
|
ErrorDialog = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardOutput = false,
|
RedirectStandardOutput = false,
|
||||||
RedirectStandardError = false
|
RedirectStandardError = false
|
||||||
}
|
};
|
||||||
|
process.Start();
|
||||||
};
|
};
|
||||||
process.Start();
|
|
||||||
process.Dispose();
|
|
||||||
|
|
||||||
// stop application so upgrade application can proceed
|
|
||||||
RestartApplication();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestartApplication()
|
public void RestartApplication()
|
||||||
|
@ -22,9 +22,6 @@
|
|||||||
<Content Remove="wwwroot\Modules\Templates\**" />
|
<Content Remove="wwwroot\Modules\Templates\**" />
|
||||||
<EmbeddedResource Remove="wwwroot\Modules\Templates\**" />
|
<EmbeddedResource Remove="wwwroot\Modules\Templates\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="Scripts\Tenant.01.00.02.01.sql" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Scripts\Master.00.00.00.00.sql" />
|
<EmbeddedResource Include="Scripts\Master.00.00.00.00.sql" />
|
||||||
<EmbeddedResource Include="Scripts\Master.00.09.00.00.sql" />
|
<EmbeddedResource Include="Scripts\Master.00.09.00.00.sql" />
|
||||||
@ -53,4 +50,12 @@
|
|||||||
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
||||||
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
|
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
<ItemGroup>
|
||||||
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.dll" />
|
||||||
|
<UpgradeFiles Include="$(ProjectDir)bin\Release\netcoreapp3.1\Oqtane.Upgrade.runtimeconfig.json" />
|
||||||
|
<TemplateFiles Include="$(ProjectDir)wwwroot\Modules\Templates\**\*.*" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
|
||||||
|
<Copy SourceFiles="@(UpgradeFiles)" DestinationFiles="@(UpgradeFiles->'$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
||||||
|
<Copy SourceFiles="@(TemplateFiles)" DestinationFiles="@(TemplateFiles->'$(PublishDir)wwwroot\Modules\Templates\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
||||||
|
</Target></Project>
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<br /><br /><h1 align="center">Please Wait... Upgrade In Progress....</h1>
|
<br /><br />
|
||||||
<img src="https://www.oqtane.org/Portals/0/oqtane-black.png" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);" />
|
<h1 align="center">Please Wait... Upgrade In Progress....</h1>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -11,12 +11,13 @@ namespace Oqtane.Upgrade
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
// requires 2 arguments - the ContentRootPath and the WebRootPath of the site
|
||||||
|
|
||||||
// for testing purposes set Oqtane.Upgrade as startup project and modify values below
|
// for testing purposes set Oqtane.Upgrade as startup project and modify values below
|
||||||
//Array.Resize(ref args, 2);
|
//Array.Resize(ref args, 2);
|
||||||
//args[0] = @"C:\yourpath\oqtane.framework\Oqtane.Server";
|
//args[0] = @"C:\yourpath\oqtane.framework\Oqtane.Server";
|
||||||
//args[1] = @"C:\yourpath\oqtane.framework\Oqtane.Server\wwwroot";
|
//args[1] = @"C:\yourpath\oqtane.framework\Oqtane.Server\wwwroot";
|
||||||
|
|
||||||
// requires 2 arguments - the contentrootpath and the webrootpath of the site
|
|
||||||
if (args.Length == 2)
|
if (args.Length == 2)
|
||||||
{
|
{
|
||||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
@ -47,14 +48,19 @@ namespace Oqtane.Upgrade
|
|||||||
{
|
{
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
{
|
{
|
||||||
switch (Path.GetDirectoryName(entry.FullName).Split('\\')[0])
|
string filename = Path.GetFileName(entry.FullName);
|
||||||
|
if (!string.IsNullOrEmpty(filename))
|
||||||
{
|
{
|
||||||
case "lib":
|
// use top level folder to determine location to extract files
|
||||||
files.Add(Path.Combine(binfolder, Path.GetFileName(entry.FullName)));
|
switch (Path.GetDirectoryName(entry.FullName).Split(Path.DirectorySeparatorChar)[0])
|
||||||
break;
|
{
|
||||||
case "wwwroot":
|
case "lib":
|
||||||
files.Add(Path.Combine(webrootfolder, entry.FullName.Replace("wwwroot/", "").Replace("/","\\")));
|
files.Add(Path.Combine(binfolder, filename));
|
||||||
break;
|
break;
|
||||||
|
case "wwwroot":
|
||||||
|
files.Add(Path.Combine(webrootfolder, entry.FullName.Replace("wwwroot/", "").Replace("/", Path.DirectorySeparatorChar.ToString())));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,74 +68,97 @@ namespace Oqtane.Upgrade
|
|||||||
// ensure files are not locked
|
// ensure files are not locked
|
||||||
if (CanAccessFiles(files))
|
if (CanAccessFiles(files))
|
||||||
{
|
{
|
||||||
// create backup
|
|
||||||
foreach (string file in files)
|
|
||||||
{
|
|
||||||
if (File.Exists(file + ".bak"))
|
|
||||||
{
|
|
||||||
File.Delete(file + ".bak");
|
|
||||||
}
|
|
||||||
File.Move(file, file + ".bak");
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract files
|
|
||||||
bool success = true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
// create backup
|
||||||
{
|
|
||||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
|
||||||
{
|
|
||||||
string filename = "";
|
|
||||||
switch (Path.GetDirectoryName(entry.FullName).Split('\\')[0])
|
|
||||||
{
|
|
||||||
case "lib":
|
|
||||||
filename = Path.Combine(binfolder, Path.GetFileName(entry.FullName));
|
|
||||||
break;
|
|
||||||
case "wwwroot":
|
|
||||||
filename = Path.Combine(webrootfolder, entry.FullName.Replace("wwwroot/", "").Replace("/", "\\"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (files.Contains(filename))
|
|
||||||
{
|
|
||||||
entry.ExtractToFile(filename, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// an error occurred extracting a file
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
// clean up backup
|
|
||||||
foreach (string file in files)
|
|
||||||
{
|
|
||||||
if (File.Exists(file + ".bak"))
|
|
||||||
{
|
|
||||||
File.Delete(file + ".bak");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete package
|
|
||||||
File.Delete(packagename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// restore on failure
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
// remove previous backup if it exists
|
||||||
|
if (File.Exists(file + ".bak"))
|
||||||
|
{
|
||||||
|
File.Delete(file + ".bak");
|
||||||
|
}
|
||||||
|
File.Move(file, file + ".bak");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract files
|
||||||
|
bool success = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||||
|
{
|
||||||
|
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||||
|
{
|
||||||
|
string filename = Path.GetFileName(entry.FullName);
|
||||||
|
if (!string.IsNullOrEmpty(filename))
|
||||||
|
{
|
||||||
|
// use top level folder to determine location to extract files
|
||||||
|
switch (Path.GetDirectoryName(entry.FullName).Split(Path.DirectorySeparatorChar)[0])
|
||||||
|
{
|
||||||
|
case "lib":
|
||||||
|
filename = Path.Combine(binfolder, filename);
|
||||||
|
break;
|
||||||
|
case "wwwroot":
|
||||||
|
filename = Path.Combine(webrootfolder, entry.FullName.Replace("wwwroot/", "").Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (files.Contains(filename))
|
||||||
|
{
|
||||||
|
entry.ExtractToFile(filename, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// an error occurred extracting a file
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
// clean up backup
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if (File.Exists(file + ".bak"))
|
||||||
|
{
|
||||||
|
File.Delete(file + ".bak");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete package
|
||||||
|
File.Delete(packagename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Update Not Successful: Error Extracting Files From Package");
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File.Move(file + ".bak", file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Update Not Successful: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Upgrade Not Successful: Some Files Are Locked");
|
||||||
}
|
}
|
||||||
|
|
||||||
// bring the app back online
|
// bring the app back online
|
||||||
@ -138,7 +167,19 @@ namespace Oqtane.Upgrade
|
|||||||
File.Delete(Path.Combine(contentrootfolder, "app_offline.htm"));
|
File.Delete(Path.Combine(contentrootfolder, "app_offline.htm"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Framework Upgrade Package Not Found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Framework Upgrade Folder " + deployfolder + " Does Not Exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Missing ContentRootPath and WebRootPath Parameters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +199,15 @@ namespace Oqtane.Upgrade
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
stream = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.None);
|
if (File.Exists(filepath))
|
||||||
locked = false;
|
{
|
||||||
|
stream = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||||
|
locked = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch // file is locked by another process
|
catch // file is locked by another process
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user