我正在构建一个 .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.<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>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.
有人能告诉我这是什么,以及如何阻止它爆炸吗?这种情况最近才开始发生,我不知道为什么我什至需要代码分析库来进行发布。
这种情况发生在使用最新 .NET Core 库(我撰写本文时为 2.0.5)的 Windows 和 Linux 上。