NuGet推送版本3.1.2返回405 HTTP错误(不允许的方法)

时间:2018-07-25 15:33:51

标签: asp.net iis nuget iis-8.5 nuget-server

我使用最新版本3.1.2的私有NuGet.Server。 我的IIS未安装WebDAV功能。 因此,其他recommendations的错误修复方法405 (method not allowed)无法解决我的问题。

我的IIS NuGet应用程序已使用系统用户“ IUSR”启用了匿名身份验证。 该用户对packagePath E:\NuGet\packages

具有完全权限

我的nuget.server的push命令如下:

  

nuget push Mypackage.1.0.0.nupkg -NonInteractive-源http://srv-dev:8080/SoNuGetHost/ -ApiKey VSTS-详细程度

错误部分如下:

  

D:> nuget push OneSignal.RestAPIv3.Client.1.0.3.nupkg -NonInteractive-源http://srv-dev:8080/SoNugetHost/ -ApiKey VSTS-详细程度

     

NuGet版本:4.6.2.5055

     

将OneSignal.RestAPIv3.Client.1.0.3.nupkg推送到'http://srv-dev:8080/SoNugetHost/'...

     

输入http://srv-dev:8080/SoNugetHost/

     

MethodNotAllowed http://srv-dev:8080/SoNugetHost/ 446ms

下面是Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
    For a description of web.config changes see     http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
    <system.Web>
        <httpRuntime targetFramework="4.6" />
    </system.Web>
-->
<system.web>
    <compilation targetFramework="4.6" />
    <!-- maxRequestLength is specified in Kb -->
    <httpRuntime targetFramework="4.6" maxRequestLength="2147483647" />
</system.web>
<system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
</system.codedom>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
        <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
        <remove name="OPTIONSVerbHandler" />
        <remove name="TRACEVerbHandler" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
         <!-- Depending on IIS configuration, these may have to be added.
         <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
         <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
         <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        <remove name="OPTIONSVerbHandler" />
        <remove name="TRACEVerbHandler" />
        <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
         -->
    </handlers>
    <staticContent>
    <mimeMap fileExtension=".nupkg" mimeType="application/zip" />
    </staticContent>\
    <security><requestFiltering><!-- maxAllowedContentLength is specified in Bytes --><requestLimits maxAllowedContentLength="2147483647" /></requestFiltering></security></system.webServer>
<appSettings>
    <!--
    Determines if an Api Key is required to push\delete packages from the server. 
    -->
    <add key="requireApiKey" value="true" />
    <!-- 
    Set the value here to allow people to push/delete packages from the server.
    NOTE: This is a shared key (password) for all users.
    -->
    <add key="apiKey" value="VSTS" />
    <!--
    Change the path to the packages folder. Default is ~/Packages.
    This can be a virtual or physical path.
    -->
    <add key="packagesPath" value="E:\NuGet\Packages" />
    <!--
    Change the name of the internal cache file. Default is machine name (System.Environment.MachineName).
    This is the name of the cache file in the packages folder. No paths allowed.
    -->
    <add key="cacheFileName" value="" />
    <!--
    Set allowOverrideExistingPackageOnPush to false to mimic NuGet.org's behaviour (do not allow overwriting packages with same id + version).
    -->
    <add key="allowOverrideExistingPackageOnPush" value="true" />
    <!--
    Set ignoreSymbolsPackages to true to filter out symbols packages. Since NuGet.Server does not come with a symbol server,
    it makes sense to ignore this type of packages. When enabled, files named `.symbols.nupkg` or packages containing a `/src` folder will be ignored.

    If you only push .symbols.nupkg packages, set this to false so that packages can be uploaded.
    -->
    <add key="ignoreSymbolsPackages" value="true" />
    <!--
    Set enableDelisting to true to enable delist instead of delete as a result of a "nuget delete" command.
    - delete: package is deleted from the repository's local filesystem.
    - delist: 
    - "nuget delete": the "hidden" file attribute of the corresponding nupkg on the repository local filesystem is turned on instead of deleting the file.
    - "nuget list" skips delisted packages, i.e. those that have the hidden attribute set on their nupkg.
    - "nuget install packageid -version version" command will succeed for both listed and delisted packages.
        e.g. delisted packages can still be downloaded by clients that explicitly specify their version.
    -->
    <add key="enableDelisting" value="true" />
    <!--
    Set enableFrameworkFiltering to true to enable filtering packages by their supported frameworks during search.
    -->
    <add key="enableFrameworkFiltering" value="false" />
    <!--
    When running NuGet.Server in a NAT network, ASP.NET may embed the server's internal IP address in the V2 feed.
    Uncomment the following configuration entry to enable NAT support.
    -->
    <!-- <add key="aspnet:UseHostHeaderForRequestUrl" value="true" /> -->
    <!--
    Set enableFileSystemMonitoring to true (default) to enable file system monitoring (which will update the package cache appropriately on file system changes).
    Set it to false to disable file system monitoring.
    NOTE: Disabling file system monitoring may result in increased storage capacity requirements as package cache may only be purged by a background job running 
    on a fixed 1-hour interval.
    -->
    <add key="enableFileSystemMonitoring" value="true" />
</appSettings>
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
    </dependentAssembly>
    </assemblyBinding>
</runtime>
</configuration>
<!--ProjectGuid: DE6B2A91-48E9-4ADF-BE86-55AD27F6EB1B-->

那么...在解决这个问题上,还有人有其他提示吗? 谢谢

编辑

这是IIS(在Server 2012 R2上的版本8.5)的TraceLogging的输出:

<EventData>
<Data Name="ContextId">{80000457-0002-FC00-B63F-84710C7967BB}</Data>
<Data Name="ModuleName">StaticFileModule</Data>
<Data Name="Notification">128</Data>
<Data Name="HttpStatus">405</Data>
<Data Name="HttpReason">Method Not Allowed</Data>
<Data Name="HttpSubStatus">0</Data>
<Data Name="ErrorCode">2147942401</Data>
<Data Name="ConfigExceptionInfo"></Data>
</EventData>

2 个答案:

答案 0 :(得分:1)

我的天哪...

经过数小时的尝试和错误,我从NuGet.Server存储库中找到了this当前的PR。

贡献者指出,旧的nuget服务器版本2.8.5xx使用了根URL,并自动api/v2/package对其进行了扩展。但是新版本需要后缀nuget。 所以我只是将nuget push命令更改为:

  

nuget push Mypackage.1.0.0.nupkg -NonInteractive-源http://srv-dev:8080/SoNuGetHost/ nuget -ApiKey VSTS-详细程度

另外,我需要将IIS配置上的身份验证方式从匿名身份验证更改为Windows身份验证。

因此,我需要将ApplicationPool设置从classicMode更改为IntegratedMode。 (我曾用anonymous和classicMode尝试过,但这没用)

答案 1 :(得分:0)

在您的web.config中,您具有:

<add key="packagesPath" value="E:\NuGet\Packages" />

尝试将其更改为

<add key="packagesPath" value="" />

编辑: 将以下行中的动词更改为*

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />



<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />