Copy local on implicit references?

So Dapper has a reference to System.Data.SqlClient and thats why it builds :slight_smile:

So I got my webapplication building in Fire against mono. I also changed the data access assembly to be .net standard 2. Its using the system.data.sqlclient nuget with copy local disabled. It runs ok on my mac but when I deploy the assemblies to a windows machine I get this error

Could not load file or assembly ‘System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

Based on this https://apisof.net/catalog/System.Data.SqlClient.SqlConnection

That version only exists in core.

There must be more to this :slight_smile:

Ok I think this should be it. Ive turned off copy local on my .net standard library references and added them to the exe/web application. That works on mono and windows.

I’d say yes, but not as Copy Local.

I tried that and Im still getting FileNotFound on my standard library.

if it fails even with copy local, I wonder if thats coz as you say Dapper also pulls it in and that makes it Copy Local. Do you have the .dll next to your .exe? If so, what happens if you make Dapper non-copy-local too? does it fail on missing that .dll (or does the .NET Core runtime retrieve that as needed via the .deps)?

Yes, of curse you need that?

Hmm. So the .NET Standard 2 assembly links 4.5.0.0 of that dll, and thats not supported by the full .NET Framework on Windows? odd.

Odd that that would fix the version # mixup, but I’ll take the win :wink:

On the nuget page

These are the references for core

Should I see those listed in Fire ?

Currently I dont but I am seeing them listed in visual studio for mac.

For .net core Im still getting a PlatformNotSupported Exception and the equivalent code in visual studio works fine.

Cheers,
John

The Add References dialog (right now) only lists whats in the local repository and the cache. see Adding a Gradle repository for "Add Reference" dialog for a more detailed discussion of this.

Sorry I wasnt trying to add this from nuget. I was using the nuget page to see what references the netcore version had. Comparing nuget page, visual studio and Fire, I was wondering why Fire didnt list those as dependencies where as VS does?

Oh. you mean they don’t get pulled in as indirect package references? lets see…

What version of .NET Core are you building for?

System.Data.SqlClient.nuspec lists no dependencies for <group targetFramework=".NETCoreApp2.2">

Yes.

I was wondering if I could just copy the resulting dlls from a working .net core console but it doesnt seem to be as easy as that because I still get platform not supported from Elements.

I did a dotnet publish from the visual studio console and it looked to be copying the references.

Its 4.6.0

And the ones for 2.1 and below have “exclude="Compile" />” which is why they don’t get added.

Seems correct to me. Does anything actually not work?

Regarding the exclude=“Compile”

If I do “dotnet run project.csproj” and look at the debug folder it just contains the console and the referenced .net standard assembly I created.

dotnet publish project.csproj contains those references.

Im under the impression the only thing we can do with the dotnet app is run the resulting application so is what Im doing more like a publish ?

Yes I’m not expecting to get the PlatformNotSupported exception.

I can send you my visual studio sample.

I’m confused, sorry…

I think there is still a problem with referencing system.data.sqlclient inside a .net core console app. With elements its results in a PlatformNotSupported Exception whereas with visual studio for mac I can open a connection to a database.

Ok, but we had all that sorted? What changed? Can I get a new testcase? thanx!

mono using a standard library, which referenced sqclient was sorted but not core with sqlclient.

SimpleDataConsoleApplication.zip (190.2 KB)
CSharpDataConsoleApplication.zip (487.4 KB)
I can dotnet run the charpconsole and it will run without exceptions.
The other one fails with PlatformNotSupported.
Cheers,
John

image

Didn’t we determine that CopyLocal for that reference is what causes the issue?

Without Copy Local, I doin get a file out found, which is odd, bt I determined it needs additional entries in the .deps.json for those.nI need to look into how to fix that, but not for today’s build, sorry :(.

Attached is the good vs bad .deps.json so yo can see whats missing…

SimpleDataConsoleApplication.deps-bad-as-generated.json (4.3 KB)
SimpleDataConsoleApplication.deps-good.json (8.0 KB)

Thanks, logged as bugs://81666: EBuild: .NET Core: additional “runtime” entries needed for SQLClient.dll

Thanks.

Copy local is only a problem when you reference a standard library. In that case all the references in the standard library should be turned off.