0

我有一个 Web 项目(W),它引用了一个类库项目(C):

W --> C

C引用N1

C --> N1

N1是一个自定义 NuGet 包,它有两个依赖项(两者也是自定义 NuGet 包):N2 e N3,分别针对版本 2.1 或更高版本和 3.4 或更高版本。

N1 ---> N2 (>= 2.1)
   `--> N3 (>= 3.4)

当我将N1包添加到C时,N2有一个可用的 2.2 版本,因此 NuGet 得到了那个版本,而不是预期的 2.1。

问题从这里开始:当我构建W时,N2没有复制到Wbin文件夹中。我用谷歌搜索了一下,发现 Visual Studio 不会将不是“第一类依赖项”的依赖项(即C不直接使用的依赖项)复制到W的输出文件夹。我可以确认,因为当我将下面的方法添加到C中的任何类时,N2会被复制。

private void ForceCopyOfN2()
{
    var someObject = new N2.SomeClass();
}

此外,如果没有上述 hack,如果我将N2的版本降级到N1包依赖项指定的相同版本(即从 2.2 到 2.1),N2也会被复制。

所以我猜这是 NuGet 的一个问题。有没有人经历过这样的事情?

4

1 回答 1

-1

I was not able to repro this with VS 2012 targeting 4.5, here is what I tried
1. Create new web application project
2. Create new class library
3. Add reference from web application to the class library
4. in class library PM> install-package windowsAzure.servicebus

Attempting to resolve dependency 'Microsoft.WindowsAzure.ConfigurationManager (≥ 1.7.0.0)'. You are downloading Microsoft.WindowsAzure.ConfigurationManager from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkID=235167. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.

Successfully installed 'Microsoft.WindowsAzure.ConfigurationManager 1.7.0.3'. You are downloading WindowsAzure.ServiceBus from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=218949. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. Successfully installed 'WindowsAzure.ServiceBus 1.8.0.0'.

Successfully added 'Microsoft.WindowsAzure.ConfigurationManager 1.7.0.3' to ClassLibrary1.
Successfully added 'WindowsAzure.ServiceBus 1.8.0.0' to ClassLibrary1.
5. where service bus is dependent on configuration with >=1.7 and 1.8 version of configurationmanage is installed
6. build the classlibrary and then webapplication solution, refresh the solution explorer. For my solution I saw classlibrary, servicebus and configurationmanager are dropped in the bin folder. (not sure why but i saw the files dropped after I tried building classlibrary once again after adding the reference)

Is there something I am missing here?

于 2012-12-01T01:39:47.573 回答