0

I have started a new project which contains as dependencies some other dlls (a sort of personal framework).

The project is an Xamarin Forms project.

When I start to build the main project all works fine.

If I try to build the Android or iOS project this error occurs and the build stopped:

Can not resolve reference: `SQLitePCLRaw.core`, referenced by `MyAppTest` > `MyFramework` > `SQLite-net`. 
Please add a NuGet package or assembly reference for `SQLitePCLRaw.core`, or remove the reference to `MyAppTest`.   
MyAppTest.Android   C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1962    

Inside the MyFramework there are some function that access at a SQLite DB (I have installed in MyFramework the NuGet package sqlite-net-sqlcipher), but I don't use these function in this new project.

I already have added this line inside the csproj of MyFramework:

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

How can I solve this?

I need to change something else inside the MyFramework?

I would not install the sqlite-net-sqlcipher package in my new application because I don't have a SQLite DB here.

Hikari
  • 589
  • 7
  • 29
  • sqlite-net-sqlcipher is a dependency of your custom framework. You need all the dependencies, for your android or iOS projec to build. So the only solution is to either add sqlite-net-sqlcipher to your Android and iOS projects, or to strip your custom framework from that dependency – Miiite Jul 26 '19 at 10:08
  • 1
    That's not the _only_ solution - you could use [preprocessor directives](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if) to exclude that code when building an app that doesn't use it. – stuartd Jul 26 '19 at 10:10
  • 1
    probably some of your classes in `MyFramework` have a type from `sqlite-net-sqlcipher` in their signature (parameters of methods/return types/properties/etc). So even you don't use them - you need `sqlite-net-sqlcipher` to load your `MyFramework` assembly. You can't load it partially, right? – vasily.sib Jul 26 '19 at 10:10
  • @stuartd considering that he already has a packaged .dll, I didn't consider preprocessor directives as an option. But if you include your framework *source code* into your new project, you could indeed exclude the sqlite parts for your new projects using this technique – Miiite Jul 26 '19 at 10:15
  • There is a way to inclue all the dependencies of `MyFramework` inside the compiled dll of itself? – Hikari Jul 26 '19 at 10:15
  • @Miiite you make a good point there. Would have to compile the DLL with a [`-define` flag](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/define-compiler-option) for different platforms. It's still an option, though. – stuartd Jul 26 '19 at 10:42
  • 1
    @Hikari I don't believe there is a way to include the dependencies into the .dll. Nuget packages do this using nuget dependencies, that's why you might install 2 or more nuget packages at the same time, when you only wanted to install one to start with. Your best option is still to install the nuget package yourself into your platforms projects, or rework your custom Framework. – Miiite Jul 26 '19 at 12:18

0 Answers0