dotnet核心方法'ValidateOptions'...没有实现

编程入门 行业动态 更新时间:2024-10-28 21:22:22
本文介绍了dotnet核心方法'ValidateOptions'...没有实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在构建一个.NET Core解决方案,它的构建还不错,但是当我尝试发布它时,它因以下错误而崩溃:

方法'ValidateOptions',Version = 2.3.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'没有一个实现。 Microsoft.CodeAnalysis.CSharp.CSharpCompilation中的.Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()中创建.Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument代码文档) Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument文档)中的 Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)中的 Microsoft.AspNetCore.Mvc中的 .Razor.ViewCompilation.Internal.PrecompileRunCommand。<> c__DisplayClass23_0。< GenerateCode> b__0(Int32 i)位于System.Threading.Tasks.Parallel。< cc.DisplayClass19_0`1。< ForWorker> b__1 (RangeWorker& currentWorker,Int32超时,Boolean& DeleteDelegateYieldedBeforeCompletion)-从上一个引发异常的位置开始的堆栈结束跟踪--System.Runtime.ExceptionServices.ExceptionDispatchInfo.T处的 <> c__DisplayClass19_0`1。< ForWorker> b__1(RangeWorker& amp; hrow() at System.Threading.Tasks.Parallel。 currentWorker,Int32超时,布尔值和放大器; System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean&yieldedBeforeCompletion)在System.Threading.Tasks.TaskReplicator.Replica.Execute()

在较高的详细度下,我会收到以下信息(我不知道这样做是否会更好):

1:10>文件 C:ForUsers\Jeremy Holovacs\.nuget\packages\microsoft中的目标 _RunForCore。 aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets来自项目 D:\Projects\MySolution\MySolution.App \MySolution.App.csproj(目标 _MvcRazorPrecompile取决于它):使用程序集 C:\Users\Jeremy Holovacs\.nuget\packages\microsoft中的 GetDotNetHost任务。 aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks.dll。 任务 GetDotNetHost 完成执行任务 GetDotNetHost。 使用程序集 Microsoft.Build.Tasks.Core,版本= 15.1.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a中的 Exec任务。 任务 Exec C:\Program Files\dotnet\dotnet.exe exec --runtimeconfig D:\Projects\MySolution\MySolution.App\bin\ \netcoreapp2.0\MySolution.App.runtimeconfig.json --depsfile D:\Projects\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.deps.json C:\用户\Jeremy Holovacs\.nuget\软件包\microsoft.aspnetcore.mvc.razor.view编译\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor。 ViewCompilation.dll @ obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp 方法'ValidateOptions'类型为Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions' 'Microsoft.CodeAnalysis.CSharp,版本= 2.3.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'没有实现。 Microsoft.CodeAnalysis.CSharp.CSharpCompilation中的.Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()中创建.Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument代码文档) Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument文档)中的 Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)中的 Microsoft.AspNetCore.Mvc中的 .Razor.ViewCompilation.Internal.PrecompileRunCommand。<> c__DisplayClass23_0。< GenerateCode> b__0(Int32 i)位于System.Threading.Tasks.Parallel。< cc.DisplayClass19_0`1。< ForWorker> b__1 (RangeWorker& currentWorker,Int32超时,Boolean& ReplicationDelegateYieldedBeforeCompletion)-从上一个引发异常的位置开始的堆栈结束跟踪--- 在System.Threading.Tasks.Parallel处System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()。<> c__DisplayClass19_0`1。< ForWorker> b__1(RangeWorker& currentWorker,Int32超时,布尔值和放大器;在System.Threading.Tasks.TaskReplicator.Replica复制$ D $ $ $ .System.Threading.Tasks。TaskReplicator.Replica.Execute($ 1 $ 10.10>在System.Threading.Tasks。TaskReplicator.Replica.Execute(布尔& yieldedBeforeCompletion) ; C:\用户\Jeremy Holovacs\.nuget\软件包\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor .ViewCompilation.targets(60,5):错误MSB3073:命令 C:\Program Files\dotnet\dotnet.exe exec --runtimeconfig D:\Projects\MySolution\MySolution.App \bin\netcoreapp2.0\MySolution.App.runtimeconfig.json --depsfile D:\项目\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.deps .json C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore。 Mvc.Razor.ViewCompilation.dll @ obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp用c退出ode 1. [D:\Projects\MySolution\MySolution.App\MySolution.App.csproj] 完成执行任务 Exec-失败。 1:10>在项目 MySolution.App.csproj中完成构建目标 _RunForCore-失败。 执行任务 CallTarget完成-失败。 1:10>在项目 MySolution.App.csproj中完成构建目标 MvcRazorPrecompile-失败。 1:10>完成的建筑项目 D:\Projects\MySolution\MySolution.App\MySolution.App.csproj(发布目标)-失败。 生成失败。

有人可以告诉我这是什么,如何阻止它爆炸?这只是最近才开始发生,我不知道为什么我什至需要代码分析库来发布。

这是在Windows和Linux上使用最新.NET发生的情况核心库(在我撰写本文时为2.0.5)。

解决方案

好的,这很愚蠢,但是可以。

我开始用谷歌搜索可以作为关键字找到的所有内容,最后对在 microsoft.aspnetcore上查找github问题有所了解。 mvc.razor.viewcompilation 。最终,这导致我进入 ASP.NET Core中的Razor视图编译和预编译页面,该页面反过来又发出了这个漂亮的小警告:

重要

在ASP.NET Core中执行自包含部署(SCD)时,剃刀视图预编译当前不可用2.0。该功能将在2.1发行时向SCD提供。

现在,它本身并不能告诉您任何信息,否则,它建议添加这样的一行:

< MvcRazorCompileOnPublish> false< ; / MvcRazorCompileOnPublish>

...到我的.csproj文件中。

您认为这样有用吗?我认为这完全是MS的失败,因为它以这种神秘的方式炸毁并且没有任何有关此错误的含义的文档,但是基本上,默认情况下,默认情况下,当您发布时,您会预编译您的剃刀视图,但这基本上不是从命令行或Linux在.NET Core 2.0中受支持...他们希望它在2.1之前能正常工作,但是...好吧,让我们说我不会屏住呼吸。

希望这可以帮助其他人将头撞在墙上,寻找答案。

I'm building a .NET Core solution, which is building just fine, but when I try to publish it, it blows up with the following error:

Method 'ValidateOptions' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Create at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors() at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.<>c__DisplayClass23_0.<GenerateCode>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute()

On a higher verbosity, I get the following information (I don't know if this is significantly better):

1:10>Target "_RunForCore" in file "C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets" from project "D:\Projects\MySolution\MySolution.App\MySolution.App.csproj" (target "_MvcRazorPrecompile" depends on it): Using "GetDotNetHost" task from assembly "C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks.dll". Task "GetDotNetHost" Done executing task "GetDotNetHost". Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Task "Exec" "C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig "D:\Projects\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.runtimeconfig.json" --depsfile "D:\Projects\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.deps.json" "C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp" Method 'ValidateOptions' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Create at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors() at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.<>c__DisplayClass23_0.<GenerateCode>b__0(Int32 i) at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute() 1:10>C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig "D:\Projects\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.runtimeconfig.json" --depsfile "D:\Projects\MySolution\MySolution.App\bin\netcoreapp2.0\MySolution.App.deps.json" "C:\Users\Jeremy Holovacs\.nuget\packages\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.2\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [D:\Projects\MySolution\MySolution.App\MySolution.App.csproj] Done executing task "Exec" -- FAILED. 1:10>Done building target "_RunForCore" in project "MySolution.App.csproj" -- FAILED. Done executing task "CallTarget" -- FAILED. 1:10>Done building target "MvcRazorPrecompile" in project "MySolution.App.csproj" -- FAILED. 1:10>Done Building Project "D:\Projects\MySolution\MySolution.App\MySolution.App.csproj" (Publish target(s)) -- FAILED. Build FAILED.

Can someone tell me what this is, and how I can stop it from blowing up? This just started happening recently, and I'm not aware of why I even need code analysis libraries for publishing.

This is happening on Windows and Linux with the latest .NET Core libraries (2.0.5 at the time I'm writing this).

解决方案

OK, this was stupid, but it worked.

I started googling everything I could find as a keyword with this, and finally got an inkling on looking up github issues on microsoft.aspnetcore.mvc.razor.viewcompilation. This ultimately led me to the Razor view compilation and precompilation in ASP.NET Core page, which in turn has this nifty little warning:

Important

Razor view precompilation is currently unavailable when performing a self-contained deployment (SCD) in ASP.NET Core 2.0. The feature will be available for SCDs when 2.1 releases.

Now, that in itself doesn't tell you anything, other than it doesn't work, but following up, it sorta suggested adding a line like this:

<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>

...into my .csproj file.

Would you believe that worked? I consider this a complete fail on MS's part for blowing up in such a cryptic way and not having any documentation about what this error means, but basically, by default, when you publish, you precompile your razor views, but this basically isn't supported in .NET Core 2.0 from a command line or from linux... they expect it to be working by 2.1, but... well, let's just say I won't hold my breath.

Hopefully this helps out someone else banging their head against the wall, looking for answers about this.

更多推荐

dotnet核心方法'ValidateOptions'...没有实现

本文发布于:2023-11-14 10:48:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:核心   方法   dotnet   ValidateOptions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!