aws / aws-toolkit-visual-studio

AWS Toolkit for Visual Studio - a plugin to interact with AWS
https://aws.amazon.com/visualstudio/
Apache License 2.0
105 stars 29 forks source link

Can no longer get credentials to connect to CodeArtifact? #446

Closed icelava closed 1 month ago

icelava commented 1 month ago

Describe the bug With the latest version of AWS Toolkit Amazon Q, it looks like Visual Studio is no longer able to automatically obtain credentials for CodeArtifact (with the designated AWS profile). The Windows Credential Manager pop-up will actually appear asking for password for the CodeArtifact user.

Even re-creating the NuGet source for https://domain-accountid.d.codeartifact.ap-southeast-1.amazonaws.com/nuget/repo/v3/index.json does not get Visual Studio to get new credentials for authentication session with CodeArtifact. Deleting the Credential Manager user does not help.

Severity Code Description Project File Line Suppression State Error (active) NU1301 Unable to load the service index for source https://domain-accountid.d.codeartifact.ap-southeast-1.amazonaws.com/nuget/repo/v3/index.json. Project C:\projects\Project.csproj 1

To Reproduce

  1. Select credentials for AWS Explorer.
  2. Copy NuGet Source Endpoint for the relevant CodeArtifact repo.
  3. Create and select new NuGet source with URL.
  4. Get solution to restore/update packages with NuGet.

Expected behavior Visual Studio can seamlessly connect to CodeArtifact as NuGet source and download/update packages. Used to be able to in the past.

Screenshots

Toolkit Logs Where to find?

Development System (please complete the following information):

Additional context

icelava commented 1 month ago

Current workaround is to manually execute aws codeartifact login .

awschristou commented 1 month ago

Hi @icelava , can you please share the toolkit log from a session where you have this problem? I suspect this is related to the issues we have been seeing in version 1.54.* around extension initialization.

Also, could you please share a list of all other Visual Studio extensions you have installed (if any)?

icelava commented 1 month ago

Like this one? log_2024-07-09_16-21-04_34468.txt

awschristou commented 1 month ago

Yes thank you. I'm guessing you are seeing a message along the lines of "Some functionality may not work during this IDE session." in the Toolkit's Output pane (titled "Amazon Web Services"). The CodeArtifact credentials provider is one of the extension's components that Visual Studio is having problems finding. This problem relates to the underlying issues in #441, which we're still looking to understand more about.

Could you please share a list of all other Visual Studio extensions you have installed (if any)?

A couple of things you can try:

Please let us know whether or not you are able to connect to CodeArtifact after running through these steps.

icelava commented 1 month ago

What I have are

icelava commented 1 month ago

I don't see how updating Visual Studio will solve the problem since they don't include the implementation for AWS Toolkit or CodeArtifact credentials helper. And sure enough after updating to 17.10.4 the problem still persists.

awschristou commented 1 month ago

We are still trying to understand why Visual Studio is failing to load some components of the AWS Toolkit. At this time, we don't know if this is a problem in Visual Studio, or in the extension. That is why we ask to update Visual Studio.

Something that is worth trying is to have Visual Studio rebuild its cache of MEF components. To do this, you need to close all instances of Visual Studio, remove the cache folder, and then re-launch Visual Studio. Visual Studio will then rebuild its component cache.

The cache folder is located at %localappdata%\Microsoft\VisualStudio\XXX\ComponentModelCache where "XXX" is specific to your instance, and would start with "17.0". Alternatively, there is an extension called Clear MEF Component Cache which helps do this for you.

fendric commented 1 month ago

Greetings. Having a similar issue with my Visual Studio 2022 copy. Ever since upgrading the latest AWS Toolkit (v1.55.0.0) my CodeArtifact credentials have ceased to work. Keeps prompting me for credentials every time. We are using IAM Roles to authenticate. I tried configuring the tool with the credentials using the "Get Started" wizard, but to no avail. Prompts me every time I load a solution in Visual Studio. I have tried clearing the component cache suggested above. No change. Have reinstalled nuget, reinstalled the credential provider, reconfigured everything from scratch. Rebooted several times. Can't log into CodeArtifact.

awschristou commented 1 month ago

Hi, we have released a new version of the Toolkit (1.55.1.0) that intends to minimize the extension's component-loading problems to Amazon Q instead of all of the extension's features. Please install this latest version and share whether or not you are able to access CodeArtifact using the Toolkit.

fendric commented 1 month ago

This fixed it for me. Thank you.

awschristou commented 1 month ago

Thanks for letting us know @fendric , glad to hear it.

@icelava I'll wait to hear from you before closing this issue

icelava commented 1 month ago

After installing 1.55.1.0 Visual Studio can launch and check for Nuget package updates without me having to manually log into CodeArtifact. Thanks.

awschristou commented 1 month ago

Thanks for confirming!

baughj commented 1 month ago

@awschristou not sure if you want me to open another ticket or not, but this behavior is still manifesting for me with 1.55.1.0 and Visual Studio 2022 17.10.4, after clearing the component cache, and after repairing VS & rebooting.

awschristou commented 1 month ago

Hi @baughj , thanks for letting us know that you still have problems. We are now going to consolidate similar issues on an issue representing the core problem.

Can you please have a look at https://github.com/aws/aws-toolkit-visual-studio/issues/452, and if your system is still in a bad state, please follow through the "help us out" section to help us collect more data about the problem.

If you are getting the "Some Toolkit components could not be initialized. Some functionality may not work during this IDE session." message, please comment on that issue going forward. Otherwise, please file a new issue, but try going through the guidance in 452.

icelava commented 4 weeks ago

Looks like the auto-credentials function is unstable. Some times it works transparently, some times it cannot connect.

error NU1301: Unable to load the service index for source https://domain-accountid.d.codeartifact.ap-southeast-1.amazonaws.com/nuget/repo/v3/index.json.