Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.Data.SqlClient v 5.2.0: NET 8.0 assembly in NET 6.0 dll? #2535

Closed
Thorium opened this issue May 25, 2024 · 15 comments · Fixed by #2550
Closed

Microsoft.Data.SqlClient v 5.2.0: NET 8.0 assembly in NET 6.0 dll? #2535

Thorium opened this issue May 25, 2024 · 15 comments · Fixed by #2550

Comments

@Thorium
Copy link

Thorium commented May 25, 2024

I was debugging a few hours why I get weird "Microsoft.Data.SqlClient is not supported on this platform."

There is something fishy going on with the v5.2.0:

image

@arellegue
Copy link
Contributor

arellegue commented May 27, 2024

Before we can begin investigation, could you please provide a step how to reproduce the issue, what is the environment operating system and also provide a sample reproduction program, please? Have you tried deleting the nuget package cache for .Net 6.0?

@kf-gonzalez2 kf-gonzalez2 added ℹ️ Needs more Info Waiting on additional information ⏳ Waiting for Customer We're waiting for your response :) and removed untriaged labels May 28, 2024
@Thorium
Copy link
Author

Thorium commented Jun 4, 2024

This seems to be the case with the current version (5.2.1) too.

To reproduce the issue:

  1. Delete any Microsoft.Data.SqlClient from your .nuget-cache, e.g. C:\Users\(yourname)\.nuget\packages\microsoft.data.sqlclient
  2. Install ILSpy that can tell the file versions, choco install ilspy
  3. Create a .net6.0 library: dotnet new console --framework net6.0
  4. Add reference to download the nuget package: dotnet add package Microsoft.Data.SqlClient
  5. Go to your nuget cache .net6.0 folder, e.g. C:\Users\(yourname)\.nuget\packages\microsoft.data.sqlclient\5.2.1\lib\net6.0
  6. Open the Microsoft.Data.SqlClient.dll with ILSpy and observe it's .NET 8.0 version in .NET 6.0 path.

The environment shouldn't matter, because the issue is the package, however as general info, tested with:

  • NuGet Version: 6.7.0.127
  • My machine has Windows 11 Pro (23H2) with dotnet 6.0.423 and 8.0.206

@JRahnama
Copy link
Member

JRahnama commented Jun 4, 2024

Hi @Thorium, can you add a global.json file in the root repository and set content as below and try to see the results.
One possibility in my opinion is targeting net6 with Net8 SDK

{
  "sdk": {
    "version": "<version goes here. such as 6.0.300",
  }
}

@Thorium
Copy link
Author

Thorium commented Jun 4, 2024

The issue is Microsoft.Data.SqlClient NuGet package: The package has multiple dlls in libs-folder, for different target frameworks, e.g. net6.0 and net8.0. But why is there .Net 8 dll in net6.0 folder?

If net6.0 is not supported by Microsoft.Data.SqlClient, then fine, just remove the libs/net6.0 path from the Nuget package (and from target frameworks).

@JRahnama
Copy link
Member

JRahnama commented Jun 5, 2024

The issue was coming from the fact that .AssemblyAttributes was put in netcore folder under path of SqlClient\artifacts\Project\obj\Debug.AnyCPU\Microsoft.Data.SqlClient\netcore and that was used for net8 and net6 with Net8 version set as global.

Thanks for catching this @Thorium. I will send you package from a build of our CI pipeline to confirm that the fix has worked.

@JRahnama
Copy link
Member

JRahnama commented Jun 5, 2024

@Thorium can you test below unofficial package to see if that has issue addressed in it.
Microsoft.Data.SqlClient.6.0.0-pull.115703.zip

@Thorium
Copy link
Author

Thorium commented Jun 5, 2024

Yes, this package has it correct.

@kf-gonzalez2 kf-gonzalez2 removed ℹ️ Needs more Info Waiting on additional information ⏳ Waiting for Customer We're waiting for your response :) labels Jun 11, 2024
@kf-gonzalez2 kf-gonzalez2 linked a pull request Jun 11, 2024 that will close this issue
@kf-gonzalez2
Copy link

Closing as PR to fix this has been merged

@Miloky
Copy link

Miloky commented Aug 29, 2024

Having the same issue with .net8 and azure-functions on the azure portal.
Any ideas how to fix this?

@JRahnama
Copy link
Member

@Miloky what version of M.D.SqlClient are you using?

@Miloky
Copy link

Miloky commented Aug 29, 2024

@JRahnama tried different versions:
6.0.0-preview1.24240.8
5.2.0
5.1.3

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 29, 2024

5.2.2 ??

@arellegue arellegue reopened this Aug 29, 2024
@JRahnama
Copy link
Member

5.2.0, and 5.1.3 are problamtic ones, try testing with 5.1.6 and 5.2.2. I will check 6.0.0-preview1.24240.8

@JRahnama
Copy link
Member

Also, making a repro is same as the one provided in original issue?

@arellegue
Copy link
Contributor

@Miloky The original issue has been addressed, confirmed as working, and backported to version 5.2.2. If your issue is different from this one, please open a new GitHub issue with detailed steps to reproduce it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

6 participants