microsoft / artifacts-credprovider

The Azure Artifacts Credential Provider enables dotnet, NuGet.exe, and MSBuild to interactively acquire credentials for Azure Artifacts feeds.
MIT License
759 stars 707 forks source link

Credential Provider + Linux + Rider #436

Closed kirill-d-lappo closed 10 months ago

kirill-d-lappo commented 1 year ago

I am not sure if it is an issue at all and who is responsible for it, I am just making some notes on the issue I have run into.

Preparations

Problem:

Rider does not communicate with the Azure nuget feed, user can't see any packages from it.

At the same time dotnet restore works as expected.

Description

Rider logs contains the next error:

Credential provider preference: NuGetPlugins
Querying credential provider cache for: https://pkgs.dev.azure.com/your-company-here/_packaging/your-company-here/nuget/v3/index.json (isRetry: False)
Querying credential providers for: https://pkgs.dev.azure.com/your-company-here/_packaging/your-company-here/nuget/v3/index.json (isRetry: False)
Problem starting the plugin '/home/klappo/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe'. An error occurred trying to start process '/home/klappo/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe' with working directory '/home/klappo/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/231.9161.46/bin'. Exec format error
Exception while querying credential providers for: https://pkgs.dev.azure.com/your-company-here/_packaging/your-company-here/nuget/v3/index.json
NuGet.Credentials.PluginException: Problem starting the plugin '/home/klappo/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe'. An error occurred trying to start process '/home/klappo/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe' with working directory '/home/klappo/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/231.9161.46/bin'. Exec format error
 ---> System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/home/klappo/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.exe' with working directory '/home/klappo/.local/share/JetBrains/Toolbox/apps/Rider/ch-0/231.9161.46/bin'. Exec format error
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at NuGet.Protocol.Plugins.PluginProcess.Start()
   at JetBrains.Rider.Backend.Features.NuGet.CredentialProvider.Internal.PluginFactory.CreatePluginAsync(String filePath, IEnumerable`1 arguments, IRequestHandlers requestHandlers, ConnectionOptions options, CancellationToken sessionCancellationToken)
   at JetBrains.Rider.Backend.Features.NuGet.CredentialProvider.Internal.PluginFactory.GetOrCreateAsync(String filePath, IEnumerable`1 arguments, IRequestHandlers requestHandlers, ConnectionOptions options, CancellationToken sessionCancellationToken)
   at NuGet.Protocol.Plugins.PluginManager.TryCreatePluginAsync(PluginDiscoveryResult result, OperationClaim requestedOperationClaim, PluginRequestKey requestKey, String packageSourceRepository, JObject serviceIndex, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---

Seems like Rider uses credential provider binary directly to display packages.

But the plugin in artifacts is built for windows platform only.

Solution

Clone artifacts-credprovider repo and build the plugin manually for linux platform.

# after cloning and cd-ing into the repo

# the config in the repo contains a link to a private nuget feed
# but you can restore all dependencies via public nuget.org feed
# so just remove that private repo
rm ./nuget.config

pluginDir="$HOME/.nuget/plugins/netcore/CredentialProvider.Microsoft"

# clean up existing plugin
rm -rf "$pluginDir"

# publish the provider.
dotnet publish CredentialProvider.Microsoft/CredentialProvider.Microsoft.csproj  \
  -c Release  \
  -f net6.0   \
  -o "$pluginDir"
JohnSchmeichel commented 1 year ago

Yeah, the netcore plugin is expected to use dotnet CredentialProvider.Microsoft.dll, so seems like a Rider issue here? The default NuGet libraries will do the correct thing here, so guessing Rider is initializing or using the SDK in a non-standard way here. Are any of these environment variables set? https://learn.microsoft.com/en-us/nuget/reference/extensibility/nuget-cross-platform-plugins#plugin-installation-and-discovery

kirill-d-lappo commented 1 year ago

@JohnSchmeichel

Are any of these environment variables set?

no, I use default set-up for the sdk and dotnet cli, no additional path configuration

Yeah, the netcore plugin is expected to use dotnet CredentialProvider.Microsoft.dll, so seems like a Rider issue here?

I guess, it is a Rider issue, but can't say definitely, I don't know internals of the tool.

kirill-d-lappo commented 1 year ago

I have created the same issue in YouTrack: https://youtrack.jetbrains.com/issue/RIDER-96160/Credential-Manager-Rider-Linux

MartinSGill commented 1 year ago

Have you tried changing this setting? On my machine it defaults to "Rider Integrated" and that caused all sorts problems with Azure feeds. Changing it to CLI allows me to work with Azure Nuget feeds without issues.

image

kirill-d-lappo commented 1 year ago

Have you tried changing this setting? On my machine it defaults to "Rider Integrated" and that caused all sorts problems with Azure feeds. Changing it to CLI allows me to work with Azure Nuget feeds without issues.

image

yes, I have changed it to the third option, and Rider threw the error from the description.

github-actions[bot] commented 10 months ago

This issue has had no activity in 90 days. Please comment if it is not actually stale.