dotnet core方法’ValidateOptions’…没有实现
我正在构建一个.NET Core解决方案,它正在构建得很好,但是当我尝试发布它时,会出现以下错误:
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.b__0(Int32 i) at System.Threading.Tasks.Parallel.c__DisplayClass19_0`1.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.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>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.b__0(Int32 i) at System.Threading.Tasks.Parallel.c__DisplayClass19_0`1.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.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.
有人能告诉我这是什么,以及如何阻止它爆炸? 这刚刚开始发生,我不知道为什么我甚至需要代码分析库进行发布。
这种情况发生在Windows和Linux上,带有最新的.NET Core库(当时我写的是2.0.5)。
好吧,这是愚蠢的,但它确实有效。
我开始谷歌搜索我能找到的所有关键字,最后得到了关于在microsoft.aspnetcore.mvc.razor.viewcompilation
上查找github问题的内容。 这最终导致我在ASP.NET Core页面中进行Razor视图编译和预编译 ,而这反过来又有了这个漂亮的小警告:
重要
在ASP.NET Core 2.0中执行自包含部署(SCD)时,Razor视图预编译当前不可用。 2.1版本发布时,该function将适用于SCD。
现在,这本身并没有告诉你什么,除了它不起作用,但是跟进,它有点建议添加这样的一行:
false
…进入我的.csproj文件。
你相信这有用吗? 我认为这是MS完全失败的一部分,因为它以如此神秘的方式爆炸并没有任何关于这个错误意味着什么的文档,但基本上,默认情况下,当你发布时,你预先编译你的剃刀视图,但这基本上不是从命令行或Linux中支持.NET Core 2.0 ……他们希望它能在2.1之前工作,但是……好吧,我只想说我不会屏住呼吸。
希望这可以帮助别人敲头撞墙,寻找答案。
- 应用程序在添加Oauth时重定向到Account / AccessDenied
- 在.NET Core中引用时,从程序集文件加载的类型不等于相同的类型
- 在ASP.NET Core应用程序中设置RabbitMQ使用者
- 通过命令行构建.NET Core应用程序,以便它可以在未安装.NET Core的计算机上运行
- Microsoft.DotNet.Common.Targets(262,5):错误:对象引用未设置为对象的实例
- .NET Core中的SOAP?
- 在dotnet核心中读取json文件时出错“已达到inotify实例数量的已配置用户限制(128)”
- 无法从UWP引用.NET Core库
- 是否支持.NET Core中的Microsoft.AspNet.WebApi.Client?