question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot connect to a private nuget server (Azure DevOps)

See original GitHub issue

I have tried to run dotnet outdated but it does not work on my computer. I have dotnet SDK 5.0.100 and the latest version of the tool 3.1.0. I also have the latest version of Microsoft.NuGet.CredentialProvider

Errors occurred while analyzing dependencies for some of your projects. Are you sure you can connect to all your configured NuGet servers? Unable to find DOTNET_HOST_PATH environment variable. If you use credential providers for your NuGet sources you need to have this set to the path to the dotnet executable.

I can set manually DOTNET_HOST_PATH but it still cannot connect to my private nuget source server :

$Env:DOTNET_HOST_PATH = "$env:ProgramFiles\dotnet\dotnet.exe"

Errors occurred while analyzing dependencies for some of your projects. Are you sure you can connect to all your configured NuGet servers?

Nuget server was added with the dotnet nuget add source command (with username and PAT token as password). The dotnet command dotnet list package --outdated works well.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
adrien-constantcommented, Jan 4, 2022

The problem still occurs in Azure Pipelines. I have also tried, as suggested by @PartTimeLegend to add the Nuget Authenticate step before this but I keep getting the following error for my private feeds in Azure Devops:

Errors occurred while analyzing dependencies for some of your projects. Are you sure you can connect to all your configured NuGet servers?

Unable to find DOTNET_HOST_PATH environment variable. If you use credential providers for your NuGet sources you need to have this set to the path to the `dotnet` executable.

Any suggestions on how to fix this?

On my private vsts agent, dotnet executable is located under /usr/bin/dotnet So you may be able to hard set the env variable, that should fix it.

variables :
  DOTNET_HOST_PATH: '/usr/bin/dotnet'
0reactions
polferovcommented, Feb 10, 2023

The workaround i found was to:

  • create a user with read-only access to the nuget feed.
  • create an access token (with the longest possible ttl)
  • create a nuget.config in your repo leveraging the access token like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!-- add this line to override previously accumulated sources (e.g. from nuget.config(s) in parent directories)-->
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <!-- reference to your nuget feed -->
    <add key="MyFeed" value="https://path-to-feed.com/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <!-- credentials to our nuget feed -->
    <MyFeed>
      <!-- username required for authentication type. can be arbitrary but not empty -->
      <add key="Username" value="user" />
      <!-- password is PAT for the created user -->
      <add key="ClearTextPassword" value="ecampleAccesToken123" />
      <add key="ValidAuthenticationTypes" value="basic" />
    </MyFeed>
  </packageSourceCredentials>
</configuration>

This way the credentials provider is never needed. Sure it’s not the best possible solution but it works for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot connect to AzureDevops private Nuget feed from ...
From VisualStudio 2019 for Windows - it works fine. p.s. I have the latest Microsoft Credentials Provider NuGet plugin installed.
Read more >
Is it possible to access private nuget server from Azure ...
Yes, it is possible. You´ll need to have a Self-Hosted Agent ==> e.g. Windows.
Read more >
Connect to Azure Artifacts feeds (NuGet.exe)
Select Artifacts and then select your feed. · Select Connect to feed. · Select NuGet.exe from the left panel.
Read more >
Get started with NuGet packages and Azure Artifacts
1. Get the feed's source URL · Navigate to your project, and then select Artifacts then select your feed. · Select Connect to...
Read more >
Mac can't connect to private feed, DevOps Server On Premise
Hi allMy office is implementing Azure DevOps Server 2019 On premise to use with .Net Framework and DotNet Core projects, mostly TFS repo ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found