gpt4 book ai didi

c# - NuGet 包 - 未引用 lib 文件夹中的 DLL?

转载 作者:太空宇宙 更新时间:2023-11-03 12:12:54 26 4
gpt4 key购买 nike

我创建了多个 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 包资源管理器的包的外观: Screenshot of NuGet Package Explorer

DLL的内容比较简单,只有两个很简单的类: ILSpy Screenshot

我还将项目的.net framework 版本更改为不同的.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 包中的命名问题,并找到了以下文章:

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

关于c# - NuGet 包 - 未引用 lib 文件夹中的 DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51240611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com