为什么我的NuGet Gallery从NuGet push返回500?

为什么我的NuGet Gallery从NuGet push返回500?,nuget,Nuget,我在我工作的web服务器(IIS 7.0下)上设置了新的NuGet Gallery。网站本身已经建立并运行良好。我们可以注册帐户,确认电子邮件地址,甚至通过网站本身上传一个新包 我们的自动构建脚本需要能够将新构建的NuGet包推送到库中。当我使用NuGet的push命令时: nuget.exe push build\nuget\BaconAndEggs.1.0.0.1.nupkg 1451002a-8c63-4174-b7ed-73dd3e7bcdf0 -Source http://somene

我在我工作的web服务器(IIS 7.0下)上设置了新的NuGet Gallery。网站本身已经建立并运行良好。我们可以注册帐户,确认电子邮件地址,甚至通过网站本身上传一个新包

我们的自动构建脚本需要能够将新构建的NuGet包推送到库中。当我使用NuGet的push命令时:

nuget.exe push build\nuget\BaconAndEggs.1.0.0.1.nupkg 1451002a-8c63-4174-b7ed-73dd3e7bcdf0 -Source http://somenearbyserver/
我得到以下结果:

Pushing BaconAndEggs 1.0.0.1 to 'http://somenearbyserver/'...
Failed to process request. 'Internal Server Error'.
The remote server returned an error: (500) Internal Server Error..
该网站可以上传一个新的软件包,但命令行不行。如果我在运行fiddler的情况下尝试push命令,它会在执行push命令时观察到两个连续的请求。一个似乎是触摸网站以确保它在那里,而第二个是实际的推送命令

Request 1: GET http://somenearbyserver/ 200 OK
Request 2: PUT http://somenearbyserver/api/v2/package/ 500 Internal Server Error
PUT请求的内容是正确的,它包含API密钥和有效负载。在web服务器上查看,事件查看器中没有错误,elmah没有捕获任何内容

Fiddler将此显示为对PUT的响应:

HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Wed, 18 Jan 2012 20:21:08 GMT
Connection: close
Content-Length: 1208

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>500 - Internal server error.</h2>
  <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>
 </fieldset></div>
</div>
</body>
</html>

还包括一些帮助文本、基于验证权限的建议等,但据我所知,权限没有问题。

我想您指的是新的库:


能否尝试从管理员帐户点击/elmah.axd,查看是否获得有关错误的更多信息?

我通过更改IIS用户的权限解决了此问题。我已将写入权限添加到
IIS\u IUSRS

右键单击
IIS>编辑权限>安全中的站点


从这里,您可以添加用户或组,并授予他们写权限。

因为没有提到,这里是我的场景:
我能够毫无问题地推送(和检索)大多数包。但是,当我试图推送一个包时,它一直导致404错误。一些在线消息来源指出,我应该为.nupkg添加一个mime类型,然而,所有这一切(无论mime类型如何)都是将错误转化为500内部服务器错误


事实证明,所讨论的包比正常的包大一点,IIS将默认请求限制限制为30MB。将设置
system.webServer.security.requestFiltering.requestLimits.maxAllowedContentLength
更改为更大的值(在我删除添加的mime类型后)可以解决此问题。

在我的情况下,它是一个旧的本地nuget服务器。我在日志中找到的消息:

“YourLib”的架构版本与版本不兼容 NuGet的“某个版本a.b”。请将NuGet升级至最新版本 从


在我的例子中,我降级了nuget(下载了一个旧的nuget.exe)并重新创建了包。推动现在起作用了。我不想在其他地方干扰这个过程,我需要一个快速的解决方案,但这当然取决于一个场景。从长远来看,我将更新nuget。

我建议您去IIS主机服务器打开eventvwr,您应该能够准确地说出错误发生的原因。 在Windows日志/应用程序中查找

在我的情况下,这是因为磁盘已满。消息如下所示:

Application information: 
    Application domain: /LM/W3SVC/4/ROOT-1-131895206439239270 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: E:\NuGet.Server\src\NuGet.Server\ 
    Machine name: CM 

Process information: 
    Process ID: 1876 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\SYSTEM 

Exception information: 
    Exception type: IOException 
    Exception message: **There is not enough space on the disk.**
...
...

是的,我指的是新画廊。我检查了一下艾玛是否在录音,结果什么也没发现。我甚至在应用程序的文件夹中检查了错误xml文件,但什么都没有。我会尝试在begin request中设置一个断点,以查看代码是否被命中。如果不是,那可能是IIS配置问题。我在本地开发机器上运行了该项目,并尝试使用NuGet.exe在本地推送包,但效果很好。我认为这肯定是一个IIS配置问题。对什么配置错误有什么想法吗?对库的其他请求是否有效(例如提要或UI)?你能试着运行fiddler看看好的/坏的请求是什么样子的吗?我可以让命令行列出提要中的包,而gallery网站本身工作正常。在fiddler中,我可以看到所有良好的请求和响应,但仍能获得500分。一旦我更改了站点中的api文件夹以返回详细错误,我就开始获得更多的错误信息。我会把它加到问题上。请注意,组名为
IIS\u IUSRS
(带有额外的
i
)。右键单击站点时没有“编辑权限”。您应该为应用程序池用户添加写入权限,
IIS APPPOOL\MyAppPoolName
。注意连续三个P。将应用程序池的名称替换为MyAppPoolName。
Application information: 
    Application domain: /LM/W3SVC/4/ROOT-1-131895206439239270 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: E:\NuGet.Server\src\NuGet.Server\ 
    Machine name: CM 

Process information: 
    Process ID: 1876 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\SYSTEM 

Exception information: 
    Exception type: IOException 
    Exception message: **There is not enough space on the disk.**
...
...