我已关注 instructions设置和托管我自己的 NuGet 提要。我在 上运行 Web 应用程序Windows 2012 (IIS 8.5) 盒子。
我构建并运行解决方案并获得 default.aspx 页面...
上面写着“您正在运行 NuGet.Server v2.8.60318.667”
和“单击此处查看您的包裹”。
当我单击“此处”链接时,我收到“404 - 未找到文件或目录”。错误。
Nuget 服务器;但是我在尝试运行时收到 404 错误
nugget.exe 列表命令。
成功。
<modules runAllManagedModulesForAllRequests="true">
似乎 url 路由不起作用,但我似乎无法确定我做错了什么。有些东西阻止了 odata 提要工作。
我知道 NuGet 服务器有很棒的 3rd 方实现,但我真的很想让免费的服务器运行起来,而且看起来应该很容易。任何想法或故障排除提示将不胜感激。
最佳答案
这个答案扩展了 AndrewD's answer 上留下的评论.
和他一样,我从一个 VB 项目开始,最后我和 OP 处于同一个阵营。然而,对我有用的是在这两个文件中将所有 C# 代码转换为 VB。
为了完成起见,我在下面包含了这些文件的转换后内容。
默认.aspx
<%@ 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>
NuGetODataConfig.vb
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
关于NuGet.Server 返回 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30539179/