1

I created a class library project and put my SQLite database in it, and set these lines in the .csproj file:

<ItemGroup>
    <Content Include="Data\DataBase\locations.db">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>

If I locally reference that class library to my main project (ASP.NET Core), it works fine and on every build it will copy the database file to this directory:

***\bin\Debug\net5.0\Data\DataBase

But when I publish the class library to NuGet, and install it in my main project, it doesn't copy the file.

Any help why this is happening and what should I do?

This is my package in NuGet package explorer

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
keyone2693
  • 619
  • 1
  • 4
  • 17

1 Answers1

1

Just find out the answer

  <ItemGroup>
    <Content Include="Data\DataBase\locations.db">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
  </ItemGroup>

This line will do the job

<PackageCopyToOutput>true</PackageCopyToOutput>
keyone2693
  • 619
  • 1
  • 4
  • 17