diff --git a/packages/flutter_tools/lib/src/windows/build_windows.dart b/packages/flutter_tools/lib/src/windows/build_windows.dart index 7ffb4a69d7..c63b1dc3bc 100644 --- a/packages/flutter_tools/lib/src/windows/build_windows.dart +++ b/packages/flutter_tools/lib/src/windows/build_windows.dart @@ -190,7 +190,16 @@ Future _runBuild( // MSBuild sends all output to stdout, including build errors. This surfaces // known error patterns. - final RegExp errorMatcher = RegExp(r':\s*(?:warning|(?:fatal )?error).*?:'); + final RegExp errorMatcher = RegExp( + [ + // Known error messages + r'(:\s*(?:warning|(?:fatal )?error).*?:)', + r'Error detected in pubspec\.yaml:', + + // Known secondary error lines for pubspec.yaml + r'No file or variants found for asset:', + ].join('|'), + ); int result; try { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart index 921b14ecfa..4dbed14f96 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart @@ -962,6 +962,41 @@ if %errorlevel% neq 0 goto :VCEnd ProcessManager: () => FakeProcessManager.any(), FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), }); + + // Tests the case where stdout contains the error about pubspec.yaml + // And tests the case where stdout contains the error about missing assets + testUsingContext('Windows build extracts errors related to pubspec.yaml from stdout', () async { + final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(); + final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test()) + ..visualStudioOverride = fakeVisualStudio; + setUpMockProjectFilesForBuild(); + + const String stdout = r''' +Error detected in pubspec.yaml: +No file or variants found for asset: images/a_dot_burr.jpeg. +'''; + + processManager = FakeProcessManager.list([ + cmakeGenerationCommand(), + buildCommand('Release', + stdout: stdout, + ), + ]); + + await createTestCommandRunner(command).run( + const ['windows', '--no-pub'] + ); + // Just the warnings and errors should be surfaced. + expect(testLogger.errorText, r''' +Error detected in pubspec.yaml: +No file or variants found for asset: images/a_dot_burr.jpeg. +'''); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Platform: () => windowsPlatform, + FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), + }); } class FakeVisualStudio extends Fake implements VisualStudio {