diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs
index 637421409d..ba38782ceb 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Tools/src/GenerateCommand.cs
@@ -214,24 +214,27 @@ namespace Microsoft.AspNetCore.Razor.Tools
foreach (var result in results)
{
var errorCount = result.CSharpDocument.Diagnostics.Count;
- if (errorCount > 0)
+ for (var i = 0; i < errorCount; i++)
{
- success = false;
-
- for (var i = 0; i < errorCount; i++)
+ var error = result.CSharpDocument.Diagnostics[i];
+ if (error.Severity == RazorDiagnosticSeverity.Error)
+ {
+ success = false;
+ }
+
+ if (i < 100)
{
- var error = result.CSharpDocument.Diagnostics[i];
Error.WriteLine(error.ToString());
// Only show the first 100 errors to prevent massive string allocations.
if (i == 99)
{
- Error.WriteLine($"And {errorCount - i + 1} more errors.");
- break;
+ Error.WriteLine($"And {errorCount - i + 1} more warnings/errors.");
}
}
}
- else
+
+ if (success)
{
// Only output the file if we generated it without errors.
var outputFilePath = result.InputItem.OutputPath;
diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs b/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs
index 79694479a4..9a660fb1bf 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/DotnetToolTask.cs
@@ -165,6 +165,17 @@ namespace Microsoft.AspNetCore.Razor.Tasks
{
// Server execution succeeded.
Log.LogMessage(StandardOutputLoggingImportance, $"Server execution completed with return code {result}.");
+
+ // There might still be warnings in the error output.
+ if (LogStandardErrorAsError)
+ {
+ LogErrors(completedResponse.ErrorOutput);
+ }
+ else
+ {
+ LogMessages(completedResponse.ErrorOutput, StandardErrorLoggingImportance);
+ }
+
return true;
}
else if (result == 2)
diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
index 8a5d449cc7..2138f539ac 100644
--- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
+++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildWithComponentsIntegrationTest.cs
@@ -45,6 +45,24 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
}
+ [Fact]
+ [InitializeTestProject("ComponentApp")]
+ public async Task Build_Successful_WhenThereAreWarnings()
+ {
+ ReplaceContent("