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.
Topics
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
-
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.
-
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 Tools ≫ Extensions and Updates (Visual Studio 2017) or Extensions ≫ Manage Extensions (Visual Studio 2019). -
After the toolkit has been installed, open it by choosing AWS Explorer from the View menu.
-
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.
(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.
Add your CodeArtifact repository as a package source in Visual Studio.
Navigate to your repository in the AWS Explorer window, right click and select
Copy NuGet Source Endpoint
.Use the Tools > Options command and scroll to NuGet Package Manager.
Select the Package Sources node.
Select +, edit the name, and paste the repository URL endpoint copied in Step 3a in the Source box, and select Update.
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 Connect a CodeArtifact repository to a public repository.
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
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.