2
votes

I've created multiple nuget packages. All of them work fine, besides one: When I add that nuget package, I can see that it is referenced in the packages.config and the dll is downloaded to packages\InhouseWKOIT.Framework.Resources.4.5.999.999\lib\InhouseWKOIT.Framework.Resources.dll but it is not added to the references in the target project.

The dll so far is not targeted to a .NET framework version (such as lib\net45), which should be fine (at least it is for all other working nuget packages I've created).

I checked out Stackoverflow and Google, but I couldn't find something that described the problem. Most solutions were only to clear the NuGet cache or update/re-install the package which didn't help. I also tried it on different computers, the behavior is everywhere the same: all packages are working fine but that one is not.

Here is a look of the package with the NuGet Package Explorer: Screenshot of NuGet Package Explorer

The content of the DLL is rather simple, only two very simple classes: ILSpy Screenshot

I also changed the .net framework version of the project to different .net versions (also other than 4.5.2)

I can manually add the reference in the target project, when selecting the dll in the packages\InhouseWKOIT.Framework.Resources.4.5.999.999\lib\InhouseWKOIT.Framework.Resources.dll without any problems and use the classes of this assembly.

(Btw. do not wonder about the version number 999.999, that is just, when I build locally to debug problems in nuget packages)

This is the output of the package manager, when adding the package:

Attempting to gather dependency information for package 'InhouseWKOIT.Framework.Resources.4.5.999.999' with respect to project 'ConsoleApp8', targeting '.NETFramework,Version=v4.5.2'
Gathering dependency information took 65,78 ms
Attempting to resolve dependencies for package 'InhouseWKOIT.Framework.Resources.4.5.999.999' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'InhouseWKOIT.Framework.Resources.4.5.999.999'
Resolved actions to install package 'InhouseWKOIT.Framework.Resources.4.5.999.999'
Retrieving package 'InhouseWKOIT.Framework.Resources 4.5.999.999' from 'LocalPackage'.
Adding package 'InhouseWKOIT.Framework.Resources.4.5.999.999' to folder 'C:\Users\AmonD\Source\Repos\ConsoleApp8\packages'
Added package 'InhouseWKOIT.Framework.Resources.4.5.999.999' to folder 'C:\Users\AmonD\Source\Repos\ConsoleApp8\packages'
Added package 'InhouseWKOIT.Framework.Resources.4.5.999.999' to 'packages.config'
Successfully installed 'InhouseWKOIT.Framework.Resources 4.5.999.999' to ConsoleApp8
Executing nuget actions took 375,64 ms
Time Elapsed: 00:00:00.5244957
========== Finished ==========

The packages.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="InhouseWKOIT.Framework.Resources" version="4.5.999.999" targetFramework="net452" />
</packages>

The Package.nuspec file:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <!-- The identifier that must be unique within the hosting gallery -->
    <id>InhouseWKOIT.Framework.Resources</id>

    <!-- The package version number that is used when resolving dependencies -->
    <version>$fullversion$</version>

    <!-- Authors contain text that appears directly on the gallery -->
    <authors>Dominik Amon</authors>

    <!-- Owners are typically nuget.org identities that allow gallery
            users to easily find other packages by the same owners.  -->
    <owners>amond</owners>

    <!-- License and project URLs provide links for the gallery -->
    <licenseUrl>https://wikis.oe.wknet/applikationsentwicklung/inhouse-framework</licenseUrl>
    <projectUrl>https://wikis.oe.wknet/applikationsentwicklung/inhouse-framework</projectUrl>

    <!-- The icon is used in Visual Studio's package manager UI -->
    <iconUrl>https://tae.dev.oe.wknet/InhouseVisualStudioGallery/Nuget.png</iconUrl>

    <!-- If true, this value prompts the user to accept the license when
            installing the package. -->
    <requireLicenseAcceptance>false</requireLicenseAcceptance>

    <!-- Any details about this particular release -->
    <releaseNotes></releaseNotes>

    <description>Basis Resourcen für das InhouseFramework</description>

    <!-- Copyright information -->
    <copyright>Copyright ©2018 Inhouse WKO IT</copyright>

    <!-- Tags appear in the gallery and can be used for tag searches -->
    <tags>inhouseframework inhouse framework resources</tags>


  </metadata>

  <!-- A readme.txt to display when the package is installed -->
  <files>
    <file src="..\..\FrameworkLight\Resources\obj\$configuration$\InhouseWKOIT.Framework.Resources.dll" target="lib" />
  </files>
</package>

Any ideas why the reference to the dll is not set automatically to the target project?

1
Is the DLL being used/referenced in your project? Can you please post your .nuspec file?Rui Jarimba
I just added the nuspec file in the content (see updated version). By adding the nuget package to the project, it should be referenced in order to be used in the project.DominikAmon

1 Answers

1
votes

I actually found the issue, the package is fine, the problem is the name of the dll, ending with *.Resources.dll - When I changed the name of the assembly to something else, everything worked fine. So I was looking now for naming issues in NuGet Packages and found the following article:

Use NuGet to add a project assembly reference to a file named *.Resources.dll