Closed pascallapradebrite4 closed 3 years ago
You have to add ResolutionPath static parameter to point the folder of the MySqlConnector driver.
@Thorium Thanks for your support!
However, our goal is to have a single binary file that we can put on any computer and just run it, not to have to go and install MySqlConnector drivers in a predetermined folder that we can then hardcode statically. I can understand then if this goal is simply not supported by the project.
What I know, simply, is that we were able to have a single executable deployed for months, without providing the ResolutionPath
, and that worked fine, so even without us providing the path, the .NET extraction method for single executables made everything work. Now that assemblies are instead loaded in memory, this behavior of SQLProvider+MySqlConnector+PublishSingleFile is broken, and ResolutionPath
is not a solution for us (though at least there will be a workaround on the .NET side if this cannot be fixed here).
The ResolutionPath is also used on compilation time, and for intellisense in Visual Studio (or whatever IDE you are using). So that has to be there for the compiler.
On runtime, I guess we could just add the probing of the driver to the bundled-files inside the single file, however that is done... Do you know how? PRs accepted. :-)
@Thorium Interestingly, we realized that the ResolutionPath
didn't need to be specified at compile time, at least with the .NET 5 SDK. We haven't tried with .NET Core 3.1, so we do not know if this is a change in how the compiler resolves dependencies or something else. We do, however, specify it in the code for developers, to get IDE support as you mentioned. We simply use a compiler directive to not give the ResolutionPath
when we're actually building, since that allowed us to use the single file until recently.
I'm not familiar with how the new single file works with .NET 5, but if it's simply loading all the assemblies in memory, I'm pretty sure there's a way to get it without too much changes being needed in the current resolution code, simply trying to load it from there instead than from a path.
I'll try to work on this on my personal time to see if I can figure out how to get it working! Thanks again!
Thanks, released in NuGet package 1.1.93
And I can confirm the fix works with our app. Thanks!
Describe the bug Executables produced with .NET 5 SDK RC 1 crash when built with the
PublishSingleFile
switch. The stacktrace produced is the following:To Reproduce Steps to reproduce the behavior:
dotnet new console --language=f# -o UnableToResolveAssemblies
dotnet add package MySqlConnector
anddotnet add package SqlProvider
[]
let ConnectionString =
// Change Database, User and Password for compile-time type safety checks.
"Server=localhost;Database=database;User=user;Password=password;"
type internal DbProvider = SqlDataProvider< Common.DatabaseProviderTypes.MYSQL, ConnectionString
let getConnectionString = sprintf "Server=%s;Database=%s;User=%s;Password=%s"
[]
let main argv =
match argv with
| [|server; database; user; password|] ->
// Provide the server, database, user and password at runtime if it differs
// between your build machine and your target machine.
DbProvider.GetDataContext (getConnectionString server database user password)
|> ignore
| _ ->
DbProvider.GetDataContext ()
|> ignore
0