buildMsixBundle function

Future<String> buildMsixBundle({
  1. required String repoRoot,
  2. required String version,
  3. required String packageDir,
  4. required String outputPath,
  5. required String workingDirectory,
})

Bundles architecture-specific MSIX packages.

Implementation

Future<String> buildMsixBundle({
  required String repoRoot,
  required String version,
  required String packageDir,
  required String outputPath,
  required String workingDirectory,
}) async {
  final resolvedPackageDir = _resolveRepoPath(repoRoot, packageDir);
  final resolvedOutputPath = _resolveRepoPath(repoRoot, outputPath);
  final bundleInputDir = _resolveRepoPath(repoRoot, workingDirectory);
  final packageNames =
      Directory(resolvedPackageDir)
          .listSync()
          .whereType<File>()
          .map((entry) => p.basename(entry.path))
          .where((name) => name.endsWith('.msix'))
          .toList()
        ..sort();

  if (packageNames.isEmpty) {
    throw ShipworldException('No .msix packages found in $resolvedPackageDir');
  }

  await _removeDirectory(bundleInputDir);
  await Directory(bundleInputDir).create(recursive: true);

  for (final packageName in packageNames) {
    await File(
      p.join(resolvedPackageDir, packageName),
    ).copy(p.join(bundleInputDir, packageName));
  }

  final makeAppxPath = await _findWindowsSdkTool('makeappx');

  await runInherited(makeAppxPath, [
    'bundle',
    '/v',
    '/o',
    '/bv',
    convertVersionToMsixVersion(version),
    '/d',
    bundleInputDir,
    '/p',
    resolvedOutputPath,
  ], workingDirectory: repoRoot);

  return resolvedOutputPath;
}