簡體   English   中英

Nuget 返回了意外的狀態代碼“404 Not Found” - 本地驅動器上的包

[英]Nuget returned an unexpected status code '404 Not Found' - Package on local drive

試圖從 dll 生成 Nuget 包。 我們的項目之一是生成 ConfigurationCore.dll 和下面給出的項目程序集的引用

  • 微軟CSharp
  • 牛頓軟件
  • Mak.Enums(本地 Nuget 服務器上可用的自定義 Nuget 包)
  • Mak.Operations(本地 Nuget 服務器上可用的自定義 Nuget 包)
  • PresentationCore、PresentationFramework、PresentationFramework.Aero
  • System、System.Core、System.Data、System.Data.DataSetExtensions
  • System.Drawing, System.IO.Compression, System.IO.Compression.FileSystem
  • System.Net.Http、System.Runtime.Serialization、System.Web
  • System.Xaml、System.Xml、System.Xml.Linq、WindowsBase

使用下面的 ConfigurationCore.nuspec 生成 Nuget 包

<?xml version="1.0"?>
<package >
<metadata>
<id>ConfigurationCore</id>
<version>1.2.0</version>
<title>Configuration Core</title>
<authors>MAKK</authors>
<owners>IT Department</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ConfigurationCore contains core funcationality of Software</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2018</copyright>

<dependencies>
  <dependency id="Newtonsoft.Json" version="10.0.3" />
</dependencies>
</metadata>
<files>
<file src="C:\Users\makk\source\repos\ConfigurationCore\bin\x86\Test\ConfigurationCore.dll" target="lib\net461" />
</files>
</package>

嘗試針對項目“NugetTest”收集包“ConfigurationCore.1.2.0”的依賴信息,目標是“.NETFramework,Version=v4.6.1” 收集依賴信息需要 1.09 秒嘗試解析包“ConfigurationCore.1.2”的依賴。 0' with DependencyBehavior 'Lowest' 解析依賴信息需要 0 ms 解析安裝包 'ConfigurationCore.1.2.0' 的操作 安裝包 'ConfigurationCore.1.2.0' 的解析操作 ' http://builtsrv1:8080/ 上的 V2 提要nuget/FindPackagesById()?id= 'ConfigurationCore'&semVerLevel=2.0.0' 返回了一個意外的狀態代碼 '404 Not Found'。 已用時間:00:00:02.1513344 ========== 完成 ==========

注意:Nuget 包源位於本地硬盤上...請建議解決此問題。

更新您的 Nuget 包鏈接。

轉到項目-> 管理 Nuget 包。

現在單擊您的包源設置

更新源鏈接到https://api.nuget.org/v3/index.json

在此處輸入圖像描述https://i.stack.imgur.com/sMLYn.png

你的 URL 應該以/nuget 結尾

示例:http: //yourDomain.co/yourNuGetServer/nuget

Nuget 返回了意外的狀態代碼“404 Not Found” - 本地驅動器上的包

  1. 確保src="..."的路徑正確。

    也許路徑應該是:

    ...\\ConfigurationCore\\ConfigurationCore\\...而不是...\\ConfigurationCore\\...

    簡而言之,請確保您可以根據該 url 找到 dll 文件。

    注意:一般情況下,我們建議在 url 中使用相對路徑,例如:

    <file src="bin\\x86\\Test\\ConfigurationCore.dll" target="lib\\net461" />

  2. 更新nuget.exe的版本。

    nuget.exe 3.4.x 存在問題,請下載nuget.exe 3.5及以上版本。

有關更多詳細信息,請參閱從 dll 創建 nuget 包

更新:請按照以下步驟創建 nuget 包:

  1. 下載nuget.exe ,並將其設置在本地,例如D:\\NuGetLocalFolder

  2. 創建一個項目名稱為“ConfigurationCore”的新項目。

  3. 打開一個cmd,切換到之前存放nuget.exe的路徑。

  4. 使用命令行:

     nuget spec "C:\\Users\\<Username>\\Source\\repos\\ConfigurationCore\\ConfigurationCore\\ConfigurationCore.csproj"

    在此處輸入圖片說明

    你會發現生成了.nuspec ,不要關閉這個 CMD 窗口。

  5. 編輯ConfigurationCore.csproj.nuspec文件並修改它,下面是我的 .nuspec 文件:

     <?xml version="1.0"?> <package > <metadata> <id>ConfigurationCore</id> <version>1.2.0</version> <title>Configuration Core</title> <authors>MAKK</authors> <owners>IT Department</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>ConfigurationCore contains core funcationality of Software</description> <releaseNotes></releaseNotes> <copyright>Copyright 2018</copyright> <dependencies> <dependency id="Newtonsoft.Json" version="10.0.3" /> </dependencies> </metadata> <files> <file src="C:\\Users\\Admin\\Source\\repos\\ConfigurationCore\\ConfigurationCore\\bin\\x86\\Test\\ConfigurationCore.dll" target="lib\\net461" /> </files> </package>
  6. 保存ConfigurationCore.csproj.nuspec文件,並返回到您的 CMD 窗口,使用 pack 命令生成 nuget 包:

    在此處輸入圖片說明

    ConfigurationCore.1.2.0.nupkg被創建到 nuget.exe 所在的文件夾中, D:\\NuGetLocalFolder

這是 NuGet 包中連接不良的問題。 將以下鏈接添加到 NuGet 包中。 https://api.nuget.org/v3/index.json Tha

這是因為您引用了一個不存在的鏈接: http://builtsrv1:8080/nuget/FindPackagesById()?id='ConfigurationCore'&semVerLevel=2.0.0'

您在 url 中使用了一個方法,該方法無效並且是導致錯誤的原因:

             //this is an error
../nuget/FindPackagesById()?

修復網址,測試並重試,

這可能是因為您在僅支持“nuget v2”網址時提供了“nuget v3”網址(在我的情況下, apt-get給了我一些古老版本的nuget )。 通常,支持 v3 的 nuget 源也將支持 v2,因此如果您的 url 看起來像

https://<something>/api/v3/index.json

嘗試將其更改為

https://<something>/api/v2

暫無
暫無

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

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