Build Nuget.Server

Container needs of the project company, small study to net frameworkupgrade the project to be net standard 2.0, but in the package upload nupkglater, vs the nuget plug-in does not recognize the dependency display Unsupported.

Xiao Bian suspected cause of the company's nuge server version is too low, then by nuget installed the latest Nuget.Server. When the project started, throwing 500 error:

[FileLoadException: 未能加载文件或程序集“NuGet.Server, Version=3.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)]
   nuget.server.App_Start.NuGetODataConfig.Start() in C:\Project_Works\github.com\nuget.server\nugetserver\App_Start\NuGetODataConfig.cs:35

[TargetInvocationException: 调用的目标发生了异常。]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +73
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +637
   WebActivatorEx.ActivationManager.Run() +101

[InvalidOperationException: 针对类型 WebActivatorEx.ActivationManager 的应用程序预启动初始化方法 Run 引发了异常,显示下列错误消息: 调用的目标发生了异常。。]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +615
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +549

[HttpException (0x80004005): 针对类型 WebActivatorEx.ActivationManager 的应用程序预启动初始化方法 Run 引发了异常,显示下列错误消息: 调用的目标发生了异常。。]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10075596
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Because nuget.server package in question, Xiao Bian finally downloaded the latest source code Nuget.Server

Local compile and run properly, but after the release of web projects deployed on the server, run the project returns a 500 error.

异常信息: 
    异常类型: NullReferenceException 
    异常消息: 未将对象引用设置到对象的实例。
   在 NuGet.Server.ServiceResolverExtensions.Resolve[T](IServiceResolver resolver) 位置 C:\Project_Works\github.com\nuget\NuGet.Server\src\NuGet.Server\Core\ServiceResolverExtensions.cs:行号 11
   在 ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
   在 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   在 System.Web.UI.Page.Render(HtmlTextWriter writer)
   在 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The log is determined: not relevant target injection start of the project, resulting in IOC when performing the analysis, the null pointer exception occurs.

Finally found the cause of the error in NuGetODataConfig.cs file. The assertion if deleted, re-released project, Nuget.Server run successfully, vs can properly identify the dependencies

// The consuming project executes this logic with its own copy of this class. This is done with a .pp file that is
// added and transformed upon package install.
#if DEBUG
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(NuGet.Server.App_Start.NuGetODataConfig), "Start")]
#endif

Guess you like

Origin www.cnblogs.com/frank-zhang/p/11404637.html