0

For a current project, we had to resort to C# for parts of the programming. After the leftpad-occurences in npm, I'd like to create a mirrored package repository for securing builds.

Since managing dependencies by hand is a hassle, is there an automated way to mirror a NuGet-Package including all dependencies on my local / shared drive?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
  • "*I'd like to create a mirrored package repository for securing builds*" - can you elaborate on this a little more? – TheGeneral Sep 16 '21 at 06:23
  • Hiya - i just posted an answer but i fear i might've misunderstood - could you explain a bit further? – sommmen Sep 16 '21 at 06:33

1 Answers1

2

You can setup a private nuget feed and host the packages there.

For example in azure devops we have Azure artifacts:

https://learn.microsoft.com/en-us/azure/devops/artifacts/start-using-azure-artifacts?view=azure-devops#get-started-with-azure-artifacts

In that case the nuget feed is a private feed and you can configure it to access the public nuget feed. any consumed packages will then also be kept on the private azure artifacts feed, meaning you always have the original package.

The nuget.org upstream source allows you to merge the contents of nuget.org into your feed such that the NuGet client can install packages from both locations without making multiple search queries. Enabling upstream sources also automatically enables saving of packages you use from the upstream source.

https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/upstream-sources?view=azure-devops

Also see: https://learn.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops

I've also seen people using MyGet: https://www.myget.org/

And another option is to just use a local folder as a nuget source.

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <!-- NuGet packages are now stored globally, see: https://stackoverflow.com/a/35809007/4122889 -->
  <!-- see: https://stackoverflow.com/a/53451805/4122889 -->
  <config>
    <add key="globalPackagesFolder" value=".\Packages" />
    <add key="repositoryPath" value=".\Packages" />
  </config>

  <!-- Setup for local packages, not in a nuget source -->
  <packageSources>
    <add key="My_Azure_Feed" value="https://pkgs.dev.azure.com/org/proj/_packaging/My_Azure_Feed/nuget/v3/index.json" />
    <!--<add key="LocalPackages" value="./LocalPackages" />-->

  </packageSources>
  <activePackageSource>
    <!-- this tells that all of them are active -->
    <!--<add key="All" value="(Aggregate source)" />-->
  </activePackageSource>

</configuration>
sommmen
  • 6,570
  • 2
  • 30
  • 51