如何获取myget包源?

时间:2013-06-24 13:31:43

标签: nuget myget

我正在使用myget作为我的Nuget包。因为我正在使用带凭据的私人Feed,所以我关注了此博客:http://www.xavierdecoster.com/deploying-to-azure-web-sites-using-nuget-package-restore-from-a-secured-feed

我的本​​地(项目)nuget.config(位于解决方案中的.nuget文件夹中)如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSource>
    <clear />

    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>

  </packageSource>
  <activePackageSource>
    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>
  </activePackageSource>
  <packageSourceCredentials>
    <EcareMyGet>
      <add key="Username" value="www.myget.org/raimond" />
      <add key="ClearTextPassword" value="wachtwoord" />
    </EcareMyGet>
  </packageSourceCredentials>
</configuration> 

在我的nuget.targets中,我根据博客更改了恢复命令:

<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)"   -NonInteractive   $(RequireConsentSwitch) -solutionDir "$(SolutionDir)\" -Verbosity detailed </RestoreCommand>

尽管如此,构建服务器仍然使用nuget.org作为源:

NuGet.exe sources
  Registered Sources:

    1.  https://nuget.org/api/v2/ [Enabled]
        https://nuget.org/api/v2/

谁知道解决方案?

2 个答案:

答案 0 :(得分:2)

答案:替换&lt; packageSource&gt;通过&lt; packageSources&gt;在nuget.config文件中

以下是导致答案的对话......

为了确定,您是否还阅读了禁用-RequireConsent开关的部分?

<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">
false
</RequireRestoreConsent>

另外,请确保未在MSBuild PackageSources元素中对其进行配置,默认情况下如下所示(未配置包源):

<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="https://my-nuget-source/nuget/" />
    -->
</ItemGroup>

如果您这样做了,那不是问题,请您分享一下输出日志的更多细节,以便我可以确定问题何时发生以及由什么命令引起?

答案 1 :(得分:0)

你写的是你使用“我的本地(项目)nuget.config”,这让我相信你的项目文件夹中有 nuget.config 文件

您可以阅读NuGet Config File here。在那里你会看到“NuGet首先从默认位置加载NuGet.config,然后加载任何名为NuGet.config的文件,从当前驱动器的根目录开始,到当前目录结束。”

这意味着,NuGet将从根目录到 nuget.exe 的位置一直在文件夹层次结构中查找配置,这通常位于下。解决方案根目录中的nuget 文件夹。这意味着它永远不会查看解决方案中的项目文件夹。因此,您可以尝试将 nuget.config 移动到解决方案文件夹,然后查看它是否已正确读取。

相关问题