首页 文章

Nuget返回了一个意外的状态码'404 Not Found' - 本地驱动器上的包

提问于
浏览
1

尝试从dll生成Nuget包 . 我们的一个项目是生成下面给出的ConfigurationCore.dll和项目组件的参考

  • Microsoft.CSharp

  • Newtonsoft.Json

  • 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>

试图聚集在一起包依赖信息'ConfigurationCore.1.2.0'相对于项目'NugetTest',瞄准'.NETFramework,Version=v4.6.1'收集依赖信息了1.09秒试图与DependencyBehavior 'Lowest'解决,解决了包'ConfigurationCore.1.2.0'依赖依赖信息了0毫秒解决行动,以安装包'ConfigurationCore.1.2.0'解决行动,以安装包'ConfigurationCore.1.2.0' V2的输入位于'http://builtsrv1:8080/nuget/FindPackagesById()?id= 'ConfigurationCore'&semVerLevel = 2.0.0 ' returned an unexpected status code ' 404未找到' . 经过的时间:00:00:02.1513344 ==========完成==========

注意:Nuget包源是在本地硬盘上...请建议解决问题 .

3 回答

  • 0

    这是因为您引用了一条不存在的链接: http://builtsrv1:8080/nuget/FindPackagesById()?id='ConfigurationCore'&semVerLevel=2.0.0'

    You are using a method inside url, which is invalid 并且是错误的原因:

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

    修复网址,测试并重试,

  • 0

    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上有an issue,请下载nuget.exe 3.5及以上版本 .

    有关详细信息,请参阅Create nuget package from dlls .

    Update: 请按照以下步骤创建nuget包:

    • 下载nuget.exe,并将其设置在您的本地,例如 D:\NuGetLocalFolder .

    • 创建项目名称为“ConfigurationCore”的新项目 .

    • 打开cmd并切换到之前存储nuget.exe的路径 .

    • 使用命令行:

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

    enter image description here

    您会发现 .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包:

    enter image description here

    软件包 ConfigurationCore.1.2.0.nupkg 已创建到nuget.exe所在的文件夹中, D:\NuGetLocalFolder .

  • 1

    您的网址应以 /nuget 结尾

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

相关问题