Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Commit 61565f6

Browse files
authored
Show Razor build errors in non build server scenarios (#2737)
1 parent b2e9365 commit 61565f6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Microsoft.AspNetCore.Razor.Tools/Program.cs

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static int Main(string[] args)
4040
outputWriter.Dispose();
4141
errorWriter.Dispose();
4242

43+
Console.Write(output);
44+
Console.Error.Write(error);
45+
4346
// This will no-op if server logging is not enabled.
4447
ServerLogger.Log(output);
4548
ServerLogger.Log(error);

test/Microsoft.NET.Sdk.Razor.Test/IntegrationTests/BuildIntegrationTest.cs

+20
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Runtime.InteropServices;
88
using System.Threading.Tasks;
9+
using Microsoft.AspNetCore.Razor.Language;
910
using Microsoft.AspNetCore.Testing.xunit;
1011
using Microsoft.Extensions.DependencyModel;
1112
using Xunit;
@@ -652,6 +653,25 @@ public async Task Building_WorksWhenMultipleRazorConfigurationsArePresent()
652653
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
653654
}
654655

656+
[Fact]
657+
[InitializeTestProject("SimpleMvc")]
658+
public async Task Build_WithoutServer_ErrorDuringBuild_DisplaysErrorInMsBuildOutput()
659+
{
660+
var result = await DotnetMSBuild(
661+
"Build",
662+
"/p:UseRazorBuildServer=false /p:RazorLangVersion=5.0",
663+
suppressBuildServer: true);
664+
665+
Assert.BuildFailed(result);
666+
Assert.BuildOutputContainsLine(
667+
result,
668+
$"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}.");
669+
670+
// Compilation failed without creating the views assembly
671+
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
672+
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
673+
}
674+
655675
private static DependencyContext ReadDependencyContext(string depsFilePath)
656676
{
657677
var reader = new DependencyContextJsonReader();

0 commit comments

Comments
 (0)