-
Notifications
You must be signed in to change notification settings - Fork 295
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
SqlClient is not usable via transitive reference because build scripts are not transitive. #137
Comments
Hi @anurse The team is looking into it and we'll get back to you soon! |
Hi @anurse , |
Awesome, thanks! |
I'm still seeing this in 1.1.0-preview1.19275.1. Same repro steps as above, adding the NuGet package directly to the exe project resolves the errors. Is this expected to be resolved in 1.1.0-preview1.19275.1 or a later release? |
@mfreim it should be fixed in 1.1.0-preview1.19275.1. What is your NuGet version? |
I'm running NuGet 5.3.0 and Visual Studio 2019 16.3.5 |
@mfreim we tried to run the repro locally again and it's working fine on our end. When you say "adding the NuGet package directly to the exe project" I presume you're talking about the sni package. When you build your project, how does your bin/Release[or Debug] directory look like? Does it have the |
I did some more investigation and found that this has to do with PackageReferences set to PrivateAssets in the solution. If I disable this the issue goes away. To reproduce, use the same steps as the original comment, except add a Directory.Build.props to the solution root with the following contents:
Result I see the specific "Failed to load sni.dll" error when I do this for some unit tests. Note that there's no build error here, this is a runtime error. As far as I can tell this setup with PrivateAssets should be supported. If helpful I can open a new issue since the reproduction steps are slightly different. |
@mfreim The documentation for PrivateAssets is a bit confusing, but the way I read it is that for PrivateAssets "These assets will be consumed but won't flow to the parent project". Meaning you have disabled the mechanism the SqlClient SNI package uses to ensure that SNI dependency objects flow to parent projects. I don't think there is anything the SqlClient or SqlClient SNI packages can do to counter the directive you have defined in your project. |
I cloned the repo: https://github.com/anurse/SqlClientNotTransitive The Exception message is "Error: Could not load file or assembly 'Microsoft.Data.SqlClient Version=1.10.19324.4....' I'm expecting the consumer to have the dependency, am I missing something? I'm on Visual Studio 2019 v16.1.3 with Nuget Package Manager 5.1 |
I verified this works in WPF .NET Core project and not with WPF .NET Framework, would recommend opening issue with WPF Team (dotnet/wpf). Although they're .NET Core, I'm sure they can answer better on how to get it working with WPF .NET Framework too! From our side, it doesn't look like a limitation. |
thank you. we will look into migrating to core then.
Sent: Thursday, December 12, 2019 at 6:02 PM
From: "Cheena Malhotra" <notifications@github.com>
To: dotnet/SqlClient <SqlClient@noreply.github.com>
Cc: SteveFoo <codefoo@mail.com>, Mention <mention@noreply.github.com>
Subject: Re: [dotnet/SqlClient] SqlClient is not usable via transitive reference because build scripts are not transitive. (#137)
@stevefoo
I verified this works in WPF .NET Core project and not with WPF .NET Framework, would recommend opening issue with WPF Team (dotnet/wpf).
Although they're .NET Core, I'm sure they can answer better on how to get it working with WPF .NET Framework too! From our side, it doesn't look like a limitation.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@stevefoo @cheenamalhotra Any news with projects WPF .NET Framework? |
Furthermore I have to say that I am building a DesktopBridge WPF application. There, in the .appxupload package the sni.dll file is missing. |
The Microsoft.Data.SqlClient package, as of version
1.0.19189.1-Preview
, carries MSBuild targets that need to run when building .NET Framework apps in order to copysni.dll
. However, these targets are not "transitive" which means if you reference SqlClient indirectly through a library, you don't get those build targets and end up with errors.It's my understanding that this can be solved by using a
buildTransitive/
folder instead ofbuild/
. See the NuGet spec on the subject for more info. This was released in NuGet 5.0, so it does mean the package will require NuGet 5.0 or higher if it uses this feature.Users can work around this issue by adding a direct dependency to
Microsoft.Data.SqlClient
but this is not the standard or expected practice in projects using the modern<PackageReference>
syntax, which we do support for .NET Framework packages.Repro steps
Example repo: https://github.com/anurse/SqlClientNotTransitive
dotnet restore
dotnet run --project ./Consumer
Detailed steps (from scratch instead of using the repo)
cd
to some empty directorydotnet new sln
dotnet new console --name Consumer
dotnet sln add ./Consumer
dotnet new classlib --name Library
dotnet sln add ./Library
<PackageReference>
toMicrosoft.Data.SqlClient 1.0.19189.1-Preview
inLibrary
.<ProjectReference>
toLibrary
inConsumer
Consumer.csproj
to targetnet471
Connector.cs
toLibrary
:Program.cs
inConsumer
to:dotnet run --project ./Consumer
Expected Behavior
This presumes the connection string above is valid for your environment. Even if it isn't you should at least see a connection failure message instead of what you end up getting.
Actual Behavior
The build output from
Consumer
does indeed show nosni.dll
:The text was updated successfully, but these errors were encountered: