[英]Nuget returned an unexpected status code '404 Not Found' - Package on local drive
試圖從 dll 生成 Nuget 包。 我們的項目之一是生成 ConfigurationCore.dll 和下面給出的項目程序集的引用
使用下面的 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 包源位於本地硬盤上...請建議解決此問題。
你的 URL 應該以/nuget 結尾
Nuget 返回了意外的狀態代碼“404 Not Found” - 本地驅動器上的包
確保src="..."
的路徑正確。
也許路徑應該是:
...\\ConfigurationCore\\ConfigurationCore\\...
而不是...\\ConfigurationCore\\...
。
簡而言之,請確保您可以根據該 url 找到 dll 文件。
注意:一般情況下,我們建議在 url 中使用相對路徑,例如:
<file src="bin\\x86\\Test\\ConfigurationCore.dll" target="lib\\net461" />
更新nuget.exe
的版本。
nuget.exe 3.4.x 存在問題,請下載nuget.exe 3.5及以上版本。
有關更多詳細信息,請參閱從 dll 創建 nuget 包。
更新:請按照以下步驟創建 nuget 包:
下載nuget.exe ,並將其設置在本地,例如D:\\NuGetLocalFolder
。
創建一個項目名稱為“ConfigurationCore”的新項目。
打開一個cmd,切換到之前存放nuget.exe的路徑。
使用命令行:
nuget spec "C:\\Users\\<Username>\\Source\\repos\\ConfigurationCore\\ConfigurationCore\\ConfigurationCore.csproj"
你會發現生成了.nuspec
,不要關閉這個 CMD 窗口。
編輯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>
保存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.