.net NuGet 包还原找不到包,没有源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17151709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NuGet Package Restore cannot find package, has no Source
提问by Luke Puplett
I have a package on my TeamCity NuGet feed, built by TeamCity, but a dependent TC project cannot see it during package restore.
我的 TeamCity NuGet 提要中有一个由 TeamCity 构建的包,但在包还原期间,依赖的 TC 项目看不到它。
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9): Unable to find version '1.0.17.0' of package 'MarkLogicManager40'.
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9): error MSB3073: The command ""E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.exe" install "E:\TeamCity-BuildAgent\work\62023563850993a7\ProductMvc\packages.config" -source "" -RequireConsent -solutionDir "E:\TeamCity-BuildAgent\work\62023563850993a7\Web\ "" exited with code 1.
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9):无法找到包“MarkLogicManager40”的“1.0.17.0”版本。
[14:05:02][Exec] E:\TeamCity-BuildAgent\work\62023563850993a7\Web.nuget\nuget.targets(88, 9): 错误 MSB3073: 命令 ""E:\TeamCity-BuildAgent\work\ 62023563850993a7\Web.nuget\nuget.exe"安装"E:\TeamCity-BuildAgent\work\62023563850993a7\ProductMvc\packages.config" -source "" -RequireConsent -solutionDir "E:\TeamCity-BuildAgent\work\6202356395 \ "" 以代码 1 退出。
Note that the sourceparameter in the NuGet command line is empty. Could this be the cause?
请注意,sourceNuGet 命令行中的参数为空。这可能是原因吗?
回答by abatishchev
As of today, NuGet.targets has the following way to specify custom feed(s):
截至今天,NuGet.targets 有以下方式来指定自定义提要:
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="\MyShare" />
<PackageSource Include="http://MyServer/" />
</ItemGroup>
Another option is to put NuGet.confignext to the solution file:
另一种选择是将NuGet.config放在解决方案文件旁边:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="MyShare" value="\MyShare" />
<add key="MyServer" value="http://MyServer" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
回答by Luke Puplett
Apparently NuGet custom feeds are set not via anything in the solution or project files, or nuget.config in the solution, but in the nuget.config in the developer's profile.
显然,NuGet 自定义提要不是通过解决方案或项目文件中的任何内容设置的,也不是通过解决方案中的 nuget.config 设置的,而是通过开发人员配置文件中的 nuget.config 设置的。
Over on TeamCity, there's no check by the agent of this config file, or writing to it, to ensure it contains the feed for the TeamCity server itself.
在 TeamCity 上,代理不会检查或写入此配置文件,以确保它包含 TeamCity 服务器本身的提要。
So package restore on TC using a custom TC feed won't 'just work'. You have to waste hundreds of pounds of client's money chasing your tail to discover all this and then set/copy your nuget.config from your profile into the profile of the user account running the build agent.
因此,使用自定义 TC 提要在 TC 上进行包还原不会“正常工作”。您必须浪费数百英镑的客户资金追逐您的尾巴以发现所有这些,然后将您的 nuget.config 从您的配置文件设置/复制到运行构建代理的用户帐户的配置文件中。
Horrible.
可怕。

