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

nuget libraries are not properly copied over to AppData\Local\assembly #2579

Closed
farzonl opened this issue Aug 25, 2023 · 9 comments
Closed
Labels
feature request New feature request sdk sdk-next-release Will be included in the upcoming release

Comments

@farzonl
Copy link

farzonl commented Aug 25, 2023

Describe the bug

Exception thrown: 'System.ComponentModel.Win32Exception' in SQLitePCLRaw.batteries_v2.dll
Exception thrown: 'System.Exception' in SQLitePCLRaw.batteries_v2.dll
2023-08-24 23:27:29.932 [AppCenter] ERROR: Failed to initialize sqlite3 provider.
System.Exception: Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
    1) C:\Users\username\AppData\Local\assembly\dl3\GPDLTRHM.2DD\CW8H18OX.ZAX\f0a1aaf0\009d039e_e66ed801\runtimes\win-x64\native\e_sqlite3.dll
    2) C:\Users\username\AppData\Local\assembly\dl3\GPDLTRHM.2DD\CW8H18OX.ZAX\f0a1aaf0\009d039e_e66ed801\e_sqlite3.dll
win TryLoad: C:\Users\username\AppData\Local\assembly\dl3\GPDLTRHM.2DD\CW8H18OX.ZAX\f0a1aaf0\009d039e_e66ed801\runtimes\win-x64\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found

%AppData%\Local\assembly\dl3\GPDLTRHM.2DD\CW8H18OX.ZAX\f0a1aaf0\009d039e_e66ed801

is missing runtimes directory.

Describe the solution you'd like
A clear and concise description of what you want to happen.
The runtimes directory from:
C:\Users\username\.nuget\packages\sqlitepclraw.lib.e_sqlite3\2.1.0\runtimes
needs to be copied to
%AppData%\Local\assembly\dl3\GPDLTRHM.2DD\CW8H18OX.ZAX\f0a1aaf0\009d039e_e66ed801

when I copy over the runtimes directory manually everything works fine.

@farzonl farzonl added the feature request New feature request label Aug 25, 2023
@farzonl
Copy link
Author

farzonl commented Aug 25, 2023

looks like a duplicate of #2527 and microsoft/appcenter-sdk-dotnet#1716

However I'm on 5.0.2 and im using Package References.

Hmm this seems the most relevant since i'm on 4.8.1 and working on a VSTO app: microsoft/appcenter-sdk-dotnet#1583

And ericsink/SQLitePCL.raw#537 is already resolved.

@DmitriyKirakosyan
Copy link
Contributor

Hi @farzonl , thank you for reaching out!

Have you tried to reference the fixed version of SQlitePCL.raw directly in your project? Would it resolve the issue?

@farzonl
Copy link
Author

farzonl commented Aug 28, 2023

No updating didn't fix anything.

@DmitriyKirakosyan
Copy link
Contributor

@farzonl, I believe it's a duplicate of microsoft/appcenter-sdk-dotnet#1583.

Although the issue you referenced was marked as 'resolved', it wasn't actually addressed in the SQLitePCL.raw side; it was simply closed without a fix. Your situation appears distinct since you're encountering the problem even with a PackageReference project.

Please refer to #1583 for all related links.

@farzonl
Copy link
Author

farzonl commented Sep 1, 2023

@DmitriyKirakosyan The call stack I'm seeing and microsoft/appcenter-sdk-dotnet#1583 are distinct so I'm still unsure if it is a dupe. But the good news is I have a fix: ericsink/SQLitePCL.raw#553. I'll ask the original poster if he would like to try my fix?

The issue has a few parts. First and formost SQLITEPCL.Raw won't copy over e_sqlite3.dll from nuget unless you specify an architecture type. like so:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
  <PlatformTarget>x86</PlatformTarget>
  <DebugSymbols>true</DebugSymbols>
  <DebugType>full</DebugType>
  <Optimize>false</Optimize>
  <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
  <RuntimeIdentifier>win-x86</RuntimeIdentifier>
  <OutputPath>bin\x86\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
  <PlatformTarget>x86</PlatformTarget>
  <DebugType>pdbonly</DebugType>
  <Optimize>true</Optimize>
  <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
  <RuntimeIdentifier>win-x86</RuntimeIdentifier>
  <OutputPath>bin\x86\Release\</OutputPath>
</PropertyGroup>
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
  <PlatformTarget>x64</PlatformTarget>
  <DebugSymbols>true</DebugSymbols>
  <DebugType>full</DebugType>
  <Optimize>false</Optimize>
  <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  <OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
  <PlatformTarget>x64</PlatformTarget>
  <DebugType>pdbonly</DebugType>
  <Optimize>true</Optimize>
  <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  <OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>

That only gets your dll in your Release\Debug directory though. Second Problem is that VSTO copies libraries to temp directories. More on that here: https://web.archive.org/web/20140424032444/http://blogs.msdn.com/b/vsod/archive/2008/11/01/office-customization-creates-loads-dll-from-temporary-folder.aspx

This is where my fix comes in to play. Using System.Reflection.Assembly.GetExecutingAssembly().CodeBase we can get the original directory of the library where all the other dependency libraries like e_sqlite3.dll will also be.

More instruction on how I confirmed the fix and someone else could try:
ericsink/SQLitePCL.raw#552 (comment)

@DmitriyKirakosyan
Copy link
Contributor

@farzonl, great news! Thanks a lot for your excellent work in finding and fixing the problem. We hope the folks in charge of SQLitePCL.raw will soon accept your changes, allowing us to update it in our SDK. Your help is much appreciated!

@farzonl
Copy link
Author

farzonl commented Nov 7, 2023

@DmitriyKirakosyan This issue has been resolved by ericsink/SQLitePCL.raw#553

What is needed to roll the appcenter dotnet sdk to take this change in the next release?

@DmitriyKirakosyan
Copy link
Contributor

We'll roll the new release into our SDK as soon as it's out. 👍

Related thread microsoft/appcenter-sdk-dotnet#1583.

@DmitriyKirakosyan
Copy link
Contributor

fixed in microsoft/appcenter-sdk-dotnet#1765

@DmitriyKirakosyan DmitriyKirakosyan added the sdk-next-release Will be included in the upcoming release label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature request sdk sdk-next-release Will be included in the upcoming release
Projects
None yet
Development

No branches or pull requests

2 participants