[英]Assembly reference not being added with custom nuget package
I've got two nuget packages where one depends on the other. 我有两个nuget包,其中一个依赖于另一个。 When installing the second one, an assembly reference for the assembly in the first package gets correctly added to the project references, however I'm somehow unable to add the latter one. 在安装第二个程序包时,第一个程序包中程序集的程序集引用会正确添加到项目引用中,但是我不知何故无法添加后者。 Is there something wrong with my spec? 我的规格有问题吗?
// first
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>first</id>
...
</metadata>
<files>
<file src="..\src\MyFirstProject\bin\v4.0\MyFirstProject.dll" target="lib\net40-client\MyFirstProject.dll" />
<file src="..\src\MyFirstProject\bin\v4.0\MyFirstProject.xml" target="lib\net40-client\MyFirstProject.xml" />
<file src="..\src\MyFirstProject\bin\v4.5\MyFirstProject.dll" target="lib\net45\MyFirstProject.dll" />
<file src="..\src\MyFirstProject\bin\v4.5\MyFirstProject.xml" target="lib\net45\MyFirstProject.xml" />
<file src="..\src\MyFirstProject\bin\v4.6\MyFirstProject.dll" target="lib\net46\MyFirstProject.dll" />
<file src="..\src\MyFirstProject\bin\v4.6\MyFirstProject.xml" target="lib\net46\MyFirstProject.xml" />
</files>
</package>
// second
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>second</id>
...
<dependencies>
<dependency id="first" ...
</dependencies
</metadata>
<files>
<file src="..\src\MySecondProject\bin\v4.6\MySecondProject.dll" target="lib\net46\MySecondProject.dll" />
<file src="..\src\MySecondProject\bin\v4.6\MySecondProject.xml" target="lib\net46\MySecondProject.xml" />
</files>
</package>
The second project is only available for .NET4.6 since I'm using some framework specific features shipped with this release. 第二个项目仅适用于.NET4.6,因为我正在使用此发行版附带的一些特定于框架的功能。 The target project I'm trying to install the package to is also a .NET4.6 project. 我尝试将软件包安装到的目标项目也是.NET4.6项目。
Validated: 验证:
lib\\
folder 程序集位于lib\\
文件夹中 packages.config
with the right framework version is made 使用正确的框架版本在packages.config
输入 Nevermind, I fixed it. 没关系,我已修复它。
The problem was the content of the packages.config
. 问题是packages.config
的内容。 I initially created the target project as a .NET4.5 project and downloaded the .NET4.6 nuget package which caused the assembly reference to not being added. 我最初将目标项目创建为.NET4.5项目,并下载了.NET4.6 nuget程序包,该程序包导致未添加程序集引用。 After I noticed my mistake, I switched over to .NET4.6 as the projects platform and adjusted the package version in the packages.config
manually, but somehow VS memorized that setting so it didn't change anything. 注意到错误之后,我切换到了.NET4.6作为项目平台,并手动调整了packages.config
的软件包版本,但是VS以某种方式记住了该设置,因此它没有任何改变。 Only after I completely removed every package from the package.config
and installed them again, it magically started to work. 仅当我从package.config
完全删除每个软件包并再次安装它们后,它神奇地开始工作。 Weird. 奇怪的。 :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.