
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).
Answer1:
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.