0

My nuget package is for a library that needs a configuration file (ClassLibrary1.dll.config). I've tried to bundle it like this:

enter image description here

This is the nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>ClassLibrary1</id>
    <version>1.0.0</version>
    <authors>ClassLibrary1</authors>
    <owners></owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework="net5.0" />
    </dependencies>
  </metadata>
  <files>
    <file src="lib\net5.0\ClassLibrary1.dll" target="lib\net5.0\ClassLibrary1.dll" />
    <file src="lib\net5.0\ClassLibrary1.dll.config" target="lib\net5.0\ClassLibrary1.dll.config" />
  </files>
</package>

I have an application that references this Nuget package. The assembly is correctly copied to the output folder, but the .dll.config is not.

This is the output folder:

enter image description here

What's wrong? What should I do to get the config copied to the output directory?

I'm using Nuget 5.10+

BTW, I've read the answers to this post and none of them worked:

How can i make dll.config to be part of Nuget package

SuperJMN
  • 13,110
  • 16
  • 86
  • 185

1 Answers1

0

See https://stackoverflow.com/a/70608349/487503 for what worked for me.

In short: add a .props and .targets file to the nuget package that get executed in the project that consumes the nuget package and copies the .config file to the output directory.

decocijo
  • 908
  • 7
  • 19