将自定义包源添加到Visual Studio代码

Tom*_*ino 22 package-managers myget visual-studio-code

有人知道如何向Visual Studio Code添加自定义包源吗?

例如,我想将https://www.myget.org/F/aspnet-contrib/api/v3/index.json添加为包源,并通过project.json驱动这些包.

Alv*_*vis 28

要添加答案,nuget.config在项目中添加a 可以为项目解决问题.添加到root是可以的.配置可能如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="MyGet" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />
  </packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,“nuget.config”仅在 VS 中有效,但在 VS Studio 中无效。所以,这个答案是错误的或不完整的。 (3认同)

js8*_*s80 9

另一个对我有用并且实际上需要作为我的 CI/CD 管道的一部分的选项是使用dotnet nuget add source <repo-url> --name <repo-name>

只需在调用之前调用该方法即可dotnet restore,或者dotnet build

参考: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source