Unverified Commit f9c118b6 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Exit for missing Windows plugin projects (#51838)

Exit, rather than crash, if a Windows plugin is missing its project.

Fixes #51743
parent 8d8439f8
......@@ -32,10 +32,14 @@ class _PluginProjectInfo {
}) {
name = plugin.name;
final File projectFile = fileSystem.directory(plugin.path).childDirectory('windows').childFile('plugin.vcxproj');
try {
guid = VisualStudioProject(projectFile, fileSystem: fileSystem).guid;
if (guid == null) {
} on FileSystemException {
throwToolExit('Unable to find a plugin.vcxproj for plugin "$name"');
}
if (guid == null) {
throwToolExit('Unable to find a plugin.vcxproj ID for plugin "$name"');
}
}
// The name of the plugin, which is also the name of the symlink folder.
......
......@@ -222,12 +222,14 @@ EndGlobal''');
// Configures and returns a mock plugin with the given name and GUID in the
// project's plugin symlink directory.
Plugin getMockPlugin(String name, String guid) {
Plugin getMockPlugin(String name, String guid, {bool createProject = true}) {
final MockPlugin plugin = MockPlugin();
when(plugin.platforms).thenReturn(<String, PluginPlatform>{project.pluginConfigKey: null});
when(plugin.name).thenReturn(name);
when(plugin.path).thenReturn(project.pluginSymlinkDirectory.childDirectory(name).path);
writeDummyPluginProject(name, guid);
if (createProject) {
writeDummyPluginProject(name, guid);
}
return plugin;
}
......@@ -422,6 +424,16 @@ EndGlobal''');
expect(RegExp(r'^([ \t]+\t|\t[ \t]+)GlobalSection\(\s*$', multiLine: true).hasMatch(newSolutionContents), false);
expect(RegExp(r'^([ \t]+\t|\t[ \t]+)EndGlobalSection\s*$', multiLine: true).hasMatch(newSolutionContents), false);
});
test('A plugin without a project exits without crashing', () async {
writeSolutionWithoutPlugins();
final List<Plugin> plugins = <Plugin>[
getMockPlugin('plugin_a', pluginAGuid, createProject: false),
];
expect(() => VisualStudioSolutionUtils(project: project, fileSystem: fs).updatePlugins(plugins),
throwsToolExit());
});
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment