Skip to content

Cannot connect to a private nuget server (Azure DevOps) #59

Open

Description

@adrien-constant

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.

Activity

  1. dannydwarren commented on Jan 11, 2021

    @dannydwarren

    We are in the same boat. It seems that dotnet outdated is not using our configured Azure Artifacts credential provider to access our private NuGet feed in Azure DevOps.

  2. coderpatros commented on Jan 13, 2021

    @coderpatros
    Member

    Does it work if you first run the Azure DevOps dotnet restore step? I think there might be some special stuff to make the token available to the restore step that might not be available when running dotnet outdated.

  3. dannydwarren commented on Jan 17, 2021

    @dannydwarren
  4. Spragalas commented on May 31, 2021

    @Spragalas

    Did anyone found the solution? I am currently experiencing same issue

  5. PartTimeLegend commented on Jun 4, 2021

    @PartTimeLegend

    I'm also in the same boat. Is this project abandoned?

  6. added
    help wanted
    on Jun 4, 2021
  7. coderpatros commented on Jun 4, 2021

    @coderpatros
    Member

    Not abandoned. Just an issue I haven't faced myself. And just one issue in a long list of the projects I work on.

    If someone wants to debug this, and come up with a solution, a pull request would be most appreciated.

  8. PartTimeLegend commented on Jun 6, 2021

    @PartTimeLegend

    I was able to use the Nuget Authenticate task before it in order to get things working again. My issue seemed to be that dotnet-outdated-tool doesn't appear to read the credentials used elsewhere in the pipeline.

  9. coderpatros commented on Jun 7, 2021

    @coderpatros
    Member

    Can anyone else confirm this fixes the issue for them as well? There is some funky stuff that goes on in Azure DevOps pipelines with service principals and authentication.

    Although I think the initial issue was when running this locally, not in Azure DevOps pipelines. @adrien-constant can you confirm? Don't want to prematurely close this issue.

  10. danielcweber commented on Jul 21, 2021

    @danielcweber

    Here's what worked for me (in a local setting, not in a pipeline):

    1. Definitely use the Azure Artifacts credential provider, but...
    2. Don't use "dotnet restore --interactive" to get the credentials into it during a restore, but rather....
    3. Run the credentials provider manually (dotnet run .\pathToThePluginFolder\CredentialProvider.Microsoft.dll -U yourArtifactsUri -C). More info on the parameters here (in the help section).
    4. Make peace with the fact that more than one token might be requested

    While before, dotnet restore would regularly forget any credentials, they seem to be stored for good now.

  11. adrien-constant commented on Dec 21, 2021

    @adrien-constant
    Author

    For information, it worked after upgrading to the latest version and login interactively with the browser :

    dotnet tool update --global dotnet-outdated-tool --interactive --verbosity minimal

  12. LotteVoorhorst commented on Jan 4, 2022

    @LotteVoorhorst

    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.
    

    My yaml file consists of the following:

    Starter pipeline
    # Start with a minimal pipeline that you can customize to build and deploy your code.
    # Add steps that build, run tests, deploy, and more:
    # https://aka.ms/yaml
    
    trigger:
    - main
    
    pool:
      vmImage: ubuntu-latest
    
    steps:
    - task: UseDotNet@2
      inputs:
        version: "6.x"
    - task: UseDotNet@2
      inputs:
        version: "3.x"
    
    - task: DotNetCoreCLI@2
      inputs:
        command: 'restore'
        projects: '*/**.csproj'
        feedsToUse: 'select'
        vstsFeed: '<nuget-feed-id>'
        
    - script: dotnet tool install -g dotnet-outdated-tool
    - task: DotNetCoreCLI@2
      inputs:
        command: 'custom'
        projects: '*/**.csproj'
        custom: 'outdated'
        arguments: '--fail-on-updates --older-than 14'
    

    Any suggestions on how to fix this?

  13. adrien-constant commented on Jan 4, 2022

    @adrien-constant
    Author

    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'
    
  14. RudeySH commented on Dec 20, 2022

    @RudeySH

    I have the same issue (tool not working locally, never mind Azure Pipelines...).

    • I verified I'm using dotnet-outdated-tool version 4.3.2 (latest).
    • I followed @danielcweber's steps to get the credentials going.
    • I verified that I'm able to connect to all my configured NuGet servers.
      • For example, dotnet list package --outdated works.

    Just like pretty much everyone else here, I'm getting the following error:

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

    It would be really, really helpful if dotnet-outdated had some sort of --verbose parameter that allowed us to see the underlying errors, so we at least have a chance of figuring out what's wrong.

  15. polferov commented on Feb 10, 2023

    @polferov

    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.

  16. ivog commented on Oct 24, 2023

    @ivog
    Contributor

    @LucidoKeith I had the same issue, below is the stacktrace I encountered. For me the problem was the DOTNET_HOST_PATH environment variable pointing to the wrong location. In my case setting the value to C:\Program Files\dotnet\dotnet.exe fixed the access denied issue.

    In Program.Cs this line can be changed to use a real logger instead of a nulllogger so that the user is at least aware of issues.

    DefaultCredentialServiceUtility.SetupDefaultCredentialService(new NuGet.Common.NullLogger(), true);

    I'll see if I can create a PR to improve the logging.

    System.ComponentModel.Win32Exception (5): An error occurred trying to start process 'C:\Program Files\dotnet\sdk\7.0.306' with working directory 'C:\Users\C91412\Developer\Workspace\us\XXXXX'. Access is denied.
    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
    at System.Diagnostics.Process.Start()
    at NuGet.Protocol.Plugins.PluginProcess.Start()
    at NuGet.Protocol.Plugins.PluginFactory.CreatePluginAsync(String filePath, IEnumerable1 arguments, IRequestHandlers requestHandlers, ConnectionOptions options, CancellationToken sessionCancellationToken) at NuGet.Protocol.Plugins.PluginFactory.GetOrCreateAsync(String filePath, IEnumerable1 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)

  17. RecTuomas commented on Dec 19, 2023

    @RecTuomas

    I have run into this issue as well trying to get this to run in devops pipeline. Creating a nuget.config to all my repos with PATS is too much hassle and bad practice. Nothing else seem to work.

  18. Chris-Greaves commented on May 3, 2024

    @Chris-Greaves
    Contributor

    Here in 2024, and none of these workarounds have worked for me.
    It's clear that changes to the tool are needed to support using with Private NuGet Feeds from Azure DevOps.

    I think the PR #493 could be rebased and adjusted to work in main again. This would at least give some logging to show exactly what is failing. For me, it runs locally, but not inside the pipeline and I have absolutely no idea why.

    I'm going to dive into the code a bit more tomorrow, and see if I can get a custom build running in the pipeline with better logging. If I find anything I will add it here.

  19. Chris-Greaves commented on May 30, 2024

    @Chris-Greaves
    Contributor

    Hello all, I'm back with a PR to add logging, and the error that is causing it to not work in Azure DevOps for me.

    The PR

    A more polished version of the original Logging PR #493 which hopefully will get approved. If you are still stuck yourselves, please consider giving it a Thumbs Up! 👍

    If you want to run my version of the code in your own pipelines, it's a bit of a pain, but it can be done.

    1. Build for your Agent's OS (mine was ubuntu) and zip it (I chose .tar.gz, but you can use .zip if you like)
    2. In the pipeline, extract that archive into a folder, I chose the Built-in ToolsDirectory.
      - task: ExtractFiles@1
        inputs:
          archiveFilePatterns: $(Build.SourcesDirectory)/tools/dotnet-outdated.tar.gz
          destinationFolder: $(Agent.ToolsDirectory)/dotnet-outdated
    1. Then call the executable directly. I had to run chmod to make it executable. I used Bash because I had issues with Powershell on Ubuntu, but whatever works for you.
      - task: Bash@3
        displayName: Run dotnet Outdated
        continueOnError: false
        condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
        inputs:
          targetType: inline
          script: chmod +x $(Agent.ToolsDirectory)/dotnet-outdated/linux-build/dotnet-outdated && $(Agent.ToolsDirectory)/dotnet-outdated/linux-build/dotnet-outdated -of Markdown -o outdated-results.md -utd ${{ parameters.ApplicationDirectory }}/${{ parameters.ApplicationProjectFile }}
          workingDirectory: ${{ parameters.SolutionFileDirectory }}
        env:
          DOTNET_HOST_PATH: $(Agent.ToolsDirectory)/dotnet

    The Error

    Using the logging, I got the error below:

    [ERROR] Problem starting the plugin '/home/vsts/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll'. The FileName property should not be a directory unless UseShellExecute is set.
    

    I have absolutely no idea what it means, but maybe someone here can help me. Either way, it's a step in the right direction!

  20. jvgarner commented on Jun 29, 2024

    @jvgarner

    Just a heads up for anyone that ends up here like I did trying to debug this error message.

    In my case, it was due to my nuget.config file being in a sub-folder and not the root folder of my source ie with other dotnet commands and tools I was specifying the config or the config wasn't required so I didn't think of this as being my issue at first. Once I moved it, my self-hosted build agent was able to run the tool just fine.

    Ideally this tool would allow us to specify the path to the config file but it's not a huge deal for me to move it and now everything is working well.

  21. Chris-Greaves commented on Aug 22, 2024

    @Chris-Greaves
    Contributor

    So, spent a significant amount of time today looking into this again.... and still no luck.

    From your comment @jvgarner, I tried moving my nuget.config file around to different places in the hope it was that but still had no luck. So I actually built my own version of dotnet-outdated that allowed me to specify the nuget.config I want to use (yes, I will raise a PR with my changes soon, leave a 👍 to hold me accountable for that). However, even when specifying the nuget.config file directly, it still failed with the same error.

    [DEBUG] Using /home/vsts/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll as a credential provider plugin.
    [ERROR] Problem starting the plugin '/home/vsts/.nuget/plugins/netcore/CredentialProvider.Microsoft/CredentialProvider.Microsoft.dll'. The FileName property should not be a directory unless UseShellExecute is set.
    [DEBUG] System.ComponentModel.Win32Exception (0x80004005): The FileName property should not be a directory unless UseShellExecute is set.
       at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
       at NuGet.Protocol.Plugins.PluginProcess.Start()
       at NuGet.Protocol.Plugins.PluginFactory.CreatePluginAsync(String filePath, IEnumerable`1 arguments, IRequestHandlers requestHandlers, ConnectionOptions options, CancellationToken sessionCancellationToken)
       at NuGet.Protocol.Plugins.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)
    

    I did an ls inside the CredentialProvider.Microsoft folder, and the files are there, so I have absolutely no idea what's going on. One thing that occurred to me is that I am using ubuntu-latest, and I wonder if this is some Windows pathing issue. Still super weird as the task before this literally does a dotnet restore so it can definitely work.

    Has anyone got theirs working on Linux with a private nuget server?

  22. Chris-Greaves commented on Sep 5, 2024

    @Chris-Greaves
    Contributor

    Alright, I got it working finally!!!

    Essentially I did what @polferov posted, and added credentials into the config file and that seemed to work. I have no idea why the credential provider doesn't work, but I have found a slightly easier way to do this in Azure DevOps now.

    My pipeline tasks:

    ###
      - script: dotnet tool install --global dotnet-outdated-tool
        displayName: Install dotnet outdated
      - task: NuGetAuthenticate@1
        inputs:
          nugetServiceConnections: Private NuGet Feed
          forceReinstallCredentialProvider: true
      - task: DotNetCoreCLI@2
        displayName: restore solution nuget packages
        inputs:
          command: restore
          projects: ${{ parameters.SolutionFileDirectory }}/${{ parameters.SolutionFile }}
          feedsToUse: config
          nugetConfigPath: ${{ parameters.SolutionFileDirectory }}/nuget.config
          workingDirectory: ${{ parameters.SolutionFileDirectory }}
      - task: DotNetCoreCLI@2
        displayName: Run dotnet outdated
        inputs:
          command: custom
          custom: 'outdated'
          arguments: '-of Markdown -o outdated-results.md -utd'
          projects: ${{ parameters.ApplicationDirectory }}/${{ parameters.ApplicationProjectFile }}
          workingDirectory: ${{ parameters.SolutionFileDirectory }}
    ###

    My nuget.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <clear />
        <add key="PrivateFeed" value="https://private-feed.dev/v3/index.json" />
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
      </packageSources>
      <packageSourceCredentials>
        <PrivateFeed>
            <add key="Username" value="VSTS" />
            <add key="ClearTextPassword" value="%VSS_NUGET_ACCESSTOKEN%" />
        </PrivateFeed>
      </packageSourceCredentials>
    </configuration>

    The NuGetAuthenticate@1 task adds the VSS_NUGET_ACCESSTOKEN environment variable for the rest of the job (source), so I use that as my access token in the config file using the % characters (source).

    I'm still going to submit my PR for the "Specify NuGet config" change, in case you want a different nuget.config for pipelines than for devs locally. I might also create a new formatter that looks better in Azure DevOps as currently the colouring formatting doesn't work.

    I hope someone reads this and finds it helpful.

  23. malovicn commented on Oct 18, 2024

    @malovicn

    I've spent 6 hours trying to figure out how to solve this, including creating Nuget.

    I configured it with hardcoded PAT and other advice here, and all I achieved was a supreme level of furiousness that something so essential as "update all packages with CLI" in dotnet 2024 is still a challenge...

    I am going to try to do this now manually using standard dotnet clicli and powershell

  24. dylbarne commented on Nov 4, 2024

    @dylbarne

    feature request/suggestion: potentially log the specific projects/nugets it has Unknown dependency upgrade severity for?

    I was running into the same issue locally as others have described above (dealing with private nuget feed etc.), however when cloning the repo and debugging against Sln path I am trying to execute dotnet outdated against, I actually then did not get this error; so it seems impossible for me to further troubleshoot what particular packages it is complaining about internally.

    maybe could provide as default option or flag to selectively log around these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions