【问题标题】:NuGet Package - DLL from lib folder not referenced?NuGet 包 - 未引用 lib 文件夹中的 DLL?
【发布时间】:2018-12-16 20:18:44
【问题描述】:

我创建了多个 nuget 包。除了一个之外,它们都工作正常:当我添加那个 nuget 包时,我可以看到它在 packages.config 中被引用,并且 dll 被下载到 packages\InhouseWKOIT.Framework.Resources.4.5.999.999\lib\InhouseWKOIT.Framework.Resources.dll 但它没有被添加到目标项目中的引用中。

到目前为止,该 dll 不是针对 .NET 框架版本(例如 lib\net45),这应该没问题(至少它适用于我创建的所有其他工作 nuget 包)。

我查看了 Stackoverflow 和 Google,但找不到描述问题的内容。大多数解决方案只是清除 NuGet 缓存或更新/重新安装没有帮助的包。我也在不同的计算机上尝试过,行为到处都是一样的:所有的包都工作正常,但一个不是。

以下是使用 NuGet 包资源管理器查看的包:

DLL的内容比较简单,只有两个非常简单的类:

我还将项目的 .net 框架版本更改为不同的 .net 版本(也不是 4.5.2)

我可以手动添加目标项目中的引用,在@ 987654327中选择DLL,没有任何问题并使用此程序集的类。

(顺便说一句。不要怀疑版本号 999.999,就是当我在本地构建以调试 nuget 包中的问题时)

这是添加包时包管理器的输出:

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 ==========

packages.config 看起来像这样:

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

Package.nuspec 文件:

<?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>

任何想法为什么不自动将对 dll 的引用设置为目标项目?

【问题讨论】:

  • 您的项目中是否正在使用/引用 DLL?你能发布你的 .nuspec 文件吗?
  • 我刚刚在内容中添加了 nuspec 文件(见更新版本)。通过将nuget包添加到项目中,它应该被引用以便在项目中使用。

标签: c# .net nuget


【解决方案1】:

我实际上发现了问题,包很好,问题是 dll 的名称,以 *.Resources.dll 结尾 - 当我将程序集的名称更改为其他名称时,一切正常。 所以我现在正在寻找 NuGet Packages 中的命名问题,并找到了以下文章:

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

【讨论】:

  • 我也犯了同样的错误。为什么不能有日志错误或任何说明无法使用命名空间的信息...
猜你喜欢
  • 2014-02-23
  • 1970-01-01
  • 2023-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-01
  • 1970-01-01
相关资源
最近更新 更多