While migrating a still project.json based project to Visual Studio 2017s *.csproj format, an integration tests project gave me a bit of a headache:
It's been a class library project that used the Microsoft.AspNetCore.TestHost package for integration testing API calls. Since I wanted to make use of a relational database for data integrity and validation, I chose to use Microsoft.EntityFrameworkCore.Sqlite as database provider. After migration, however, I got a lot of System.DllNotFoundException telling me that sqlite3.dll could not be loaded.
I have been unable to find any real cause for the issue, but it's got something to do with the SQLite NuGet package dlls not being copied to the output directory when targeting the full .Net Framework in a class library. Kinda, sorta, somehow. It comes up in issues where people couldn't run dotnet ef CLI commands without a startup project.
Luckily, I could fix it:
- I made a copySQLiteDlls.ps1 script that copied the required Dlls in a Dependencies folder in the solution root
- I added the Dlls to be included in the output on compilation in the *.csproj file:
Just make sure to run the first script after a package restore or before running your tests and you should be fine. There should now be an x64 and x86 folder in your output directory containing the sqlite3.dll files.
Happy integration!