Richard Barraclough
Richard Barraclough

Reputation: 2964

dotnet restore in Azure pipeline

I need to restore packages that are produced by other pipelines

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    restoreSolution: 'build.sln'
    #feedsToUse: 'select'
    #vstsFeed: 'Some-DLLs'
    # includeNuGetOrg: true
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'

Where nuget.config is

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="Some-DLLs" value="https://tfs.co.net/tfs/collection/_packaging/Some-DLLs/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredetials>
    <Some-DLLs>
      <add key="Username" value="DOMAIN\richard.barraclough" />
      <add key="ClearTextPassword" value="un33xgbppqqbeowgwq6b2xn35gkohzbhrz54ohitxefhc5hgjsla" /> <!-- A PAT -->
    </Some-DLLs>
  </packageSourceCredetials>
</configuration>

However, he step fails

         C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error : Unable to load the service index for source https://tfs.co.net/tfs/collection/_packaging/Some-DLLs/nuget/v3/index.json. [C:\agent\_work\19\s\build.sln]
       C:\Program Files\dotnet\sdk\5.0.104\NuGet.targets(131,5): error :   No credentials are available in the security package [C:\agent\_work\19\s\build.sln]

This also doesn't work

- task: CmdLine@2
  inputs:
    script: 'dotnet restore --configfile nuget.config proj\proj.csproj' 

Upvotes: 0

Views: 1965

Answers (1)

Bright Ran-MSFT
Bright Ran-MSFT

Reputation: 13534

Please check with the following things:

  1. If the Artifacts feed and the pipeline are in the same project, you can use the restore task to directly restore the packages from the feed to the pipeline.

  2. If the Artifacts feed and the pipeline are in different projects but in the same organization/collection.

    • If the feed is project-scoped, you can open this feed and navigate to "Feed settings" > "Views" > Select "Local" > Click "Edit" > Select "All feeds and people in <Your_Collection_Name>". With this way, all the pipelines in the same organization/collection are able to use the download the packages from the feed.

    enter image description here

    • If the feed is organization-scoped, you can use the restore task to directly restore the packages from the feed to the pipeline.
  3. If the feed is outside the current organization/collection, you need to create a NuGet service connection to access the feed.

    enter image description here

Upvotes: 1

Related Questions