Home Why do dotnet command line builds fail on MVC View errors but VS2017 does not?

# Why do dotnet command line builds fail on MVC View errors but VS2017 does not?

Mourndark
1#
Mourndark Published in 2018-02-08 11:07:26Z
 I'm working on a .NET Core 2 MVC project in VS2017. I've noticed that when building with the command line, any C# errors in my Razor views cause the build to fail. However when building in VS2017 the build will run fine. If I have a .cshtml file open that contains C# errors, they will show as errors in the error list, but they won't stop the build from completing. I'm not sure why I'm getting two different results as surely both are using MSBuild under the hood? Is there a way I get VS to fail on Razor C# errors in the same way as the command line does?
CalC
2#
 With ASP.NET Core 2.x Razor, views can be precompiled on publish if the Microsoft.AspNetCore.Mvc.Razor.ViewCompilation package is included (setting the MvcRazorCompileOnPublish to true is optional). It is not currently possible to compile views as part of a standard debug build. For further details see Razor view compilation and precompilation in ASP.NET Core If your project targets .NET Framework, include a package reference to Microsoft.AspNetCore.Mvc.Razor.ViewCompilation:   Prepare the app for a framework-dependent deployment by executing a command such as the following at the project root: > dotnet publish -c Release  A .PrecompiledViews.dll file, containing the compiled Razor views, is produced when precompilation succeeds.