Installing SQLite NuGet Package installs the package but the reference is not available. VS2019 Community

浪尽此生 提交于 2021-01-29 20:26:19

问题


I"m writing a c# application using SQLite and I need the the SQLite Reference. Using NuGet I locate the package and the output window shows a successful install.

Looking at the packages config file in the solution explorer it shows the version installed.

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="SQLite" version="3.13.0" targetFramework="net472" />
</packages>

However under the project References in the Solution explorer SQLite is not there.

I have watched tutorials online where the same process is done on other machines and all is ok, all of the references pop up after NuGet finishes the installation.

I'm using VS2019 and from what I understand there were some changes on how NuGet operates, however I had VS2015 and VS2017 Community and had the same issues. I'm really at a standing point as I have no idea how to get the reference to show up so I can access it in my program.

SQLite has no Assembly reference so adding it there is not an option.

I have seen posts about a NuGet config file and Package Config File as well as the possibility of the package being installed outside of the Solution Folder but I don't know where. I have looked in the output location of the solution and none of the references are located in the debug folder anywhere.

I feel the Dll's are being installed outside of the solution folder but I don't know where and how to get Visual Studio to get them to the proper location or reference there existing location correctly.

Rebuild and Restore NuGet Packages provide no solution.

Any help would be greatly appreciated.


回答1:


Installing SQLite NuGet Package installs the package but the reference is not available. VS2019 Community

I assume you have installed sqlite version 3.13.0 nuget package.If so, it is the behavior of this nuget package. This package is very special in that it is a transactional SQL database engine that implements self-contained, serverless, zero-configuration.

In simple terms, it is a configuration function package that operates on related data when the project is running, rather than a package that provides a reference class library for the project.

Let me explain it in more detail:

This is the content of the nuget package sqlite version 3.13.0

Note that each folder provides specific functionality for the installation project. And the function of the lib folder is to add its content(xxxx.dlls) as reference to a new project. In a word, Only the Dlls in lib folder can be recognized by nuget and added into Reference.

You can refer to this link for more detailed info about the function of the folders.

Second, there is a file called SQLite.props in the Build folder. The file will do some configuration to your project during build process.

In it, you can see these files:

<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win7-x64\native\*">
      <Link>x64\%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup Condition=" (Exists('packages.config') Or Exists('packages.$(MSBuildProjectName).config')) And '$(Platform)' == 'x86'">
    <Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win7-x86\native\*">
      <Link>%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </Content>
  </ItemGroup>
  <ItemGroup Condition=" (Exists('packages.config') Or Exists('packages.$(MSBuildProjectName).config')) And '$(Platform)' == 'x64'">
    <Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win7-x64\native\*">
      <Link>%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>False</Visible>
    </Content>

So when you build your project, the SQLite.props file will be executed and they will provide services during build or at the runtime.

All of these indicates it is a package for specific execution functions rather than a nuget package for adding reference libraries to the project.

Suggestion

As a suggestion, you could install System.Data.SQLite in your project. And this nuget package provides the dlls which you want in Reference.

Hope it could help you.



来源:https://stackoverflow.com/questions/60217526/installing-sqlite-nuget-package-installs-the-package-but-the-reference-is-not-av

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!