Skip to content

Move NuGet feeds from Artifactory or Nexus to CloudRepo

Your NuGet packages move into a hosted repository in CloudRepo, and nuget.org comes through a proxy. A group puts the two behind one URL, and dotnet restores through it. Your old server is only read. It keeps running, unchanged, until your builds restore from CloudRepo.

In Artifactory In Nexus 3 In CloudRepo
Local NuGet repository Hosted NuGet repository A hosted NuGet repository. You push your packages to it.
Remote repository of nuget.org Proxy repository of nuget.org A NuGet proxy of nuget.org. Nothing to move: it fetches each package the first time a build asks, and keeps a copy.
Virtual NuGet repository Group NuGet repository A NuGet group of your hosted repository and your proxy. One URL serves both.

A NuGet proxy reads nuget.org only. A group or a proxy takes no push: you push to the hosted repository and restore through the group. The other Artifactory and Nexus terms are on Artifactory and Nexus terms in CloudRepo.

Create a hosted repository, a proxy of nuget.org and a group of the two, and a repository token that covers all three, as Use NuGet with dotnet shows.

The tool can do steps 2 and 3 for you. cloudrepo-migrate reads each package from your server, pushes it to your hosted repository in CloudRepo, and reads it back to check it.

Used on this page only, never saved. Never enter a token or password here.

This page’s commands are for version 0.15.0. Install that version and check it:

Terminal
pipx install cloudrepo-migrate==0.15.0
cloudrepo-migrate --version

No pipx? pip install cloudrepo-migrate==0.15.0 in a virtual environment works too. The check prints cloudrepo-migrate 0.15.0. Another number means pipx kept an install you already had: run pipx install --force cloudrepo-migrate==0.15.0.

Set your credentials as Nexus 3 or Artifactory shows. Name your hosted repository as your old one is named, or map the two with --repo SOURCE=TARGET.

NuGet moves only when you name it: a run without --include nuget skips each NuGet repository, says so, and can still exit 0 with no NuGet moved. On Nexus 3, a dry run lists what would move and what it skips, and uploads nothing:

Terminal
cloudrepo-migrate nexus3 \
--nexus-url https://nexus.example.com \
--org your-org \
--include nuget \
--dry-run

An Artifactory run takes the same flag. It is experimental: it is tested against a stand-in for Artifactory’s API, not yet against a real Artifactory server.

Terminal
cloudrepo-migrate artifactory \
--artifactory-url https://artifactory.example.com/artifactory \
--org your-org \
--include nuget \
--dry-run

When the list looks right, run the same command without --dry-run, and keep --include nuget. Then go to step 4. Nexus 2 has no NuGet move. To move by hand, or from Nexus 2, export each local or hosted NuGet repository. A remote, proxy, virtual or group repository has nothing to export.

  • Artifactory. Run the loop in step 3 of Migrate from JFrog Artifactory, with REPO set to the key of your local NuGet repository. It saves every file under export/<repository>/, and JFrog’s NuGet page says each package is a .nupkg file.
  • Nexus 3. Run the loop in step 3 of Migrate from Sonatype Nexus Repository, with REPO set to the name of your hosted NuGet repository. It saves every asset the assets API lists under export/<repository>/. On Nexus 3.76.0 a package is saved at <id>/<version>, with no file extension, such as export/nuget-hosted/Acme.Logging/1.02.0.0+build.7: the version is the one its .nuspec writes. Step 3 gives each one the .nupkg name the push takes.
  • Nexus 2. List your packages with your server’s API, as Sonatype’s Nexus Repository 2 help shows, and download each .nupkg.

Add your hosted repository to your nuget.config as the source cloudrepo-push, as Push a package shows, and set CLOUDREPO_TOKEN to your repository token. Then put the packages you exported in one folder named out.

From Artifactory, copy each .nupkg. Put your repository’s key or name in place of nuget-local:

Terminal
mkdir -p out
find export/nuget-local -name '*.nupkg' -exec cp {} out/ \;

From Nexus 3, copy each package under the name the push takes, <id>.<version>.nupkg. Put your repository’s name in place of nuget-hosted:

Terminal
mkdir -p out
find export/nuget-hosted -mindepth 2 -maxdepth 2 -type f | while IFS= read -r package; do
cp "$package" "out/$(basename "$(dirname "$package")").$(basename "$package").nupkg"
done

Then push them all:

Terminal
dotnet nuget push out/*.nupkg --source cloudrepo-push

A package can be up to 250 MiB, the same limit as nuget.org. A bigger push is refused with a message that says so.

CloudRepo refuses a version it already holds with 409 and says it already exists in this repository. So if a push stops partway, fix the cause and run it again with --skip-duplicate, which Microsoft documents as treating a 409 Conflict as a warning so the other pushes continue.

Point each nuget.config at your CloudRepo group, as Set up dotnet shows. Each old URL, as Sonatype’s and JFrog’s examples write it, and the URL that replaces it:

URL in Nexus or Artifactory URL on CloudRepo
https://example.nexus.com/repository/nuget-group/index.json https://your-org.mycloudrepo.io/repositories/your-repo/index.json
http://example.nexus.com/repository/nuget-hosted/index.json https://your-org.mycloudrepo.io/repositories/your-hosted-repo/index.json
https://company.jfrog.io/artifactory/api/nuget/v3/john-nuget-local/index.json https://your-org.mycloudrepo.io/repositories/your-hosted-repo/index.json

The Nexus forms are from Sonatype’s NuGet setup page and the Artifactory form from JFrog’s NuGet page. On Nexus 2, copy the old URL from your own nuget.config. The new file names %CLOUDREPO_TOKEN%, so it holds no token and you can commit it.

This search lists every nuget.config in a repository that still names an old server. Run it in each repository you have:

Terminal
git grep -n -i -E '/repository/|/artifactory/' -- ':(icase)*nuget.config'

A URL can hide outside your repositories too, in CI variables and build images. Beyond the files lists where to look.

Restore in a fresh CI job, with no packages cached and no route to your old server:

Terminal
dotnet restore

With <clear /> in your nuget.config, the group is your only source, so a package you missed fails now and not on the day you switch the old server off. Leave the old server running until every build restores this way.

View as Markdown