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.SNI not deployed to _PublishedWebsites for an ASP.NET Web Application #936

Open
mbakalov opened this issue Feb 26, 2021 · 16 comments

Comments

@mbakalov
Copy link
Member

Background

For ASP.NET Web Applications it is common to build them providing /p:OutDir=someDir (or /p:OutputPath=someDir) parameter and then taking the _PublishedWebsites\WebApp contents and xcopy-ing them.

The custom SNI-deploying targets do support OutDir but not for a web app scenario - the SNI .dlls don't get copied to _PublishedWebsites\WebApp\bin.

Steps to reproduce

A repo with a blank ASP.NET Web App and steps to reproduce: https://github.com/mbakalov/SqlClientSniRepro1

To reproduce, in VS command prompt do:

msbuild /t:Build /p:Configuration=Release /p:Platform="Any CPU" Example.sln /p:OutDir=C:\temp\output

The SNI .dlls get copied to C:\temp\output, but not to C:\Temp\output\_PublishedWebsites\WebApp\bin

Expected behavior

Expected the SNI .dlls to be copied to the "bin" folder of the published website.

Further technical details

Microsoft.Data.SqlClient version: 2.1.1
.NET target: net461

Related issue: #441

@cheenamalhotra
Copy link
Member

Hi @mbakalov

Thanks for the repro. We'll investigate and get back to you soon!

@cheenamalhotra cheenamalhotra added this to Needs triage in SqlClient Triage Board via automation Feb 26, 2021
@cheenamalhotra cheenamalhotra moved this from Needs triage to Under Investigation in SqlClient Triage Board Feb 26, 2021
@mbakalov
Copy link
Member Author

@cheenamalhotra - thank you for a quick response!

I'd worked around this for now by adding the below target to my webapp.csproj:

<Target Name="_CopySNIFilesToWebProjectOutputDir"
        AfterTargets="CopySNIFiles"
        Condition="'$(WebProjectOutputDir)' != ''">
		
	<Copy SourceFiles="@(SNIFiles)"
	      DestinationFiles="@(SNIFiles -> '$(WebProjectOutputDir)\bin\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>

It works well enough for my scenario, but looking into the Microsoft.WebApplication.targets file, the correct fix is probably much more complicated.

Thanks again!

@Tony322
Copy link

Tony322 commented Jun 22, 2021

I can confirm. I have the exact same issue.

@ldsenow
Copy link

ldsenow commented Aug 26, 2021

WOW, I experience the same issue and tried the work around mentioned above and it didnt work. Any tips?

@poychang
Copy link

poychang commented Oct 1, 2021

@cheenamalhotra - thank you for a quick response!

I'd worked around this for now by adding the below target to my webapp.csproj:

<Target Name="_CopySNIFilesToWebProjectOutputDir"
        AfterTargets="CopySNIFiles"
        Condition="'$(WebProjectOutputDir)' != ''">
		
	<Copy SourceFiles="@(SNIFiles)"
	      DestinationFiles="@(SNIFiles -> '$(WebProjectOutputDir)\bin\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>

It works well enough for my scenario, but looking into the Microsoft.WebApplication.targets file, the correct fix is probably much more complicated.

Thanks again!

This workaround works for me.
Hoping has non-workaround fix soon.

@kfrancis
Copy link

kfrancis commented Dec 9, 2021

For some reason, this is really biting me now. A number of production pushes now have resulted in failures due to this.

@luizgrs
Copy link

luizgrs commented Apr 11, 2022

The problem occurs when using VS2022 (msbuild 17) to publish Web Applications using any version of Microsoft.Data.SqlClient, the files are not copied to OBJ folder and then not copied to final target folder.

If using VS2019 it works fine, in VS2019 build log we can see:

CopyAllFilesToSingleFolderForPackage:
  Creating directory "obj\Release\Package\PackageTmp".
  Copying all files to temporary location below for package/publish:
  obj\Release\Package\PackageTmp.
  Copying D:\362\s\packages\Microsoft.Data.SqlClient.SNI.1.0.19235.1\build\net46\x64\SNI.dll to obj\Release\Package\PackageTmp\bin\x64\SNI.dll.
  Copying D:\362\s\packages\Microsoft.Data.SqlClient.SNI.1.0.19235.1\build\net46\x64\SNI.pdb to obj\Release\Package\PackageTmp\bin\x64\SNI.pdb.
  Copying D:\362\s\packages\Microsoft.Data.SqlClient.SNI.1.0.19235.1\build\net46\x86\SNI.dll to obj\Release\Package\PackageTmp\bin\x86\SNI.dll.
  Copying D:\362\s\packages\Microsoft.Data.SqlClient.SNI.1.0.19235.1\build\net46\x86\SNI.pdb to obj\Release\Package\PackageTmp\bin\x86\SNI.pdb.

Lines above doesn't exist in VS2022 build logs.

Any updates @cheenamalhotra ?

Thanks

@kfrancis
Copy link

I did find this, and it's at least helped with the situation where IIS express can't deploy because of locked files.

@Scott-VentsUS
Copy link

Scott-VentsUS commented Oct 4, 2022

Any update on this? @poychang 's workaround is not working. The only way I can get it to work is on each device after install, to manually copy and paste the x64 and x86 folders with SNI inside it from the debug in the project files to the application folder "C:\Users\Scott\AppData\Local\Apps\2.0\KD9YXEPJ.DKY\5QCR3OCQ.WRY\vent..tion_098ef6a925fa6387_0001.0009_35951381a6b516d2"

for each machine. I need to install this program often enough for this to be a hassle.
Any idea how I can streamline it better or find another workaround?
Thanks!

@lcheunglci
Copy link
Contributor

The experience is better in newer versions of Microsoft.Data.SqlClient. Try something newer than 1.x.

@Scott-VentsUS
Copy link

Scott-VentsUS commented Oct 4, 2022

The experience is better in newer versions of Microsoft.Data.SqlClient. Try something newer than 1.x.

I updated to Microsoft.Data.SqlClient 5.0.0 and Microsoft.Data.SqlClient.SNI 5.0.0 and still the same issue

@lcheunglci
Copy link
Contributor

The experience is better in newer versions of Microsoft.Data.SqlClient. Try something newer than 1.x.

I updated to Microsoft.Data.SqlClient 5.0.0 and Microsoft.Data.SqlClient.SNI 5.0.0 and still the same issue

I just ran the sample repro project from the original author of this post https://github.com/mbakalov/SqlClientSniRepro1 and upgrade the project from .NET Framework 4.6.1 to 4.6.2 since M.D.S 5.0 only support 4.6.2 and above and ran the
msbuild /t:Build /p:Configuration=Release /p:Platform="Any CPU" Example.sln /p:OutDir=C:\temp\output and the SNI.dlls (i.e. Microsoft.Data.SqlClient.SNI.x64.dll, Microsoft.Data.SqlClient.SNI.x86.dll and along with their pdbs) were copied into the output folder.

@lcheunglci lcheunglci moved this from Under Investigation to Needs More Info in SqlClient Triage Board Oct 11, 2022
@lcheunglci
Copy link
Contributor

@Scott-VentsUS are you able to provide a different repro sample as the one provided from the original author works fine.

@juanii
Copy link

juanii commented Jan 11, 2024

Just came across this issue and I can still reproduce it using the reproduction repo and the VS2022 build toolchain.
@lcheunglci I can see the files are copied to the build output folder as you mention, but the OP stated that they were actually copied there, they're missing from the published website folder though, in the _PublishedWebsites\WebApp\bin subdirectory. Do you mean that location in your comment?

@HolisticDeveloper
Copy link

@cheenamalhotra any progress on this issue? Are you waiting for anything?

@luiz-soares
Copy link

luiz-soares commented Feb 7, 2024

Since v2, such files are not copied to folders x64/x86 anymore but directly into bin instead.

So if you are upgrading v1, try the app instead of just checking if such folders were created. I have successfully upgraded to v5.

It worth checking breaking changes in that link.

If sticking to v1, this workaround should get files copied:

  <Target Name="_CopySNIFilesForPublishPackage"
        AfterTargets="CopyAllFilesToSingleFolderForPackage">

    <Copy SourceFiles="@(SNIFiles)"
          DestinationFiles="@(SNIFiles -> '$(_PackageTempDir)\bin\%(RecursiveDir)%(Filename)%(Extension)')"/>
  </Target>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
SqlClient Triage Board
  
Needs More Info
Development

No branches or pull requests