• Using the .NET CLI to restore packages from a private NuGet feed


    Using the .NET CLI to restore packages from a private NuGet feed

    For the past years, I've been working in Visual Studio (the 2022 preview version is available), but recently I've given Visual Studio Code a shot. Transitioning between the two IDE's also means that you use the .NET CLI more extensively. Sadly, this was the cause of one annoying problem for me.

    A couple of times a day, when I was trying to build a project, I bumped against the following error saying that I'm not authorized to access our private feed.

     
     

    This led to frustrations and was counter-productive. As a work-around, I opened the project in Visual Studio to be authorized.

    Some GitHub issues mentioned running the restore command with the interactive flag, but in my case, this ended up in the same error.

     
     

    After browsing through more GitHub issues, I found a comment that suggested installing the Microsoft NuGet CredentialProvider.

     
     

    To my satisfaction, the error was finally gone.

    Support me

    I appreciate it if you would support me if have you enjoyed this post and found it useful, thank you in advance.

    https://github.com/Microsoft/artifacts-credprovider#setup

    Setup

    If you are using dotnet or nuget, you can use the Azure Artifact Credential Provider by adding it to NuGet's plugin search path. This section contains both manual and scripted instructions for doing so.

    Dotnet needs the netcore version to be installed. NuGet and MSBuild need the netfx version to be installed.

    Installation on Windows

    Automatic PowerShell script

    PowerShell helper script

    • To install netcore, run installcredprovider.ps1
      • e.g. iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) }"
    • To install both netfx and netcore, run installcredprovider.ps1 -AddNetfx. The netfx version is needed for nuget.exe.
      • e.g. iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"

    Manual installation on Windows

    1. Download the latest release of Microsoft.NuGet.CredentialProvider.zip
    2. Unzip the file
    3. Copy the netcore (and netfx for nuget.exe) directory from the extracted archive to $env:UserProfile\.nuget\plugins (%UserProfile%/.nuget/plugins/)

    Using the above is recommended, but as per NuGet's plugin discovery rules, alternatively you can install the credential provider to a location you prefer, and then set the environment variable NUGET_PLUGIN_PATHS to the .exe of the credential provider found in plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe. For example, $env:NUGET_PLUGIN_PATHS="my-alternative-location\CredentialProvider.Microsoft.exe". Note that if you are using both nuget and dotnet, this environment variable is not recommended due to this issue: NuGet/Home#8151

     

     

  • 相关阅读:
    mongodb删除指定字段
    nodejs地理坐标转换
    浅谈对腾讯云微信小程序解决方案服务端的理解(主要针对信道服务)
    利用Django进行微信支付接口的开发
    SpringBoot常用注解
    构建一个敏感词字典树
    Java异常统一处理
    [一天一个小知识]instanceof
    [总结]实现表格中对checkbox的操作
    小程序的数据绑定
  • 原文地址:https://www.cnblogs.com/chucklu/p/16734108.html
Copyright © 2020-2023  润新知