Skip to content

[BUG]: dotnet restore with source mapping and private feed does not work #20910

Open
@mortenn

Description

@mortenn

New issue checklist

Task name

DotNetCoreCLI

Task version

2

Issue Description

I am building a solution in a pipeline which uses dotnet restore to restore nugets.

After adding a private Azure DevOps feed to nuget.config, it did not work, because the task used a "temporary" nuget.config file.

Adding a vstsFeed to the task did not work, because Centralized Package Management requires source mapping.

Changing the task to use config rather than select does not work because it adds a "feed-" prefix to the feed key, which I cannot do in the source mapping or it will break for developers.

As a workaround, I added an extra DevOps-Nuget.Config where the key just "private" in the source list, but "feed-private" in the source mapping section.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

N/A

Relevant log output

error NU1101: Unable to find package FooSys.Events. No packages exist with this id in source(s): NuGetOrg [/home/vsts/work/1/s/FooSys.sln]

error NU1507: Warning As Error: There are 2 package sources defined in your configuration. When using central package management, please map your package sources with package source mapping

error NU1100: Unable to resolve 'FooSys.Events (>= 1.2.77-beta-gea926e2040)' for 'net9.0'. PackageSourceMapping is enabled, the following source(s) were not considered: feed-private, nuget.org. [/home/vsts/work/1/s/FooSys.sln]

error NU1100: Unable to resolve 'FooSys.Events (>= 1.2.77-beta-gea926e2040)' for 'net9.0'. PackageSourceMapping is enabled, the following source(s) were not considered: feed-feed-FooSys, nuget.org. [/home/vsts/work/1/s/FooSys.sln]

Full task logs with system.debug enabled

No response

Repro steps

- task: DotNetCoreCLI@2
    displayName: 'Restore NuGet packages'
    inputs:
      command: 'restore'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions