Migrate NuGet packages to Azure Artifacts

Using the AzureArtifactsPackageMigration PowerShell module, you can easily migrate your NuGet packages to Azure Artifacts. This article will walk you through an example of migrating NuGet packages from MyGet to Azure Artifacts.

In this article, you'll learn how to:

  • Install PowerShell module.
  • Connect to Azure Artifacts.
  • Migrate NuGet packages.

Prerequisites

Install the PowerShell module

  1. Open an elevated PowerShell prompt window.

  2. Run the following commands to install the AzureArtifactsPackageMigration PowerShell module and import it into your current session.

Install-Module -Name AzureArtifactsPackageMigration -Scope CurrentUser -Force
Import-Module -Name AzureArtifactsPackageMigration

Alternatively, you can also download the migration scripts from the GitHub repository.

Migration setup

To migrate your packages, you will need to get the package source URL for both the source and destination feeds.

Azure Artifacts

  1. Select Artifacts and then select your feed.

  2. Select Connect to feed.

    Screenshot showing how to connect to feed.

  3. Select NuGet.exe and then follow the instructions in the Project setup to set up your config file.

    Screenshot showing the instructions to set up a project.

MyGet

  1. Log in to your MyGet Account.

  2. Navigate to the feed you want to migrate.

  3. Select Feed Details.

  4. Select Packages and then copy the NuGet V3 feed URL.

    https://www.myget.org/F/<YOUR_FEED_NAME>/api/v3/index.json 
    

Migrate NuGet packages

If your myget feed is private, you will need to create a password to authenticate. You can skip the first step if your myget feed is public.

  1. Run the following command to convert your password to a secure string.

    $password = ConvertTo-SecureString -String '<YOUR_PASSWORD>' -AsPlainText -Force
    
  2. Run the following command to migrate your packages to Azure Artifacts;

    • Migrate from a private source feed:
      Move-MyGetNuGetPackages -SourceIndexUrl '<MYGET_SOURCE_URL>' -DestinationIndexUrl '<ARTIFACTS_FEED_SOURCE_URL>' -DestinationPAT '<AZURE_DEVOPS_PAT>' -DestinationFeedName '<ARTIFACTS_FEED_NAME>' -SourceUsername '<MYGET_USERNAME>' -SourcePassword $password -Verbose
    
    • Migrate from a public source feed:
      Move-MyGetNuGetPackages -SourceIndexUrl '<MYGET_SOURCE_URL>' -DestinationIndexUrl '<ARTIFACTS_FEED_SOURCE_URL>' -DestinationPAT '<AZURE_DEVOPS_PAT>' -DestinationFeedName '<ARTIFACTS_FEED_NAME>' -Verbose