# Move NuGet feeds from Artifactory or Nexus to CloudRepo

> Map your NuGet repositories, export your packages from Artifactory or Nexus, push them with dotnet, and restore through a CloudRepo group.

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.

> **Early access:** NuGet repositories are in early access.

## What maps to what

| 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](/docs/migrate/artifactory-and-nexus-terms.html).

## 1. Create your repositories

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](/docs/consume/nuget.html#create-your-repositories) shows.

## 2. Export your packages

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.

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

**Terminal**

```bash
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](/docs/migrate/from-nexus-3.html#2-run-it) or [Artifactory](/docs/migrate/from-artifactory.html#2-run-it) 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**

```bash
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**

```bash
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](/docs/migrate/from-jfrog.html#3-export-the-files), with `REPO` set to the key of your local NuGet repository. It saves every file under `export/<repository>/`, and [JFrog’s NuGet page](https://docs.jfrog.com/artifactory/docs/nuget-repositories) says each package is a `.nupkg` file.
- **Nexus 3.** Run the loop in step 3 of [Migrate from Sonatype Nexus Repository](/docs/migrate/from-nexus.html#3-export-the-files), with `REPO` set to the name of your hosted NuGet repository. It saves every asset the [assets API](https://help.sonatype.com/en/assets-api.html) 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](https://help.sonatype.com/en/repository-manager-2.html) shows, and download each `.nupkg`.

## 3. Push them to CloudRepo

Add your hosted repository to your `nuget.config` as the source `cloudrepo-push`, as [Push a package](/docs/consume/nuget.html#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**

```bash
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**

```bash
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**

```bash
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](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push) as treating a 409 Conflict as a warning so the other pushes continue.

## 4. Repoint your builds

Point each `nuget.config` at your CloudRepo group, as [Set up dotnet](/docs/consume/nuget.html#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](https://help.sonatype.com/en/configure-nuget-with-nexus.html) and the Artifactory form from [JFrog’s NuGet page](https://docs.jfrog.com/artifactory/docs/nuget-repositories). 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**

```bash
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](/docs/migrate/repoint-builds.html#beyond-the-files) lists where to look.

## 5. Check the move

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

**Terminal**

```bash
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.

---

The page: https://www.cloudrepo.io/docs/migrate/nuget.html
