1

If I have NuGet.config file with two sources retrieved from Artifactory.

For development purposes, one would want source to come from local packages if needed.

What is the best approach to go about that? 1) Having two Nuget.config, one for local development and one for production? 2) Include backup sources for nuget.config within same file? 3) Something else?

I guess the question is more about process to make development process easier. The NuGet.Config file is to be copied to Docker container to be part of that image.

For reference, here are the contents of the NuGet.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="Internal-Packages" value="http://artifactory.mycompany.corp:8081/artifactory/api/nuget/Internal-Packages" />
    <add key="External-Packages" value="http://artifactory.mycompany.corp:8081/artifactory/api/nuget/External-Packages" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>
Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152

1 Answers1

0

NuGet uses a global cache automatically, without needing to update your NuGet config. If the packages are available in the global cache it uses them from there, otherwise it goes and looks in the artifactory sources you defined in your config. In other words, the same config for development and production does what you want.

From the docs:

When asked to retrieve a package, NuGet first looks in theĀ global-packagesĀ folder.

rbennett485
  • 1,907
  • 15
  • 24