Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Verifying the package source mapping configuration #11959

Open
a-ctor opened this issue Jul 11, 2022 · 0 comments
Open

[Feature]: Verifying the package source mapping configuration #11959

a-ctor opened this issue Jul 11, 2022 · 0 comments
Assignees
Labels
Area:PackageSourceMapping Issues related to the package source mapping feature Priority:2 Issues for the current backlog. Type:Feature

Comments

@a-ctor
Copy link

a-ctor commented Jul 11, 2022

NuGet Product(s) Involved

NuGet.exe, dotnet.exe

The Elevator Pitch

With the new package source mapping it is possible to restrict certain packages to be restored from specific package sources. But there are scenarios with package source mapping where a local restore succeeds but fails on another machine. This happens when the packages are already cached locally and so the package source mapping is not considered when restoring. This is quite annoying when verifying the package source mapping as the Nuget package cache must be cleared to test a new configuration.

I propose adding an option that will check that all the required packages can be resolved from the package sources using the current package source mapping (skipping the local cache of course). The exact details are up for discussion.

Looking forward for you input on the matter :)

Additional Context and Details

Here is a step-by-step example of how to replicate the problem. Only after clearing the cache does it become clear that the package source mapping does not work.

  1. dotnet new classlib -n test -o .
  2. dotnet add test.csproj package NUnit: Install any package which is automatically restored and cached
  3. Add a Nuget.config which filters out the installed package using <packageSourceMapping> (see example below)
  4. dotnet restore: Does not fail because the package is cached
  5. Remove %USERPROFILE%\.nuget\packages\NUnit: Remove the package from the cache
  6. dotnet restore: Restore fails because the package source mapping must be used

Here is an example Nuget.config with a restrictive filter:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="Does not match the package" />
    </packageSource>
  </packageSourceMapping>
</configuration>
@jeffkl jeffkl added Area:PackageSourceMapping Issues related to the package source mapping feature and removed Triage:Untriaged labels Jul 17, 2022
@nkolev92 nkolev92 added the Priority:2 Issues for the current backlog. label Jul 18, 2022
@nkolev92 nkolev92 self-assigned this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:PackageSourceMapping Issues related to the package source mapping feature Priority:2 Issues for the current backlog. Type:Feature
Projects
None yet
Development

No branches or pull requests

3 participants