Don't fail the build on warnings (dotnet/aspnetcore-tooling#922)
* Don't fail the build on warnings
* update
* update
\n\nCommit migrated from 450a780f40
This commit is contained in:
parent
ccf56256d9
commit
6ad8b96f3e
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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("<UnrecognizedComponent />", "Components", "Pages", "Index.razor");
|
||||
var result = await DotnetMSBuild("Build");
|
||||
|
||||
Assert.BuildPassed(result, allowWarnings: true);
|
||||
|
||||
Assert.FileExists(result, OutputPath, "ComponentApp.dll");
|
||||
Assert.FileExists(result, OutputPath, "ComponentApp.pdb");
|
||||
|
||||
// Verify component compilation succeeded
|
||||
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "ComponentApp.dll"), "ComponentApp.Components.Pages.Counter");
|
||||
|
||||
Assert.BuildWarning(result, "RZ10014");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("ComponentLibrary")]
|
||||
public async Task Build_WithoutRazorLangVersion_ProducesWarning()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
|
||||
Assert.BuildFailed(result);
|
||||
|
||||
Assert.BuildOutputContainsLine(result, "And 101 more errors.");
|
||||
Assert.BuildOutputContainsLine(result, "And 101 more warnings/errors.");
|
||||
|
||||
// RazorGenerate should compile the assembly, but not the views.
|
||||
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
<h1>Hello, world!</h1>
|
||||
|
||||
Welcome to your new app.
|
||||
Welcome to your new app.
|
||||
Loading…
Reference in New Issue