Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

.net - NuGet Package Restore cannot find package, has no Source

I have a package on my TeamCity NuGet feed, built by TeamCity, but a dependent TC project cannot see it during package restore.

[14:05:02][Exec] E:TeamCity-BuildAgentwork62023563850993a7Web.nuget uget.targets(88, 9): Unable to find version '1.0.17.0' of package 'MarkLogicManager40'.

[14:05:02][Exec] E:TeamCity-BuildAgentwork62023563850993a7Web.nuget uget.targets(88, 9): error MSB3073: The command ""E:TeamCity-BuildAgentwork62023563850993a7Web.nuget uget.exe" install "E:TeamCity-BuildAgentwork62023563850993a7ProductMvcpackages.config" -source "" -RequireConsent -solutionDir "E:TeamCity-BuildAgentwork62023563850993a7Web "" exited with code 1.

Note that the source parameter in the NuGet command line is empty. Could this be the cause?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As of today, NuGet.targets has the following way to specify custom feed(s):

<ItemGroup Condition=" '$(PackageSources)' == '' ">
    <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%NuGetNuGet.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.config next to the solution file:

<?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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...