Use CodeArtifact with Visual Studio - CodeArtifact

Use CodeArtifact with Visual Studio

You can consume packages from CodeArtifact directly in Visual Studio with the CodeArtifact Credential Provider. The credential provider simplifies the setup and authentication of your CodeArtifact repositories in Visual Studio and is available in the AWS Toolkit for Visual Studio.

Note

The AWS Toolkit for Visual Studio is not available for Visual Studio for Mac.

To configure and use NuGet with CLI tools, see Use CodeArtifact with the nuget or dotnet CLI.

Configure Visual Studio with the CodeArtifact Credential Provider

The CodeArtifact Credential Provider simplifies the setup and continued authentication between CodeArtifact and Visual Studio. CodeArtifact authentication tokens are valid for a maximum of 12 hours. To avoid having to manually refresh the token while working in Visual Studio, the credential provider periodically fetches a new token before the current token expires.

Important

To use the credential provider, ensure that any existing AWS CodeArtifact credentials are cleared from your nuget.config file that may have been added manually or by running aws codeartifact login to configure NuGet previously.

Use CodeArtifact in Visual Studio with the AWS Toolkit for Visual Studio

  1. Install the AWS Toolkit for Visual Studio using the following steps. The toolkit is compatible with Visual Studio 2017 and 2019 using these steps. AWS CodeArtifact does not support Visual Studio 2015 and earlier.

    1. The Toolkit for Visual Studio for Visual Studio 2017 and Visual Studio 2019 is distributed in the Visual Studio Marketplace. You can also install and update the toolkit within Visual Studio by using ToolsExtensions and Updates (Visual Studio 2017) or ExtensionsManage Extensions (Visual Studio 2019).

    2. After the toolkit has been installed, open it by choosing AWS Explorer from the View menu.

  2. Configure the Toolkit for Visual Studio with your AWS credentials by following the steps in Providing AWS Credentials in the AWS Toolkit for Visual Studio User Guide.

  3. (Optional) Set the AWS profile you want to use with CodeArtifact. If not set, CodeArtifact will use the default profile. To set the profile, go to Tools > NuGet Package Manager > Select CodeArtifact AWS Profile.

  4. Add your CodeArtifact repository as a package source in Visual Studio.

    1. Navigate to your repository in the AWS Explorer window, right click and select Copy NuGet Source Endpoint.

    2. Use the Tools > Options command and scroll to NuGet Package Manager.

    3. Select the Package Sources node.

    4. Select +, edit the name, and paste the repository URL endpoint copied in Step 3a in the Source box, and select Update.

    5. Select the checkbox for your newly added package source to enable it.

      Note

      We recommend adding an external connection to NuGet.org to your CodeArtifact repository and disabling the nuget.org package source in Visual Studio. When using an external connection, all of the packages fetched from NuGet.org will be stored in your CodeArtifact repository. If NuGet.org becomes unavailable, your application dependencies will still be available for CI builds and local development. For more information about external connections, see Add an external connection.

  5. Restart Visual Studio for the changes to take effect.

After configuration, Visual Studio can consume packages from your CodeArtifact repository, any of its upstream repositories, or from NuGet.org if you have added an external connection. For more information about browsing and installing NuGet packages in Visual Studio, see Install and manage packages in Visual Studio using the NuGet Package Manager in the NuGet documentation.

Use the Visual Studio Package Manager console

The Visual Studio Package Manager console will not use the Visual Studio version of the CodeArtifact Credential Provider. To use it, you will have to configure the command-line credential provider. See Use CodeArtifact with the nuget or dotnet CLI for more information.