Show Razor build errors in non build server scenarios (#2737)

This commit is contained in:
Ajay Bhargav Baaskaran 2018-11-16 15:47:02 -08:00 committed by GitHub
parent b2e9365084
commit 61565f61f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -40,6 +40,9 @@ namespace Microsoft.AspNetCore.Razor.Tools
outputWriter.Dispose();
errorWriter.Dispose();
Console.Write(output);
Console.Error.Write(error);
// This will no-op if server logging is not enabled.
ServerLogger.Log(output);
ServerLogger.Log(error);

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.DependencyModel;
using Xunit;
@ -652,6 +653,25 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithoutServer_ErrorDuringBuild_DisplaysErrorInMsBuildOutput()
{
var result = await DotnetMSBuild(
"Build",
"/p:UseRazorBuildServer=false /p:RazorLangVersion=5.0",
suppressBuildServer: true);
Assert.BuildFailed(result);
Assert.BuildOutputContainsLine(
result,
$"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}.");
// Compilation failed without creating the views assembly
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
}
private static DependencyContext ReadDependencyContext(string depsFilePath)
{
var reader = new DependencyContextJsonReader();