chucknorris / roundhouse

RoundhousE is a Database Migration Utility for .NET using sql files and versioning based on source control
http://projectroundhouse.org
920 stars 247 forks source link

.NET 5/6 file copy error #446

Open rpopovych opened 2 years ago

rpopovych commented 2 years ago

When using RH library in .NET 5/6, the following error happens:

Unable to copy ./Scripts/db1/OneTime/YYYY-MM-DD-Initials-JiraTicket-1-SampleRoleCreation.sql to ./Scripts/db1/OneTime. 
System.DllNotFoundException: Unable to load shared library 'kernel32' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libkernel32: cannot open shared object file: No such file or directory
   at roundhouse.infrastructure.filesystem.DotNetFileSystemAccess.CopyFileA(String lpExistingFileName, String lpNewFileName, Int32 bFailIfExists)
   at roundhouse.infrastructure.filesystem.DotNetFileSystemAccess.file_copy_unsafe(String source_file_name, String destination_file_name, Boolean overwrite_the_existing_file)
   at roundhouse.runners.RoundhouseMigrationRunner.copy_to_change_drop_folder(String sql_file_ran, Folder migration_folder)
   at roundhouse.runners.RoundhouseMigrationRunner.traverse_files_and_run_sql(String directory, Int64 version_id, MigrationsFolder migration_folder, EnvironmentSet migrating_environment_set, String repository_version, ConnectionType connection_type)

The issue is here: https://github.com/chucknorris/roundhouse/blob/0f17f6967a1b3a5bb1d1b63f3574a7e8ba3e1294/product/roundhouse.core/infrastructure/filesystem/DotNetFileSystemAccess.cs#L20

There is handing for Mono & .NET Core, but with .NET 5 the Core naming has been dropped.

I see this deliberation here, but has anyone tried to at least support use of libraries in .NET 6? I don't believe that would require upgrading the project to .NET 6 and it might be just this one place to fix.

.NET 3.1 End of Support is at the end of 2022: https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

kbialkowski commented 2 years ago

@rpopovych Hi got same error When trying to run under the docker container with .NET 5 I get image

Did you manage to find solution?

kbialkowski commented 2 years ago

@rpopovych The workaround I found is to install 3.1 runtime in the container. Add this to your dockerfile

COPY --from=mcr.microsoft.com/dotnet/runtime:3.1.31-buster-slim /usr/share/dotnet/shared /usr/share/dotnet/shared