You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft.Data.SqlClient.SNI not deployed along with ClickOnce #441
The nuget package Microsoft.EntityFrameworkCore.SqlServer v3.1.2 needs the reference to
Microsoft.Data.SqlClient.SNI v1.1.1. The SNI package is automatically added to the project when referencing the SqlServer v3.1.2 which is expected. When building the solution, the directories x64 and x86 are created as expected and everything works fine when started from the \bin\debug and \bin\release folders.
To reproduce the issue
When deploying the solution using ClickOnce, both directories (x86 and x64) are not included so that the application does not work anymore as it lacks the SNI.dll reference. I cannot see a way to solve the issue since I cannot include the reference under
ProjectName > Publish > Application Files...
I saw this (fixed) issue but for ClickOnce, it does not seem to be fixed.
Expected behavior
When deploying the application using ClickOnce, the x64 and x86 directories including the native SNI.dll libraries are copied to the respective version directory inside the "Application Files" directory and referenced properly.
Are you using msbuild /target:publish to publish the same or some other tool?
Could you try using msbuild if not already and let us know if that works?
If not, please provide us a repro version of your ClickOnce application for us to investigate targets.
Build project (debug or release)
Check bin/debug folder. It contains the two folders x64 and x86 with the SNI.dll in each folder.
If you publish same project (using visual studio 2019 (16.4.5)) the published folder looks like this:
Reacted by Simon Amelunxen, Ignacio - Innovo and Kristian
Thank you very much for your Quick reply. I am currently on vacation ehich is the reason for my bad response time.
According to your question: I am using the ClickOnce publish mechanism right from VS (I guess VS2017). Since I am on vacation I cannot try what you suggested right now. However:
Build project (debug or release)
Check bin/debug folder. It contains the two folders x64 and x86 with the SNI.dll in each folder.
If you publish same project (using visual studio 2019 (16.4.5)) the published folder looks like this:
This exactly depicts the issue. Thank you very much.
I am currently using a workaround by adding both directories as content to the WPF App. This way, they are deployed along with the application. This works but is not ideal.
I am currently using a workaround by adding both directories as content to the WPF App. This way, they are deployed along with the application. This works but is not ideal.
I was able to reproduce the problem and saw that the SNI files were copied to Publish directory instead of deployment folder. The support for Publish Dir is for Dotnet SDK applications but there is no internal deployment folder so this was not covered.
I was able to resolve this by adding below target to csproj:
<TargetName="_CopySNIFilesToPublishFolder"AfterTargets="_CopyFilesToPublishFolder"Condition="'$(CopySNIFiles)' != 'false' And '$(_CopySNIFilesToPublishFolder)' != 'false' And '$(_DeploymentApplicationDir)' != '' And HasTrailingSlash('$(_DeploymentApplicationDir)') And Exists('$(_DeploymentApplicationDir)')"Inputs="@(SNIFiles)"Outputs="@(SNIFiles -> '$(_DeploymentApplicationDir)%(RecursiveDir)%(Filename)%(Extension)')">
<CopySourceFiles="@(SNIFiles)"DestinationFiles="@(SNIFiles -> '$(_DeploymentApplicationDir)%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
Below is the output:
Let me know if you can get it working too, and we will plan to address this change in next SNI version.
I can confirm it copies the directories and the dlls and pdbs…… and it gives a warning: "Warning: Publishing file 'SNI.pdb' that may contain sensitive or proprietary information."
In a clickonce-publish-scenario it should be sni.dll.deploy and no pdb published.
In a clickonce-publish-scenario it should be sni.dll.deploy and no pdb published.
I agree. I think it should apply to all "Publish" targets as symbols are not needed during publish.
I've handled that internally and will be taken care of.
I will try the workaround you provided, @cheenamalhotra once I get back to work next Monday. However, according to @cfaagaard it actually works. I guess there is no need for me to additionally verify it.
If I understand you correctly, with SqlClient v2.0.0, your <Target> workaround won't be necessary anymore?
I must add the fact that the provided workaround indeed copies the files as expected. However: While installing the latest version of the application, it does not seem to copy the files to where the whole application is deployed locally hence the workaround does not work for ClickOnce applications that are installed locally upon starting the setup.exe or the .application file in the output directory.
@Siam1205
Exactly same behaviour for me deployed but not copied locally !
The only workaround I found is copying manually the x86 & x64 folders from the build to the deployed setup (bypassing clickonce updater ...). How to fix this properly please @cheenamalhotra ?
sorry that I did not respond to you for so long and thank you for continuing to find a solution for the issue.
The respective project still uses the workaround I mentioned on Feb 25.
I read briefly through your discussion but I wonder what the best solution now looks like. So what's the best way to get the ClickOnce deployment working properly without manipulating too much the project itself too much?
Nevertheless, I cannot check whether the ClickOnce-deployed solution works because I've encountered new problems after upgrading the packages. When I start the application, at some point I cannot access the database because of a new exception that I've never seen before:
Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Threading.Tasks.Extensions.
Starting with v2.0.0 of Microsoft.Data.SqlClient, you should not have issues with Clickonce application deployments.
Please upgrade and let us know if you face any issues! A new issue with repro in that case would be ideal.
This seems to be not solved or at least I can't make it work properly even trying the many workaround proposed here.
My project is .NET 5 using EF Core 5.0. The dependency uses is Microsoft.Data.SqlClient 2.0.1 and the files are not deployed with ClickOnce.
The problem is the same, can't find the Microsoft.Data.SqlClient.SNI.dll file as it is not copy to the deploy folder using ClickOnce publish.
Seems it is solved when targeting a .NET Framework project but not when it is with a .NET Core project.
Any expectation of a solution for this. Now that ClickOnce is avaiable for .NET Core projects can't be deploy properly because this issue.
Thanks.
PD: Not sure if this was the right place to comment on this or better to pen a new issue.
Starting with v2.0.0 of Microsoft.Data.SqlClient, you should not have issues with Clickonce application deployments.
Please upgrade and let us know if you face any issues! A new issue with repro in that case would be ideal.
I tested it with v2.0.1 now and it works as expected. Finally, I can verify that the issue has been fixed properly and entirely.
@MojoDK It works for my C# ClickOnce application targeting NET 4.7.2. Among others, the solution contains a GUI and a Core assembly. Both include the Microsoft.Data.SqlClient v2.0.1 nuget package.
Did you purge %USERNAME%\.nuget directory? For some reason an old package version is sometime used instead of the latest one.On 22 Feb 2021 11:39, Mojo <[email protected]> wrote:
@Siam1205 ... Well the package says 2.1.1, but the version in VS says 2.0.20168.4:
It does not work for our VB.Net ClickOnce Outlook VSTO addin. No SNI flies are being published.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
@jeremy-waguet ... that did not help. I deleted all pacakages under %userprofile%.nuget, I removed the Microsoft.Data.SqlClient from my project and added it again. When publised it throws this exception:
System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: DLL 'Microsoft.Data.SqlClient.SNI.x64.dll' The specified module could not be found.
Die you try this? I also ran into the exact exception you mentioned. I fiddled with the nuget packages and managed to fix it just to get the exception i mentioned a few comments above.
The quoted lines in combination with the newest nuget packages fixed it for me.
@MojoDK I suggest you open a new issue, and provide a repro solution, that demonstrates the issue. Notice that a VB.NET based VSTO addin is not a standard executable app.
I still can get an issue when SNI deploy files are not published to ClickOnce Publishing Folder Location. These files:
Microsoft.Data.SqlClient.SNI.x64.dll.deploy
Microsoft.Data.SqlClient.SNI.x86.dll.deploy
Although DLLs are published:
Microsoft.Data.SqlClient.SNI.x64.dll
Microsoft.Data.SqlClient.SNI.x86.dll
Steps to reproduce:
Build and Publish project with Configuration "Release".
If it is the first build and publish, when SNI deploy files are published.
Change Publishing Folder Location.
Publish again and SNI deploy files are missing
I tried viewing verbose build log Output and noticed that SNI target "AppendSNIDllsInManifest" is not called, because it depends on Target "BeforeBuild" and "BeforeBuild" is not called because MSBuild decides that not much have changed and no need to run many Targets.
Same issues can be reproduced also by these things:
switch to other Configuration (in my case I use custom configuration) after previous successful publish and try to publish again
after previous successful publish, delete all files from Publishing Folder Location and try to publish again
I was having this issue with a normal "publish to folder" process. After adding SNI v.2.1.1 to the executable project, it started being copied to the publish directory correctly.
EDIT: Upon further inspection, turns out this didn't actually solve the issue.... even though the Microsoft.Data.SqlClient.SNI DLLs were copied, the corresponding SNI.dll files under x86 and x64 folders were not...
I was having this issue with a normal "publish to folder" process. After adding SNI v.2.1.1 to the executable project, it started being copied to the publish directory correctly.
EDIT: Upon further inspection, turns out this didn't actually solve the issue.... even though the Microsoft.Data.SqlClient.SNI DLLs were copied, the corresponding SNI.dll files under x86 and x64 folders were not...
Then proceed to add the Microsoft.Data.SqlClient v1.1.3 package (the version we were using in the solution) to the project. Didn't work. Then, I removedMicrosoft.Data.SqlClient.SNI package and did work: the x64 and x86 folders started being copied, even though the Microsoft.Data.SqlClient.SNI dlls were not there.
This is incredibly confusing to me but the important part is that it works now...
Activity
cheenamalhotra commentedon Feb 24, 2020
Hi @Siam1205
Are you using
msbuild /target:publishto publish the same or some other tool?Could you try using msbuild if not already and let us know if that works?
If not, please provide us a repro version of your ClickOnce application for us to investigate targets.
cfaagaard commentedon Feb 25, 2020
We are experiencing the same bug.
To reproduce:
Check bin/debug folder. It contains the two folders x64 and x86 with the SNI.dll in each folder.
If you publish same project (using visual studio 2019 (16.4.5)) the published folder looks like this:
Siam1205 commentedon Feb 25, 2020
Thank you very much for your Quick reply. I am currently on vacation ehich is the reason for my bad response time.
According to your question: I am using the ClickOnce publish mechanism right from VS (I guess VS2017). Since I am on vacation I cannot try what you suggested right now. However:
This exactly depicts the issue. Thank you very much.
Siam1205 commentedon Feb 25, 2020
I am currently using a workaround by adding both directories as content to the WPF App. This way, they are deployed along with the application. This works but is not ideal.
cfaagaard commentedon Feb 25, 2020
So do we right now :-)
cheenamalhotra commentedon Feb 25, 2020
Thanks for the repro @cfaagaard and @Siam1205
I was able to reproduce the problem and saw that the SNI files were copied to Publish directory instead of deployment folder. The support for Publish Dir is for Dotnet SDK applications but there is no internal deployment folder so this was not covered.
I was able to resolve this by adding below target to csproj:
Below is the output:
Let me know if you can get it working too, and we will plan to address this change in next SNI version.
cfaagaard commentedon Feb 26, 2020
I can confirm it copies the directories and the dlls and pdbs…… and it gives a warning: "Warning: Publishing file 'SNI.pdb' that may contain sensitive or proprietary information."
In a clickonce-publish-scenario it should be sni.dll.deploy and no pdb published.
cheenamalhotra commentedon Feb 26, 2020
I agree. I think it should apply to all "Publish" targets as symbols are not needed during publish.
I've handled that internally and will be taken care of.
Siam1205 commentedon Feb 27, 2020
I will try the workaround you provided, @cheenamalhotra once I get back to work next Monday. However, according to @cfaagaard it actually works. I guess there is no need for me to additionally verify it.
If I understand you correctly, with SqlClient v2.0.0, your
<Target>workaround won't be necessary anymore?cheenamalhotra commentedon Feb 27, 2020
Yes, the above target (with handled pdb case) will be part of M.D.S.SNI.targets in next release.
Siam1205 commentedon Mar 3, 2020
I can also confirm that this workaround solves the issue. I will use that until it becomes obsolete. Thank you very much for your efforts.
Siam1205 commentedon Mar 6, 2020
Hello,
I must add the fact that the provided workaround indeed copies the files as expected. However: While installing the latest version of the application, it does not seem to copy the files to where the whole application is deployed locally hence the workaround does not work for ClickOnce applications that are installed locally upon starting the
setup.exeor the.applicationfile in the output directory.jeremy-waguet commentedon Mar 31, 2020
@Siam1205
Exactly same behaviour for me deployed but not copied locally !
The only workaround I found is copying manually the x86 & x64 folders from the build to the deployed setup (bypassing clickonce updater ...). How to fix this properly please @cheenamalhotra ?
24 remaining items
Siam1205 commentedon Nov 10, 2020
Hello @cheenamalhotra and @jeremy-waguet,
sorry that I did not respond to you for so long and thank you for continuing to find a solution for the issue.
The respective project still uses the workaround I mentioned on Feb 25.
I read briefly through your discussion but I wonder what the best solution now looks like. So what's the best way to get the ClickOnce deployment working properly without manipulating too much the project itself too much?
Siam1205 commentedon Nov 10, 2020
FYI: I fixed this and following issues by adding
to the corresponding
.csprojfile.cheenamalhotra commentedon Nov 10, 2020
Hi @Siam1205
Starting with v2.0.0 of Microsoft.Data.SqlClient, you should not have issues with Clickonce application deployments.
Please upgrade and let us know if you face any issues! A new issue with repro in that case would be ideal.
tatoadsl commentedon Nov 18, 2020
Hello,
This seems to be not solved or at least I can't make it work properly even trying the many workaround proposed here.
My project is .NET 5 using EF Core 5.0. The dependency uses is Microsoft.Data.SqlClient 2.0.1 and the files are not deployed with ClickOnce.
The problem is the same, can't find the Microsoft.Data.SqlClient.SNI.dll file as it is not copy to the deploy folder using ClickOnce publish.
Seems it is solved when targeting a .NET Framework project but not when it is with a .NET Core project.
Any expectation of a solution for this. Now that ClickOnce is avaiable for .NET Core projects can't be deploy properly because this issue.
Thanks.
PD: Not sure if this was the right place to comment on this or better to pen a new issue.
MojoDK commentedon Feb 22, 2021
Why is this closed? I still have problems with SNI not deployed in ClickOnce.
Siam1205 commentedon Feb 22, 2021
I tested it with v2.0.1 now and it works as expected. Finally, I can verify that the issue has been fixed properly and entirely.
@MojoDK It works for my C# ClickOnce application targeting NET 4.7.2. Among others, the solution contains a GUI and a Core assembly. Both include the Microsoft.Data.SqlClient v2.0.1 nuget package.
MojoDK commentedon Feb 22, 2021
@Siam1205 ... Well the package says 2.1.1, but the version in VS says 2.0.20168.4:
It does not work for our VB.Net ClickOnce Outlook VSTO addin. No SNI flies are being published.
jeremy-waguet commentedon Feb 22, 2021
MojoDK commentedon Feb 22, 2021
@jeremy-waguet ... that did not help. I deleted all pacakages under %userprofile%.nuget, I removed the Microsoft.Data.SqlClient from my project and added it again. When publised it throws this exception:
System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: DLL 'Microsoft.Data.SqlClient.SNI.x64.dll' The specified module could not be found.
Siam1205 commentedon Feb 22, 2021
Die you try this? I also ran into the exact exception you mentioned. I fiddled with the nuget packages and managed to fix it just to get the exception i mentioned a few comments above.
The quoted lines in combination with the newest nuget packages fixed it for me.
MojoDK commentedon Feb 22, 2021
@Siam1205 ... I tried adding the two lines to the PropertyGroup of the vbproj file, but still same error and I am on latest packages.
ErikEJ commentedon Feb 22, 2021
@MojoDK I suggest you open a new issue, and provide a repro solution, that demonstrates the issue. Notice that a VB.NET based VSTO addin is not a standard executable app.
mantasgl commentedon Jan 21, 2022
I still can get an issue when SNI deploy files are not published to ClickOnce Publishing Folder Location. These files:
Although DLLs are published:
Steps to reproduce:
I tried viewing verbose build log Output and noticed that SNI target "AppendSNIDllsInManifest" is not called, because it depends on Target "BeforeBuild" and "BeforeBuild" is not called because MSBuild decides that not much have changed and no need to run many Targets.
Same issues can be reproduced also by these things:
julealgon commentedon Aug 12, 2023
I was having this issue with a normal "publish to folder" process. After adding SNI v.2.1.1 to the executable project, it started being copied to the publish directory correctly.
EDIT: Upon further inspection, turns out this didn't actually solve the issue.... even though the
Microsoft.Data.SqlClient.SNIDLLs were copied, the correspondingSNI.dllfiles underx86andx64folders were not...Back to square one...
julealgon commentedon Aug 12, 2023
EDIT 2: Ok... found another post here
Then proceed to add the
Microsoft.Data.SqlClient v1.1.3package (the version we were using in the solution) to the project. Didn't work. Then, I removedMicrosoft.Data.SqlClient.SNIpackage and did work: the x64 and x86 folders started being copied, even though theMicrosoft.Data.SqlClient.SNIdlls were not there.This is incredibly confusing to me but the important part is that it works now...