fix .NET upgrade issue related to database provider packages
This commit is contained in:
parent
ffae6e269b
commit
116542d8e4
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -16,7 +16,7 @@ _ReSharper.Caches
|
|||
Oqtane.Server/appsettings.json
|
||||
Oqtane.Server/Data
|
||||
|
||||
/Oqtane.Server/Properties/PublishProfiles/FolderProfile.pubxml
|
||||
Oqtane.Server/Properties/PublishProfiles/FolderProfile.pubxml
|
||||
Oqtane.Server/Content
|
||||
Oqtane.Server/Packages
|
||||
Oqtane.Server/wwwroot/Content
|
||||
|
|
|
@ -38,6 +38,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg.bak" />
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -39,6 +39,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg.bak" />
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg.bak" />
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyPackage" AfterTargets="Pack">
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg.bak" />
|
||||
<Copy SourceFiles="$(OutputPath)..\$(PackageName)" DestinationFiles="..\Oqtane.Server\wwwroot\Packages\$(MSBuildProjectName).nupkg" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -215,39 +215,14 @@ namespace Oqtane.Infrastructure
|
|||
|
||||
try
|
||||
{
|
||||
bool installPackages = false;
|
||||
|
||||
// iterate database packages in installation folder
|
||||
var packagesFolder = new DirectoryInfo(Path.Combine(_environment.ContentRootPath, Constants.PackagesFolder));
|
||||
foreach (var package in packagesFolder.GetFiles("*.nupkg.bak"))
|
||||
{
|
||||
// determine if package needs to be upgraded or installed
|
||||
bool upgrade = System.IO.File.Exists(package.FullName.Replace(".nupkg.bak",".log"));
|
||||
if (upgrade || package.Name.StartsWith(Utilities.GetAssemblyName(install.DatabaseType)))
|
||||
{
|
||||
var packageName = Path.Combine(package.DirectoryName, package.Name);
|
||||
packageName = packageName.Substring(0, packageName.IndexOf(".bak"));
|
||||
package.MoveTo(packageName, true);
|
||||
installPackages = true;
|
||||
}
|
||||
}
|
||||
if (installPackages)
|
||||
{
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var installationManager = scope.ServiceProvider.GetRequiredService<IInstallationManager>();
|
||||
installationManager.InstallPackages();
|
||||
}
|
||||
}
|
||||
|
||||
// load the installation database type (if necessary)
|
||||
if (Type.GetType(install.DatabaseType) == null)
|
||||
{
|
||||
var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
var assembliesFolder = new DirectoryInfo(assemblyPath);
|
||||
var assemblyFile = new FileInfo($"{assembliesFolder}/{Utilities.GetAssemblyName(install.DatabaseType)}.dll");
|
||||
AssemblyLoadContext.Default.LoadOqtaneAssembly(assemblyFile);
|
||||
}
|
||||
//if (Type.GetType(install.DatabaseType) == null)
|
||||
//{
|
||||
// var assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
// var assembliesFolder = new DirectoryInfo(assemblyPath);
|
||||
// var assemblyFile = new FileInfo($"{assembliesFolder}/{Utilities.GetAssemblyName(install.DatabaseType)}.dll");
|
||||
// AssemblyLoadContext.Default.LoadOqtaneAssembly(assemblyFile);
|
||||
//}
|
||||
|
||||
result.Success = true;
|
||||
}
|
||||
|
|
|
@ -52,39 +52,22 @@ namespace Oqtane.Infrastructure
|
|||
Directory.CreateDirectory(sourceFolder);
|
||||
}
|
||||
|
||||
// move packages to secure /Packages folder
|
||||
foreach (var folderName in "Modules,Themes,Packages".Split(","))
|
||||
{
|
||||
string folder = Path.Combine(webRootPath, folderName);
|
||||
// move core framework distribution packages to secure /Packages folder
|
||||
string folder = Path.Combine(webRootPath, "Packages");
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(folder, "*.nupkg*"))
|
||||
foreach (var file in Directory.GetFiles(folder, "*.nupkg"))
|
||||
{
|
||||
var destinationFile = Path.Combine(sourceFolder, Path.GetFileName(file));
|
||||
if (File.Exists(destinationFile))
|
||||
{
|
||||
File.Delete(destinationFile);
|
||||
}
|
||||
|
||||
if (destinationFile.ToLower().EndsWith(".nupkg.bak"))
|
||||
{
|
||||
// leave a copy in the current folder as it is distributed with the core framework
|
||||
File.Copy(file, destinationFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move to destination
|
||||
File.Move(file, destinationFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
}
|
||||
|
||||
// iterate through Nuget packages in source folder
|
||||
// install Nuget packages in secure Packages folder
|
||||
foreach (string packagename in Directory.GetFiles(sourceFolder, "*.nupkg"))
|
||||
{
|
||||
try
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user