nuget没有添加引用

时间:2016-03-09 08:33:14

标签: .net nuget

我有一个奇怪的问题是将参考添加到项目的参考资料中。首先让我展示一下我的设置。

我有两个包:Framework.nuspec和Resources.nuspec。每个都包含一个DLL。 Framework.nuspec中的dll为88KB,Resources.nuspec中的dll为13605 KB。

Framework.nuspec如下:

<? xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Framework</id>
    <version>1.0.2</version>
    <title>Framework</title>
    <authors>Author</authors>
    <owners>Owner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Core functionality</description>
    <copyright>Copyright © 2016 Company</copyright>
  </metadata>
  <files>
    <file src="bin\Framework.dll" target="lib\net461" />
  </files>
</package>

Resources.nuspec如下:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Resources</id>
    <version>1.0.2</version>
    <title>Resources</title>
    <authors>Author</authors>
    <owners>Owner</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>All resources</description>
    <copyright>Copyright © 2016 Company</copyright>
  </metadata>
  <files>
    <file src="bin\Resources.dll" target="lib\net461" />
  </files>
</package>

正如您所看到的,包的设置很简单,看起来完全一样,但名称和文件除外。然后打包这些包的命令很简单:nuget.exe pack Framework.nuspecnuget.exe pack Resources.nuspec

现在发生的事情是,当我添加Framework包时,它会正确添加引用: Framework

但是当我添加资源包时,它根本没有添加引用: Resources

我做错了吗? 这是我需要去报告的错误还是已经报告错过的错误? 以前有人遇到过这个吗? 是因为我使用的是net461吗?

我一遍又一遍地创建了这些包,但没有成功。

非常感谢任何反馈。

亲切的问候, Willem Toerien

更新:以下是添加资源包的输出:

Attempting to gather dependencies information for package 'Resources.1.0.2' with respect to project 'ConsoleApplication1', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'Resources.1.0.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Resources.1.0.2'
Resolved actions to install package 'Resources.1.0.2'
Adding package 'Resources.1.0.2' to folder 'C:\Users\wtoerien\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Resources.1.0.2' to folder 'C:\Users\wtoerien\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Resources.1.0.2' to 'packages.config'
Successfully installed 'Resources 1.0.2' to ConsoleApplication1
========== Finished ==========

如您所见,没有警告。

1 个答案:

答案 0 :(得分:3)

好的,经过一些游戏后,我发现了一些很奇怪的东西。只要我添加&#34; X&#34;对于所有资源,dll都会被添加! Resources.nuspecResourcesX.nuspecResources.dllResourcesX.dll以及nuspec文件中的标题。

那就是说,我的完整符号是Company.Framework.Plugin.Resources.dll,所以基本上当我将所有内容都更改为Company.Framework.Plug.ResourcesX.dll时它才有效。

这是nuspec:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Company.Framework.Plugin.ResourcesX</id>
    <version>1.0.2</version>
    <title>Company Web Resources Plugin</title>
    <authors>Company</authors>
    <owners>Company</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Core images and entity name definitions for Framework web applications.</description>
    <copyright>Copyright © 2016 Company, Inc.</copyright>
  </metadata>
  <files>
    <file src="bin\*.*" target="lib\net461" />
  </files>
</package>

结果如下:

Resources

输出如下:

Attempting to gather dependencies information for package 'Company.Framework.Plugin.ResourcesX.1.0.2' with respect to project 'ConsoleApplication1', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'Company.Framework.Plugin.ResourcesX.1.0.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Company.Framework.Plugin.ResourcesX.1.0.2'
Resolved actions to install package 'Company.Framework.Plugin.ResourcesX.1.0.2'
Adding package 'Company.Framework.Plugin.ResourcesX.1.0.2' to folder 'C:\Users\wtoerien\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Company.Framework.Plugin.ResourcesX.1.0.2' to folder 'C:\Users\wtoerien\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Company.Framework.Plugin.ResourcesX.1.0.2' to 'packages.config'
Successfully installed 'Company.Framework.Plugin.ResourcesX 1.0.2' to ConsoleApplication1
========== Finished ==========

因此在我看来,Resources名称存在阻止其被添加的内容。我会记录一个bug给nuget,但我想在此期间我们只需要解决它。

感谢。