dotnet 核心方法 'ValidateOptions' ... 没有实现 [英] dotnet core Method 'ValidateOptions' ... does not have an implementation

查看:21
本文介绍了dotnet 核心方法 'ValidateOptions' ... 没有实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:UsersJeremy Holovacs.nugetpackagesmicrosoft.aspnetcore.mvc.razor.viewcompilation2.0.2uild
etstandard2.0Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets" from project "D:ProjectsMySolutionMySolution.AppMySolution.App.csproj" (target "_MvcRazorPrecompile" depends on it):
       Using "GetDotNetHost" task from assembly "C:UsersJeremy Holovacs.nugetpackagesmicrosoft.aspnetcore.mvc.razor.viewcompilation2.0.2uild
etstandard2.0Microsoft.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 Filesdotnetdotnet.exe" exec --runtimeconfig "D:ProjectsMySolutionMySolution.Appin
etcoreapp2.0MySolution.App.runtimeconfig.json" --depsfile "D:ProjectsMySolutionMySolution.Appin
etcoreapp2.0MySolution.App.deps.json" "C:UsersJeremy Holovacs.nugetpackagesmicrosoft.aspnetcore.mvc.razor.viewcompilation2.0.2uild
etstandard2.0Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"objDebug
etcoreapp2.0microsoft.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:UsersJeremy Holovacs.nugetpackagesmicrosoft.aspnetcore.mvc.razor.viewcompilation2.0.2uild
etstandard2.0Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:Program Filesdotnetdotnet.exe" exec --runtimeconfig "D:ProjectsMySolutionMySolution.Appin
etcoreapp2.0MySolution.App.runtimeconfig.json" --depsfile "D:ProjectsMySolutionMySolution.Appin
etcoreapp2.0MySolution.App.deps.json" "C:UsersJeremy Holovacs.nugetpackagesmicrosoft.aspnetcore.mvc.razor.viewcompilation2.0.2uild
etstandard2.0Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"objDebug
etcoreapp2.0microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [D:ProjectsMySolutionMySolution.AppMySolution.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:ProjectsMySolutionMySolution.AppMySolution.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.

这发生在 Windows 和 Linux 上,使用最新的 .NET Core 库(我写这篇文章时是 2.0.5).

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.

我开始在谷歌上搜索所有我能找到的关键字,最终在 microsoft.aspnetcore.mvc.razor.viewcompilation 上查找 github 问题.这最终让我看到了 ASP.NET Core 中的 Razor 视图编译和预编译 页面,这又是一个漂亮的小警告:

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:

重要

Razor 视图预编译当前在执行时不可用ASP.NET Core 2.0 中的自包含部署 (SCD).该功能将2.1 发布时可用于 SCD.

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>

...进入我的 .csproj 文件.

...into my .csproj file.

你相信这行得通吗?我认为这完全失败了 MS 以如此神秘的方式爆炸并且没有任何关于此错误含义的文档,但基本上,默认情况下,当您发布时,您预编译了您的剃刀视图,但这基本上不是在 .NET Core 2.0 中从命令行或从 linux 支持……他们希望它在 2.1 之前可以工作,但是……好吧,我们只能说我不会屏住呼吸.

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' ... 没有实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆