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)
|
foreach (var result in results)
|
||||||
{
|
{
|
||||||
var errorCount = result.CSharpDocument.Diagnostics.Count;
|
var errorCount = result.CSharpDocument.Diagnostics.Count;
|
||||||
if (errorCount > 0)
|
for (var i = 0; i < errorCount; i++)
|
||||||
{
|
{
|
||||||
success = false;
|
var error = result.CSharpDocument.Diagnostics[i];
|
||||||
|
if (error.Severity == RazorDiagnosticSeverity.Error)
|
||||||
for (var i = 0; i < errorCount; i++)
|
{
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 100)
|
||||||
{
|
{
|
||||||
var error = result.CSharpDocument.Diagnostics[i];
|
|
||||||
Error.WriteLine(error.ToString());
|
Error.WriteLine(error.ToString());
|
||||||
|
|
||||||
// Only show the first 100 errors to prevent massive string allocations.
|
// Only show the first 100 errors to prevent massive string allocations.
|
||||||
if (i == 99)
|
if (i == 99)
|
||||||
{
|
{
|
||||||
Error.WriteLine($"And {errorCount - i + 1} more errors.");
|
Error.WriteLine($"And {errorCount - i + 1} more warnings/errors.");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
// Only output the file if we generated it without errors.
|
// Only output the file if we generated it without errors.
|
||||||
var outputFilePath = result.InputItem.OutputPath;
|
var outputFilePath = result.InputItem.OutputPath;
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,17 @@ namespace Microsoft.AspNetCore.Razor.Tasks
|
||||||
{
|
{
|
||||||
// Server execution succeeded.
|
// Server execution succeeded.
|
||||||
Log.LogMessage(StandardOutputLoggingImportance, $"Server execution completed with return code {result}.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else if (result == 2)
|
else if (result == 2)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,24 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
|
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]
|
[Fact]
|
||||||
[InitializeTestProject("ComponentLibrary")]
|
[InitializeTestProject("ComponentLibrary")]
|
||||||
public async Task Build_WithoutRazorLangVersion_ProducesWarning()
|
public async Task Build_WithoutRazorLangVersion_ProducesWarning()
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
|
|
||||||
Assert.BuildFailed(result);
|
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.
|
// RazorGenerate should compile the assembly, but not the views.
|
||||||
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
|
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue