Skip to content

Add version check to packageSourceMapping #13351

Open
@Falco20019

Description

@Falco20019

NuGet Product(s) Involved

NuGet.exe, MSBuild.exe, dotnet.exe, NuGet SDK

The Elevator Pitch

packageSourceMapping should be able to not only have a pattern but also version-limited matching. This would allow to look for local builds detectable by version in a local cache.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSourceMapping>
    <clear />
    <packageSource key="Local package cache">
      <package pattern="*" version="*-loc*" />
    </packageSource>
    <packageSource key="github-remote">
      <package pattern="MyCompany.*" />
    </packageSource>
    <packageSource key="nuget-remote">
      <package pattern="*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

Additional Context and Details

Right now, to be able to use the local cache, you would need to add ALL patterns to the local cache for it to be checked as well as otherwise, it might not be the most specific one.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSourceMapping>
    <clear />
    <packageSource key="Local package cache">
      <package pattern="MyCompany.*" />
      <package pattern="*" />
    </packageSource>
    <packageSource key="github-remote">
      <package pattern="MyCompany.*" />
    </packageSource>
    <packageSource key="nuget-remote">
      <package pattern="*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

Resolving MyCompany.SomeLib in version 1.0.0-loc20240307115400 should try to resolve it from the Local package cache and github-remote. Version 1.0.0 is enough to be checked on github-remote.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area:PackageSourceMappingIssues related to the package source mapping featurePriority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.Type:Feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions