publish method
Future<void>
publish(
)
override
Implementation
@override
Future<void> publish() async {
final packages =
this.packages.isNotEmpty ? this.packages : await _findPackages();
for (final package in packages) {
if (!await File(package).exists()) {
throw ArgumentError('MSIX package not found: $package');
}
}
final stage = flutterPublish.stage;
if (flightId == null && stage != null && stage != PublishStage.production) {
_logger.warning('Stage "${stage.name}" is ignored, '
'as no flight id is provided. Publish to the public.');
}
try {
await runProcess('msstore', ['--version'], runInShell: true);
} catch (_) {
throw Exception(
'The Microsoft Store Developer CLI (msstore) is not installed, '
'see https://apps.microsoft.com/detail/9p53pc5s0phj');
}
_logger.info('Configure Microsoft Store credentials...');
await runProcess(
'msstore',
[
'reconfigure',
'--tenantId',
tenantId,
'--sellerId',
sellerId,
'--clientId',
clientId,
'--clientSecret',
clientSecret,
],
runInShell: true,
);
// Check the credentials and the product id.
await runProcess('msstore', ['apps', 'get', productId], runInShell: true);
await _checkArchitectures(packages);
Directory? bundleDir;
try {
var packagePath = packages.first;
if (packages.length > 1) {
bundleDir = await Directory.systemTemp.createTemp('flutter_release');
// Remove the architecture suffix of the package name.
final archNames = CpuArchitecture.values.map((a) => a.name).join('|');
final bundleName = path
.basenameWithoutExtension(packages.first)
.replaceFirst(RegExp('-($archNames)\$'), '');
packagePath = await _bundle(
packages: packages,
bundleDir: bundleDir,
outputPath:
path.join(path.dirname(packages.first), '$bundleName.msixbundle'),
);
_logger.info('Bundle artifact path: $packagePath');
}
if (flutterPublish.isDryRun) {
_logger
.info('Did NOT publish: Remove `--dry-run` flag for publishing.');
return;
}
_logger.info('Upload...');
// Always keep the submission as draft first, to remove the previous packages.
await runAsyncProcess(
'msstore',
[
'publish',
path.absolute(packagePath),
'--appId',
productId,
if (flightId != null) ...['--flightId', flightId!],
if (packageRolloutPercentage != null) ...[
'--packageRolloutPercentage',
packageRolloutPercentage.toString(),
],
'--noCommit',
],
printCall: true,
runInShell: true,
);
await _removePreviousPackages(path.basename(packagePath));
if (releaseStatus == WindowsReleaseStatus.completed) {
_logger.info('Submit for certification...');
await runAsyncProcess(
'msstore',
[..._submissionCommand, 'publish', ..._submissionIds],
printCall: true,
);
}
} finally {
await bundleDir?.delete(recursive: true);
}
}