Show Razor build errors in non build server scenarios (#2737)
This commit is contained in:
parent
b2e9365084
commit
61565f61f9
|
|
@ -40,6 +40,9 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
||||||
outputWriter.Dispose();
|
outputWriter.Dispose();
|
||||||
errorWriter.Dispose();
|
errorWriter.Dispose();
|
||||||
|
|
||||||
|
Console.Write(output);
|
||||||
|
Console.Error.Write(error);
|
||||||
|
|
||||||
// This will no-op if server logging is not enabled.
|
// This will no-op if server logging is not enabled.
|
||||||
ServerLogger.Log(output);
|
ServerLogger.Log(output);
|
||||||
ServerLogger.Log(error);
|
ServerLogger.Log(error);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Razor.Language;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.Extensions.DependencyModel;
|
using Microsoft.Extensions.DependencyModel;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -652,6 +653,25 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileExists(result, OutputPath, "SimpleMvc21.Views.pdb");
|
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)
|
private static DependencyContext ReadDependencyContext(string depsFilePath)
|
||||||
{
|
{
|
||||||
var reader = new DependencyContextJsonReader();
|
var reader = new DependencyContextJsonReader();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue