我创建了多个nuget包。除了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缓存或更新/重新安装无济于事的软件包。我也在不同的计算机上尝试过,其行为在各处都是相同的:所有软件包都能正常工作,但事实并非如此。
我还将项目的.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的引用没有自动设置为目标项目?
答案 0 :(得分:1)
我实际上发现了问题,程序包很好,问题是dll的名称,以* .Resources.dll结尾-当我将程序集的名称更改为其他名称时,一切正常。 因此,我现在正在寻找NuGet软件包中的命名问题,并找到了以下文章:
Use NuGet to add a project assembly reference to a file named *.Resources.dll