Feasoron
Feasoron

Reputation: 3600

Namespace not found when adding custom dll packed via NuSpec to ASP.NET Core project

I have a brand-new asp.net core web api project targeting .net framework 4.6. For business reasons, we need to access an old .net 3.5 library. I ran

nuget spec old-library.dll

then

nuget pack old-library.dll.

and installed the package. However, I can't seem to access the library.

using old-library-namespace;

just doesn't resolve. I know we should be able to use existing .net libraries, and it seems like other people have tried this, but I am at a loss as to the next step here.

Upvotes: 0

Views: 235

Answers (1)

Martin Ullrich
Martin Ullrich

Reputation: 100621

In your .nuspec file for the dll, make sure that the <files> section sets the target path of the dll file correctly:

<?xml version="1.0"?>
<package >
  <metadata>
    <!-- your metadata -->
    <frameworkAssemblies>
      <!-- and framework assemblies you reference -->
      <frameworkAssembly assemblyName="System.Xml" targetFramework="net35" />
    </frameworkAssemblies>
  </metadata>
  <files>
    <file src="old-library.dll" target="lib\net35" />
  </files>
</package>

Upvotes: 1

Related Questions