TFS中的Nuget恢复将包恢复到不同的目录 [英] Nuget restore in TFS restores packages to different directory

查看:102
本文介绍了TFS中的Nuget恢复将包恢复到不同的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 packages.confignuget.config 放在我的根文件夹中.

I placed packages.config and nuget.config to my root folder.

当我在我的开发机器上运行 nuget restore 时,包被恢复到 root/packages 文件夹中,如 nuget.config 中所述.

When I run nuget restore on my dev machine, packages is restored into root/packages folder as described in nuget.config.

但是,当我将 Nuget 安装程序构建步骤添加到我的 TFS2015 构建定义时,包将恢复到 ../Nuget/Packages,它在我的根文件夹之外.我在接下来的构建步骤中引用恢复的 nuget 包时遇到问题.

However, when I add Nuget Installer build step to my TFS2015 build definition, the packages are restored to ../Nuget/Packages, which is outside my root folder. I have a problem referencing the restored nuget packages in next build steps then.

  1. 为什么 nuget restore 在构建服务器上表现不同?
  2. 如何解决?

nuget.config:

nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="Packages" />
  </config>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSourceCredentials />
</configuration>

来自 NuGet 恢复构建步骤的日志:

log from NuGet restore build step:

Set workingFolder to default: C:\Builds\Agent\tasks\NuGetInstaller\0.1.18
Executing the powershell script: C:\Builds\Agent\tasks\NuGetInstaller\0.1.18\NuGetInstaller.ps1
Saving to C:\Windows\Agent\_work\2\NuGet\newNuGet.config
C:\Builds\Agent\agent\worker\tools\NuGet.exe restore "C:\Windows\Agent\_work\2\s\packages.config"  -NonInteractive -configfile "C:\Windows\Agent\_work\2\NuGet\newNuGet.config"
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
All packages listed in packages.config are already installed.

推荐答案

您也可以从命令行覆盖包目录,这可能会更容易,因为您可以使用构建:

You can override the packages directory from the commandline as well, that will probably be easier, as you can pass in the value using the pre-defined variables in the build:

Nuget Arguments: -PackagesDirectory "$(Build.SourcesDirectory)\Packages"

这篇关于TFS中的Nuget恢复将包恢复到不同的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆