public function updateProfiles(StyleInterface $io) {
    $discovery = new ExtensionDiscovery($this->appRoot);

    foreach ($discovery->scan('profile') as $profile) {
      $info_file = $profile->getPathname();

      if (! is_writeable($info_file)) {
        $message = $this->t('Cannot write to @path, skipping.', [
          '@path' => $info_file,
        ]);
        $io->warning((string) $message);
        continue;
      }

      $info = file_get_contents($info_file);
      if (empty($info) || ! strstr($info, 'base profile:')) {
        continue;
      }

      $info = Yaml::decode($info);

      // 'base profile' must be an array with at least the 'name' key.
      if (! isset($info['base profile']['name'])) {
        continue;
      }

      // Build the list of excluded extensions and themes.
      $exclude = [];
      if (isset($info['base profile']['excluded_dependencies'])) {
        $exclude = array_merge($exclude, $info['base profile']['excluded_dependencies']);
      }
      if (isset($info['base profile']['excluded_themes'])) {
        $exclude = array_merge($exclude, $info['base profile']['excluded_themes']);
      }

      $info['base profile'] = $info['base profile']['name'];
      if ($exclude) {
        $info['exclude'] = $exclude;
      }

      $success = file_put_contents($info_file, Yaml::encode($info));
      if ($success) {
        $message = $this->t('Updated @profile.', [
          '@profile' => $profile->getName(),
        ]);
        $io->success((string) $message);
      }
      else {
        throw new \RuntimeException('An error occurred writing to ' . $profile->getPathname());
      }
    }
    // Reset the cached profile list.
    $this->profileList->reset();
  }