我已按照instructions设置并托管我自己的NuGet Feed。我正在 Windows 2012(IIS 8.5)框中运行Web应用程序。
我构建并运行解决方案并获取default.aspx页面......
其中说"您正在运行NuGet.Server v2.8.60318.667" 和"点击此处查看您的包裹"。
当我点击" here"链接我得到了一个" 404 - 找不到文件或目录。"错误。
Web.Config有以下条目
<modules runAllManagedModulesForAllRequests="true">
web.config还有一个条目,可以将.nupkg扩展名注册为mimeType =&#34; application / zip&#34;
似乎网址路由不起作用,但我似乎无法确定我做错了什么。有些事情阻止了odata饲料的运转。
我知道NuGet服务器有很好的第三方实现,但我真的想让免费的一个工作,看起来它应该很容易。任何想法或疑难解答提示将不胜感激。
答案 0 :(得分:3)
如果你将项目命名为Nuget.Server,因为你生成的dll将是Nuget.Server.dll,它将无法工作,因为Nuget.Server.dll是服务器的实际dll。 将您的程序集名称重命名为其他名称。
答案 1 :(得分:3)
如果您创建一个新的空 VB项目,您还将获得404(在包中并使用NuGet Manager进行浏览)。
您似乎必须将项目创建为 C#,它的工作方式与广告一样!
然而源代码看起来完全相同:(
答案 2 :(得分:1)
我找到的任何一个帖子都没有提到一个答案。如果您将项目命名为Nuget.Server,即使发布将在IIS中运行,ninject也将无法设置包列表路由,因为它将尝试加载错误的DLL并输出错误。
以下是其他一些可能的答案:
答案 3 :(得分:1)
%APPDATA%\ NuGet或$(SolutionDir).nuget中的NuGet.config文件可能指的是意外的&#34;活动源&#34;网址。例如,TFS构建代理程序安装带来的nuget.exe可能只知道NuGet v2协议,而URL指的是v3协议。或者NuGet.config中可能缺少自定义NuGet服务器URL。
答案 4 :(得分:1)
我有类似的问题,我找到了解决方案!我创建了一个私有nuget服务器,按照说明创建一个空的ASP.NET项目(我在VS2015上),然后安装nuget.server(目前是v2.11.3.0)。我能够运行并看到网页,除了我无法使用“nuget.exe push”上传包。我找到了可怕的404未找到错误。
我最终克隆了github上的nuget.server源代码并直接运行了哪个工作正常!我发现我的web.config
不正确。对我来说,关键是
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DEBUG" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
中的
<system.webServer>/<handlers>
部分。
我建议有问题的人应该去github并比较web.config文件。
BTW:nuget.server
安装应该取代您的web.config
。这对我来说可能没有用。
答案 5 :(得分:1)
我注意到当您尝试上传相当大的nuget包时出现404错误。我提高了maxAllowedContentLength
并且它有所帮助。
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="31457280"/>
</requestFiltering>
</security>
</system.webServer>
答案 6 :(得分:1)
FWIW,我错误地尝试从http://[server]/nuget/Packages获取包并得到了相同的错误。从源URL末尾删除/ Packages是答案,因此http://[server]/nuget是正确的URL。
答案 7 :(得分:1)
此答案扩展了AndrewD's answer上留下的评论。
和他一样,我开始使用VB项目,最后我和OP一样在同一个阵营。然而,对我来说有用的是在这两个文件中将所有C#代码转换为VB。
为了完成,我将在下面包含这些文件的转换后内容。
<%@ Page Language="VB" %>
<%@ Import Namespace="NuGet.Server" %>
<%@ Import Namespace="NuGet.Server.App_Start" %>
<%@ Import Namespace="NuGet.Server.Infrastructure" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>NuGet Private Repository</title>
<style>
body { font-family: Calibri; }
</style>
</head>
<body>
<div>
<h2>You are running NuGet.Server v<%= Gettype(NuGetODataConfig).Assembly.GetName().Version %></h2>
<p>
Click <a href="<%= VirtualPathUtility.ToAbsolute("~/nuget/Packages") %>">here</a> to view your packages.
</p>
<fieldset style="width:800px">
<legend><strong>Repository URLs</strong></legend>
In the package manager settings, add the following URL to the list of
Package Sources:
<blockquote>
<strong><%= Helpers.GetRepositoryUrl(Request.Url, Request.ApplicationPath) %></strong>
</blockquote>
<% if string.IsNullOrEmpty(ConfigurationManager.AppSettings("apiKey")) Then %>
To enable pushing packages to this feed using the <a href="https://www.nuget.org/downloads">NuGet command line tool</a> (nuget.exe), set the <code>apiKey</code> appSetting in web.config.
<% else %>
Use the command below to push packages to this feed using the <a href="https://www.nuget.org/downloads">NuGet command line tool</a> (nuget.exe).
<blockquote>
<strong>nuget.exe push {package file} {apikey} -Source <%= Helpers.GetPushUrl(Request.Url, Request.ApplicationPath) %></strong>
</blockquote>
<% end if %>
</fieldset>
<% if Request.IsLocal Then %>
<fieldset style="width:800px">
<legend><strong>Adding packages</strong></legend>
To add packages to the feed put package files (.nupkg files) in the folder
<code><% = PackageUtility.PackagePhysicalPath %></code><br/><br/>
Click <a href="<%= VirtualPathUtility.ToAbsolute("~/nuget/clear-cache") %>">here</a> to clear the package cache.
</fieldset>
<% End If %>
</div>
</body>
</html>
Imports System.Net.Http
Imports System.Web.Http
Imports System.Web.Http.ExceptionHandling
Imports System.Web.Http.Routing
Imports NuGet.Server
Imports NuGet.Server.Infrastructure
Imports NuGet.Server.V2
<Assembly: WebActivatorEx.PreApplicationStartMethod(GetType(MGINuGet.App_Start.NuGetODataConfig), "Start")>
Namespace MGINuGet.App_Start
Public Module NuGetODataConfig
Public Sub Start()
ServiceResolver.SetServiceResolver(New DefaultServiceResolver())
Dim config As HttpConfiguration = GlobalConfiguration.Configuration
NuGetV2WebApiEnabler.UseNuGetV2WebApiFeed(config, "NuGetDefault", "nuget", "PackagesOData")
config.Services.Replace(GetType(IExceptionLogger), New TraceExceptionLogger())
Trace.Listeners.Add(New TextWriterTraceListener(System.Web.Hosting.HostingEnvironment.MapPath("~/NuGet.Server.log")))
Trace.AutoFlush = True
config.Routes.MapHttpRoute(name:="NuGetDefault_ClearCache",
routeTemplate:="nuget/clear-cache",
defaults:=New With {Key .controller = "PackagesOData", Key .action = "ClearCache"},
constraints:=New With {Key .httpMethod = New HttpMethodConstraint(HttpMethod.Get)})
End Sub
End Module
End Namespace
答案 8 :(得分:0)
我今天遇到了这个问题。实际上我需要做的是Global.asax:
void Application_Start(object sender, EventArgs e)
{
NuGetRoutes.Start();
}
答案 9 :(得分:0)
我在干净的Visual Studio 2017
Web项目中遇到了这个问题。
从Visual Studio 2015
重新创建并以.NET 4.6.1为目标进行重新排序