簡體   English   中英

NuGet CLI源命令未更新NuGet.Config

[英]NuGet.Config isn't updated by the nuget CLI sources command

我使用dotnet pack創建了一個nuget包,並使用

nuget sources add -Name My.Namespace -Source /full/path/to/the/packages

然后將包添加到Feed中

nuget add bin/Debug/My.Namespace.0.0.0.nupkg -source /full/path/to/the/packages

nuget sources list按預期顯示了此本地提​​要:

Registered Sources:

  1.  nuget.org [Enabled]
      https://api.nuget.org/v3/index.json
  2.  My.Namespace [Enabled]
      /full/path/to/the/packages

packages的目錄結構正確

/full/path/to/the/packages
└── my.namespace
    └── 0.0.0
        ├── my.namespace.0.0.0.nupkg
        ├── my.namespace.0.0.0.nupkg.sha512
        └── my.namespace.nuspec

但是dotnet反復無法將軟件包添加到項目中

$ dotnet add package My.Namespace
error: Unable to find package My.Namespace. No packages exist with this id in source(s): nuget.org
error: Package 'My.Namespace' is incompatible with 'all' frameworks in project '/Users/theonlygusti/Documents/Projects/dotnet-core-api/Fun.Project.csproj'.

並在嘗試構建時手動將軟件包添加到.csproj錯誤:

error NU1101: Unable to find package My.Namespace. No packages exist with this id in source(s): nuget.org

好像dotnet沒有檢查我的本地NuGet提要,所以我檢查了~/.nuget/NuGet/NuGet.Config ,其中僅包含

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>                                                                                                                                             
</configuration>

為什么我的本地提要不在這里?

如何讓它出現在這里? (理想情況下,這樣我就不必每次都手動編輯此文件...)

或者,如果無法將程序包添加到其他項目的原因無關,那么我應該在本地創建並依賴NuGet程序包嗎?

默認情況下,用於添加程序包源的命令行會將其添加到路徑%appdata%\\NuGet\\nuget.config的文件中。 如果要修改特定的Nuget配置文件,可以使用-ConfigFile選項指定哪個文件,例如:

nuget sources add -Name My.Namespace -ConfigFile /path/to/config -Source /path/to/packages

我正在猜測Nuget在~/.nuget/NuGet/NuGet.Config找到配置文件,並停止搜索更多文件。

請注意,如果您所需的Nuget配置僅特定於您正在使用的項目,那么我建議您在解決方案文件夾的根目錄中放置一個nuget.config文件。

您可以在此處找到有關配置文件位置的信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM