diff --git a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs index 8d9c5518c5..3cd93a2335 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/Program.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/Program.cs @@ -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); diff --git a/test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs index c4e342c43d..564b8b2745 100644 --- a/test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs +++ b/test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs @@ -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();