恢复 nuget 并从解决方案构建特定项目

问题描述 投票:0回答:1

我正在尝试从解决方案构建一个特定的项目(7 个中的 2 个),我想恢复也特定于我在下面 yml 任务中使用的那些项目的 nuget

- task: NuGetCommand@2
  displayName: 'ScopeLibs: NuGet Restore for config Test Utils'
  continueOnError: true
  inputs:
    packagesToRestore: 'src/projectpath/packages.config'
    feedsToUse: config
    nugetConfigPath: NuGet.config
    restoreDirectory: '$(Build.BinariesDirectory)/packages'
    arguments: '-nocache'
    
- task: VSBuild@1
  displayName: '2 Build ConfigUtils Project'
  continueOnError: true
  inputs:
    solution: $(ScopeLibs)  # Path to your specific project file
    vsVersion: '16.0'
    configuration: $(buildConfiguration)  
    clean: true  # Clean the build output before building
    platform: $(buildPlatform)
    #restoreNuGetPackages: true  # Ensure NuGet packages are restored

包.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
   <package id="IPNetwork2" version="2.1.1" targetFramework="net472" />
   <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
   <package id="NUnit" version="3.8.1" targetFramework="net472" />
   <package id="System.Buffers" version="4.6.0" targetFramework="net472" />
   <package id="System.Collections.Immutable" version="9.0.0" targetFramework="net472" />
   <package id="System.Memory" version="4.6.0" targetFramework="net472" />
   <package id="System.Net.NetworkInformation" version="4.3.0" targetFramework="net472" />
   <package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net472" />
   <package id="System.Reflection.Metadata" version="9.0.0" targetFramework="net472" />
   <package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net472" />
</packages>

此处 buildConfiguration 只有两个项目需要构建,而运行上述任务构建失败并出现以下错误

Error CS0246: The type or namespace name 'IPNetwork' could not be found (are you missing a using directive or an assembly reference?)
nuget 日志中说 IPAddress 已经添加了任何想法?

Nuget 日志:

025-01-08T13:16:20.1144283Z 获取安装锁 IPNetwork2 2.1.1 2025-01-08T13:16:20.1144434Z 已获取锁定 安装 CosmosSdk 3310871.1 2025-01-08T13:16:20.1144593Z 获得IPNetwork2 2.1.1安装的锁定 2025-01-08T13:16:20.1144743Z 获得安装锁 NUnit 3.8.1 2025-01-08T13:16:20.1144991Z 好的 https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/73d392bb-70fe- 4406-9869-04ec760d4187/nuget/v3/flat2/system.numerics.vectors/4.6.0/system.numerics.vectors.4.6.0.nupkg 425ms 2025-01-08T13:16:20.1145245Z 获取安装锁定 已获取 System.Numerics.Vectors 4.6.0 2025-01-08T13:16:20.1145419Z System.Numerics.Vectors 4.6.0 安装的锁定 2025-01-08T13:16:20.1145812Z 安装了 IPNetwork2 2.1.1 https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/RSD.DSP.Telemetry/nuget/v3/index.json 带有内容哈希 8OyRRCuOtXn/cVRMMqSj4pFjVKUj3s+4jUpeyF3+hjPYB2jN3BPel3HpKUG3gp/ZhTtUON8alRUNWz4qxmpzBQ==。 2025-01-08T13:16:20.1146093Z 将包“IPNetwork2.2.1.1”添加到 文件夹 'C:__w \packages' 2025-01-08T13:16:20.1146423Z 确定 https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/73d392bb-70fe-4406-9869-0 4ec760d4187/nuget/v3/flat2/microsoft.du.telemetry.parseutils/1.13.0/microsoft.du.telemetry.parseutils.1.13.0.nupkg 623ms 2025-01-08T13:16:20.1146700Z 获取安装锁定 Microsoft.DU.Telemetry.ParseUtils 1.13.0 的 2025-01-08T13:16:20.1146938Z 获得安装锁 Microsoft.DU.Telemetry.ParseUtils 1.13.0 2025-01-08T13:16:20.1147248Z 从以下位置安装了 Microsoft.DU.Telemetry.ParseUtils 1.13.0 https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/RSD.DSP.Telemetry/nuget/v3/index.json 带有内容哈希 eOv3YWiWBsM1UAvOqu77IdjZx/eYyOzHePPcqFKZaCuJVxguIv8j9jbSCebesl4cGqKSEyeyRTnOpqe6qeSs8g==。 2025-01-08T13:16:20.1147562Z 添加包 “Microsoft.DU.Telemetry.ParseUtils.1.13.0”到文件夹 'C:__w \packages' 2025-01-08T13:16:20.1147742Z 添加了包 “IPNetwork2.2.1.1”到文件夹“C:__w \packages” 2025-01-08T13:16:20.1147995Z 添加了包“IPNetwork2.2.1.1” 源文件夹“C:__w \packages” 'https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-

build log

yaml azure-pipelines nuget-package-restore msbuild-task
1个回答
0
投票

您正在将软件包下载到

$(Build.BinariesDirectory)
,但是在编译时,没有任何信息告诉编译器从该文件夹解析软件包,因此您会看到看起来像是尚未下载软件包的错误。

您当前的设置如下所示:

  • 代码位置:
    <agent folder>\_work\<#num>\s\src\projectpath
  • 当前包裹位置:
    <agent folder>\_work\<#num>\b\pacakges

简单的修复方法是下载将在编译过程中解决的软件包:

- task: NuGetCommand@2
  displayName: 'ScopeLibs: NuGet Restore for config Test Utils'
  continueOnError: true
  inputs:
    packagesToRestore: 'src/projectpath/packages.config'
    feedsToUse: config
    nugetConfigPath: NuGet.config
    restoreDirectory: 'src/projectpath/packages'
    arguments: '-nocache'
© www.soinside.com 2019 - 2024. All rights reserved.