admin管理员组

文章数量:1129001

I am trying to build a specifc projects (2 outof 7) from solution I want to restore the nuget also specific to those project I am using below yml task

- 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

package.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>

here buildConfiguration is having only two project to build while running the above task build is failing with below error Error CS0246: The type or namespace name 'IPNetwork' could not be found (are you missing a using directive or an assembly reference?) where nuget logs says IPAddress already added any thought ?

Nuget Log:

025-01-08T13:16:20.1144283Z Acquiring lock for the installation of IPNetwork2 2.1.1 2025-01-08T13:16:20.1144434Z Acquired lock for the installation of CosmosSdk 3310871.1 2025-01-08T13:16:20.1144593Z Acquired lock for the installation of IPNetwork2 2.1.1 2025-01-08T13:16:20.1144743Z Acquired lock for the installation of NUnit 3.8.1 2025-01-08T13:16:20.1144991Z OK .numerics.vectors/4.6.0/system.numerics.vectors.4.6.0.nupkg 425ms 2025-01-08T13:16:20.1145245Z Acquiring lock for the installation of System.Numerics.Vectors 4.6.0 2025-01-08T13:16:20.1145419Z Acquired lock for the installation of System.Numerics.Vectors 4.6.0 2025-01-08T13:16:20.1145812Z Installed IPNetwork2 2.1.1 from .DSP.Telemetry/nuget/v3/index.json with content hash 8OyRRCuOtXn/cVRMMqSj4pFjVKUj3s+4jUpeyF3+hjPYB2jN3BPel3HpKUG3gp/ZhTtUON8alRUNWz4qxmpzBQ==. 2025-01-08T13:16:20.1146093Z Adding package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1146423Z OK .du.telemetry.parseutils/1.13.0/microsoft.du.telemetry.parseutils.1.13.0.nupkg 623ms 2025-01-08T13:16:20.1146700Z Acquiring lock for the installation of Microsoft.DU.Telemetry.ParseUtils 1.13.0 2025-01-08T13:16:20.1146938Z Acquired lock for the installation of Microsoft.DU.Telemetry.ParseUtils 1.13.0 2025-01-08T13:16:20.1147248Z Installed Microsoft.DU.Telemetry.ParseUtils 1.13.0 from .DSP.Telemetry/nuget/v3/index.json with content hash eOv3YWiWBsM1UAvOqu77IdjZx/eYyOzHePPcqFKZaCuJVxguIv8j9jbSCebesl4cGqKSEyeyRTnOpqe6qeSs8g==. 2025-01-08T13:16:20.1147562Z Adding package 'Microsoft.DU.Telemetry.ParseUtils.1.13.0' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1147742Z Added package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1147995Z Added package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' from source '

I am trying to build a specifc projects (2 outof 7) from solution I want to restore the nuget also specific to those project I am using below yml task

- 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

package.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>

here buildConfiguration is having only two project to build while running the above task build is failing with below error Error CS0246: The type or namespace name 'IPNetwork' could not be found (are you missing a using directive or an assembly reference?) where nuget logs says IPAddress already added any thought ?

Nuget Log:

025-01-08T13:16:20.1144283Z Acquiring lock for the installation of IPNetwork2 2.1.1 2025-01-08T13:16:20.1144434Z Acquired lock for the installation of CosmosSdk 3310871.1 2025-01-08T13:16:20.1144593Z Acquired lock for the installation of IPNetwork2 2.1.1 2025-01-08T13:16:20.1144743Z Acquired lock for the installation of NUnit 3.8.1 2025-01-08T13:16:20.1144991Z OK 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 Acquiring lock for the installation of System.Numerics.Vectors 4.6.0 2025-01-08T13:16:20.1145419Z Acquired lock for the installation of System.Numerics.Vectors 4.6.0 2025-01-08T13:16:20.1145812Z Installed IPNetwork2 2.1.1 from https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/RSD.DSP.Telemetry/nuget/v3/index.json with content hash 8OyRRCuOtXn/cVRMMqSj4pFjVKUj3s+4jUpeyF3+hjPYB2jN3BPel3HpKUG3gp/ZhTtUON8alRUNWz4qxmpzBQ==. 2025-01-08T13:16:20.1146093Z Adding package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1146423Z OK https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/73d392bb-70fe-4406-9869-04ec760d4187/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 Acquiring lock for the installation of Microsoft.DU.Telemetry.ParseUtils 1.13.0 2025-01-08T13:16:20.1146938Z Acquired lock for the installation of Microsoft.DU.Telemetry.ParseUtils 1.13.0 2025-01-08T13:16:20.1147248Z Installed Microsoft.DU.Telemetry.ParseUtils 1.13.0 from https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-6923807c7e83/_packaging/RSD.DSP.Telemetry/nuget/v3/index.json with content hash eOv3YWiWBsM1UAvOqu77IdjZx/eYyOzHePPcqFKZaCuJVxguIv8j9jbSCebesl4cGqKSEyeyRTnOpqe6qeSs8g==. 2025-01-08T13:16:20.1147562Z Adding package 'Microsoft.DU.Telemetry.ParseUtils.1.13.0' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1147742Z Added package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' 2025-01-08T13:16:20.1147995Z Added package 'IPNetwork2.2.1.1' to folder 'C:__w\1\b\packages' from source 'https://microsoft.pkgs.visualstudio.com/e8efa521-db8e-4531-9cd8-

Share Improve this question edited Jan 8 at 18:09 bryanbcook 17.6k2 gold badges44 silver badges73 bronze badges asked Jan 8 at 16:43 ramram 3435 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You are downloading the packages to $(Build.BinariesDirectory) but when you are compiling, there isn't anything telling the compiler to resolve packages from that folder, so you're seeing errors that look like the packages haven't been downloaded.

Your current setup looks like:

  • code location: <agent folder>\_work\<#num>\s\src\projectpath
  • current packages location: <agent folder>\_work\<#num>\b\pacakges

Easy fix is to download the packages where they will be resolved during compilation:

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

本文标签: yamlrestore nuget and build specific project from solutionStack Overflow