0

I want to create my own custom package for System.Data.SQLite. I have the all the dll's I need but I'm unsure how to structure it and create the nuspec for it. Current folder structure of the dll's is this, whereabouts would I put the different interop dlls to have them copied correctly to the output and what do I need to add to the nuspec?

lib/net452
  -> System.Data.SQLite.dll , System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll
Custom.SQLite.nuspec

Still have the default nuspec something like this atm

 <?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
  <metadata minClientVersion="2.5">
    <id>Custom.SQLite.Name</id>
    <version>1.0.0.0</version>
    <authors>name</authors>
    <owners>owner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Desc</description>
    <copyright>Copyright 2021</copyright>
  </metadata>
</package>
Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
TMStackO
  • 313
  • 3
  • 13

1 Answers1

1

SQLite.Interop.dll does not act as a lib assembly dll. That is not its role. And it should be a content file rather than a assembly dll. So it should not be packed as lib.

To create such custom nuget package, you should first pack System.Data.SQLite.dll, System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll as lib. See this document.

and then pack SQLite.Interop.dll as content.

Also, to make the content file be copied into the output folder of the main project when you install the nuget package, you have to use a <packages_id>.props or targets file to realize it.

1) create a file called <packages_id>.props into your class library project. And it should be the same name as your nuget package. In your side, it should be named as Custom.SQLite.Name.props. Otherwise, it will not work.

And then add these into the file:

<Project>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\content\x86\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
        <None Include="$(MSBuildThisFileDirectory)..\content\x64\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

</ItemGroup>

</Project>

2) use this nuspec file:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
  <metadata minClientVersion="2.5">
    <id>Custom.SQLite.Name</id>
    <version>1.0.0.0</version>
    <authors>name</authors>
    <owners>owner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Desc</description>
    <copyright>Copyright 2021</copyright>
  </metadata>
<files>
<file src="System.Data.SQLite.dll" target="lib\net452" />
<file src="System.Data.SQLite.EF6.dll" target="lib\net452" />
<file src="System.Data.SQLite.Linq.dll" target="lib\net452" />
<file src="xxx\x86\SQLite.Interop.dll" target="content\x86" />
<file src="xxx\x64\SQLite.Interop.dll" target="content\x64" />
<file src="Custom.SQLite.Name.props" target="build" />

</files>
</package>

3) rebuild your lib project and then use nuget pack to pack the new version.

Before you use this new version, please uninstall the old one and delete all cache files under C:\Users\xxx\.nuget\packages\Custom.SQLite.Name and <solution_folder>\packages\Custom.SQLite.Name.1.0.0. Then, reinstall the new version.

Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
  • Doing this just leads to an error when I try to use the package. Failed to add reference to 'SQLite.Interop'. Please make sure that the file is accessible, and that it is a valid assembly or COM component. – TMStackO Apr 14 '21 at 08:19
  • Ohh. Sorry for that I am knowing that SQLite.Interop.dll does not act as a lib assembly dll. That is not its role. Really sorry for that. And it should be a content file rather than a assembly dll. So it should not be packed as lib. I will update my answer – Sara Liu - MSFT Apr 14 '21 at 09:51
  • What is your vs version? And nuget.exe version? I will update tomorrow. – Sara Liu - MSFT Apr 14 '21 at 10:05
  • No worries, I did what you suggested and made it content file and it worked great, so thanks! – TMStackO Apr 14 '21 at 10:08