简体   繁体   English

程序集引用未与自定义nuget包一起添加

[英]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: 验证:

  • Target project is .NET4.6 目标项目是.NET4.6
  • Package can be correctly created 包可以正确创建
  • Assemblies reside in the lib\\ folder 程序集位于lib\\文件夹中
  • Assemblies are correctly being packed 组件正确包装
  • Nuget package gets correctly installed Nuget软件包已正确安装
  • Entry in 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.

相关问题 MSBuild:删除对通过 NuGet 添加的程序集的引用 - MSBuild: Remove Reference to Assembly added via NuGet 添加了 SharpFont nuget 但未找到对程序集的引用 - SharpFont nuget added but reference to Assembly not found 在Nuget包中添加对程序集的引用 - Add reference to assembly inside Nuget package ILMerge - “不允许未解析的程序集引用”,RestSharp Nuget package 在包文件夹中 - ILMerge - "Unresolved assembly reference not allowed", RestSharp Nuget package in the packages folder Nuget Install-Package成功,但没有添加引用到csproj - Nuget Install-Package successful but no reference added to csproj NuGet Package 管理问题 - 定位程序集的清单定义与程序集引用不匹配 - NuGet Package Management problem - The located assembly's manifest definition does not match the assembly reference 避免添加 nuget 包引用以支持程序集引用的可能性,包括。 依赖? - Possibility to avoid adding nuget package reference in favor of assembly reference incl. dependencies? 缺少程序集参考 - 确保 VS 为我的 nuget 包创建一个 .config 文件 - Missing assembly reference - ensure VS creates a .config file for my nuget package 与本地NuGet包的模糊引用 - Ambiguous reference with local NuGet package 如何在 .csproj 中引用 NuGet 包 - How to reference NuGet package in .csproj
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM