我创建了多个 nuget 包。除了一个之外,所有这些都工作正常:当我添加那个 nuget 包时,我可以看到它在
packages.config
中被引用,并且 dll 被下载到 packages\InhouseWKOIT.Framework.Resources.4.5.999.999\lib\InhouseWKOIT.Framework.Resources.dll
但它没有添加到目标项目中的引用中。
到目前为止,该 dll 尚未针对 .NET Framework 版本(例如 lib et45),这应该没问题(至少对于我创建的所有其他工作 nuget 包来说是这样)。
我查看了 Stackoverflow 和 Google,但找不到描述该问题的内容。大多数解决方案只是清除 NuGet 缓存或更新/重新安装软件包,但没有帮助。我也在不同的计算机上尝试过,行为到处都是一样的:所有包都工作正常,但那个不是。
以下是使用 NuGet Package Explorer 看到的包的外观:
我还将项目的.net框架版本更改为不同的.net版本(也不是4.5.2)
我可以在目标项目中手动添加引用,在
packages\InhouseWKOIT.Framework.Resources.4.5.999.999\lib\InhouseWKOIT.Framework.Resources.dll
中选择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 的名称,以 *.Resources.dll 结尾 - 当我将程序集的名称更改为其他名称时,一切正常。 因此,我现在正在寻找 NuGet 包中的命名问题,并发现了以下文章: