【问题标题】:Why is my repositoryPath ignored in Azure DevOps / TFS?为什么 Azure DevOps / TFS 中忽略了我的 repositoryPath?
【发布时间】:2020-06-04 04:24:44
【问题描述】:

首先,我有一个 NuGet.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value=".\ExternalReferences\Packages" />
      <solution>
        <add key="disableSourceControlIntegration" value="true" />
      </solution>
  </config>
</configuration>

在我的dev 分支的根目录中。我的工作是,我的dev 分支中的每个项目都将包恢复到\dev\ExternalReferences\Packages,这在本地运行良好。

我正在尝试通过 TFS (VisualStudio Team Services/DevOps) 为我的 CI-Build 引入 Azure Pipelines。

但是,TFS 将包恢复到错误的文件夹 \dev\packages(其中 \devD:\a\9\s\)而不是 \dev\ExternalReferences\Packages

Acquired lock for the installation of Newtonsoft.Json 12.0.3
Installing Newtonsoft.Json 12.0.3.
Adding package 'Microsoft.Extensions.Logging.Abstractions.2.2.0' to folder 'D:\a\9\s\packages'

这会在稍后破坏构建(需要ExternalReferences\Packages):

PrepareForBuild:
  Creating directory "bin\Release\".
  Creating directory "obj\Release\".
ResolveAssemblyReferences:
  Primary reference "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL".
##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\9\s\Conwell.WebServices.Google\Conwell.WebServices.Google.csproj]

知道如何让 NuGet 恢复到正确的目录吗?

我刚刚为项目类型 Asp.NET 创建了一个标准管道

【问题讨论】:

    标签: c# tfs azure-devops continuous-integration nuget


    【解决方案1】:

    为什么我的 repositoryPath 在 Azure DevOps / TFS 中被忽略?

    由于 nuget restore 任务将包还原到错误的文件夹 \dev\packages,因此 NuGet.Config 中的设置 repositoryPath 似乎被忽略了。

    要解决此问题,您可以尝试在设置 nuget 还原任务时指定nuget.config,以确保您已使用NuGet.Config

    那么我的nuget.config 看起来像:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="AzureDevOpsFeed" value="https://pkgs.dev.azure.com/xxxn/_packaging/xxx/nuget/v3/index.json" />
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
      </packageSources>
    
      <config>
        <add key="repositoryPath" value=".\ExternalReferences\Packages" />
      </config>
    
    </configuration>
    

    然后,作为测试结果,我可以在文件夹ExternalReferences\Packages中获取包:

    希望这会有所帮助。

    【讨论】:

    • 谢谢。但是这个解决方案的问题是,它现在将其安装到 Nuget\ExternalReferences 而不是 ExternalReferences :( 有什么想法吗?
    【解决方案2】:

    作为一种解决方法,我直接配置了目录:

    转到管道,然后编辑:

    转到 NuGet 还原、高级和目标目录:

    我仍然愿意接受选择,这将尊重NuGet.Config

    【讨论】:

      猜你喜欢
      • 2013-09-30
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 2011-12-31
      • 2018-03-12
      • 1970-01-01
      相关资源
      最近更新 更多