[flutter_tools] remove UWP tooling (#102174)
This commit is contained in:
@@ -71,14 +71,3 @@ class BuildableWindowsApp extends WindowsApp {
|
||||
@override
|
||||
String get name => project.parent.manifest.appName;
|
||||
}
|
||||
|
||||
class BuildableUwpApp extends ApplicationPackage {
|
||||
BuildableUwpApp({required this.project}) : super(id: project.packageGuid ?? 'com.example.placeholder');
|
||||
|
||||
final WindowsUwpProject project;
|
||||
|
||||
String? get projectVersion => project.packageVersion;
|
||||
|
||||
@override
|
||||
String? get name => getCmakeExecutableName(project);
|
||||
}
|
||||
|
||||
@@ -17,12 +17,8 @@ import '../convert.dart';
|
||||
import '../flutter_plugins.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../migrations/cmake_custom_command_migration.dart';
|
||||
import 'install_manifest.dart';
|
||||
import 'visual_studio.dart';
|
||||
|
||||
/// Update the string when non-backwards compatible changes are made to the UWP template.
|
||||
const int kCurrentUwpTemplateVersion = 0;
|
||||
|
||||
/// Builds the Windows project using msbuild.
|
||||
Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
|
||||
String? target,
|
||||
@@ -116,132 +112,6 @@ Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the Windows UWP project.
|
||||
///
|
||||
/// Note that this feature is currently unfinished.
|
||||
Future<void> buildWindowsUwp(WindowsUwpProject windowsProject, BuildInfo buildInfo, {
|
||||
String? target,
|
||||
VisualStudio? visualStudioOverride,
|
||||
}) async {
|
||||
final Directory buildDirectory = globals.fs.directory(getWindowsBuildUwpDirectory());
|
||||
if (!windowsProject.existsSync()) {
|
||||
throwToolExit(
|
||||
'No Windows UWP desktop project configured. See '
|
||||
'https://docs.flutter.dev/desktop#add-desktop-support-to-an-existing-flutter-app '
|
||||
'to learn about adding Windows support to a project.',
|
||||
);
|
||||
}
|
||||
if (windowsProject.projectVersion != kCurrentUwpTemplateVersion) {
|
||||
throwToolExit(
|
||||
'The Windows UWP project template and build process has changed. In order to build '
|
||||
'you must delete the winuwp directory and re-create the project.',
|
||||
);
|
||||
}
|
||||
// Ensure that necessary ephemeral files are generated and up to date.
|
||||
_writeGeneratedFlutterConfig(windowsProject, buildInfo, target);
|
||||
createPluginSymlinks(windowsProject.parent);
|
||||
await createManifest(
|
||||
buildDirectory: buildDirectory,
|
||||
logger: globals.logger,
|
||||
platform: globals.platform,
|
||||
project: windowsProject,
|
||||
buildInfo: buildInfo,
|
||||
fileSystem: globals.fs,
|
||||
);
|
||||
|
||||
final VisualStudio visualStudio = visualStudioOverride ?? VisualStudio(
|
||||
fileSystem: globals.fs,
|
||||
platform: globals.platform,
|
||||
logger: globals.logger,
|
||||
processManager: globals.processManager,
|
||||
);
|
||||
final String? cmakePath = visualStudio.cmakePath;
|
||||
final String? cmakeGenerator = visualStudio.cmakeGenerator;
|
||||
if (cmakePath == null || cmakeGenerator == null) {
|
||||
throwToolExit('Unable to find suitable Visual Studio toolchain. '
|
||||
'Please run `flutter doctor` for more details.');
|
||||
}
|
||||
|
||||
final String buildModeName = getNameForBuildMode(buildInfo.mode);
|
||||
final Status status = globals.logger.startProgress(
|
||||
'Building Windows UWP application...',
|
||||
);
|
||||
try {
|
||||
// The Cmake re-entrant build does not work for UWP, so the flutter build is
|
||||
// run in advance.
|
||||
await _runFlutterBuild(buildDirectory, buildInfo, target);
|
||||
await _runCmakeGeneration(
|
||||
cmakePath: cmakePath,
|
||||
generator: cmakeGenerator,
|
||||
buildDir: buildDirectory,
|
||||
sourceDir: windowsProject.cmakeFile.parent,
|
||||
);
|
||||
await _runBuild(cmakePath, buildDirectory, buildModeName, install: false);
|
||||
} finally {
|
||||
status.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
const Map<BuildMode, String> _targets = <BuildMode, String>{
|
||||
BuildMode.debug: 'debug_bundle_windows_assets_uwp',
|
||||
BuildMode.profile: 'profile_bundle_windows_assets_uwp',
|
||||
BuildMode.release: 'release_bundle_windows_assets_uwp',
|
||||
};
|
||||
|
||||
Future<void> _runFlutterBuild(Directory buildDirectory, BuildInfo buildInfo, String? targetFile) async {
|
||||
await buildDirectory.create(recursive: true);
|
||||
int result;
|
||||
String? flutterEngine;
|
||||
String? localEngine;
|
||||
final Artifacts artifacts = globals.artifacts!;
|
||||
if (artifacts is LocalEngineArtifacts) {
|
||||
final String engineOutPath = artifacts.engineOutPath;
|
||||
flutterEngine = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
|
||||
localEngine = globals.fs.path.basename(engineOutPath);
|
||||
}
|
||||
try {
|
||||
final String? buildMode = _targets[buildInfo.mode];
|
||||
result = await globals.processUtils.stream(
|
||||
<String>[
|
||||
globals.fs.path.join(Cache.flutterRoot!, 'bin', 'flutter'),
|
||||
if (globals.logger.isVerbose)
|
||||
'--verbose',
|
||||
if (flutterEngine != null) '--local-engine-src-path=$flutterEngine',
|
||||
if (localEngine != null) '--local-engine=$localEngine',
|
||||
'assemble',
|
||||
'--no-version-check',
|
||||
'--output=build',
|
||||
'-dTargetPlatform=windows-uwp-x64',
|
||||
'-dTrackWidgetCreation=${buildInfo.trackWidgetCreation}',
|
||||
'-dBuildMode=${getNameForBuildMode(buildInfo.mode)}',
|
||||
'-dTargetFile=$targetFile',
|
||||
'-dTreeShakeIcons="${buildInfo.treeShakeIcons}"',
|
||||
'-dDartObfuscation=${buildInfo.dartObfuscation}',
|
||||
if (buildInfo.bundleSkSLPath != null)
|
||||
'-dBundleSkSLPath=${buildInfo.bundleSkSLPath}',
|
||||
if (buildInfo.codeSizeDirectory != null)
|
||||
'-dCodeSizeDirectory=${buildInfo.codeSizeDirectory}',
|
||||
if (buildInfo.splitDebugInfoPath != null)
|
||||
'-dSplitDebugInfo=${buildInfo.splitDebugInfoPath}',
|
||||
if (buildInfo.dartDefines != null && buildInfo.dartDefines.isNotEmpty)
|
||||
'--DartDefines=${encodeDartDefines(buildInfo.dartDefines)}',
|
||||
if (buildInfo.extraGenSnapshotOptions != null && buildInfo.extraGenSnapshotOptions.isNotEmpty)
|
||||
'--ExtraGenSnapshotOptions=${buildInfo.extraGenSnapshotOptions}',
|
||||
if (buildInfo.extraFrontEndOptions != null && buildInfo.extraFrontEndOptions.isNotEmpty)
|
||||
'--ExtraFrontEndOptions=${buildInfo.extraFrontEndOptions}',
|
||||
if (buildMode != null)
|
||||
buildMode,
|
||||
],
|
||||
trace: true,
|
||||
);
|
||||
} on ArgumentError {
|
||||
throwToolExit("cmake not found. Run 'flutter doctor' for more information.");
|
||||
}
|
||||
if (result != 0) {
|
||||
throwToolExit('Unable to generate build files');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _runCmakeGeneration({
|
||||
required String cmakePath,
|
||||
required String generator,
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../asset.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cmake_project.dart';
|
||||
|
||||
/// Generate an install manifest that is required for CMAKE on UWP projects.
|
||||
Future<void> createManifest({
|
||||
required Logger logger,
|
||||
required FileSystem fileSystem,
|
||||
required Platform platform,
|
||||
required WindowsUwpProject project,
|
||||
required BuildInfo buildInfo,
|
||||
required Directory buildDirectory,
|
||||
}) async {
|
||||
final List<File> outputs = <File>[];
|
||||
final AssetBundle assetBundle = AssetBundleFactory.defaultInstance(
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
platform: platform,
|
||||
).createBundle();
|
||||
final int resultCode = await assetBundle.build(
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
assetDirPath: buildDirectory.childDirectory('flutter_assets').path,
|
||||
);
|
||||
if (resultCode != 0) {
|
||||
throwToolExit('Failed to build assets.');
|
||||
}
|
||||
|
||||
if (buildInfo.mode.isPrecompiled) {
|
||||
outputs.add(buildDirectory.childFile('app.so'));
|
||||
} else {
|
||||
outputs.add(buildDirectory.parent.childDirectory('flutter_assets').childFile('kernel_blob.bin'));
|
||||
}
|
||||
for (final String key in assetBundle.entries.keys) {
|
||||
outputs.add(buildDirectory.parent.childDirectory('flutter_assets').childFile(key));
|
||||
}
|
||||
outputs.add(project.ephemeralDirectory.childFile('flutter_windows_winuwp.dll'));
|
||||
outputs.add(project.ephemeralDirectory.childFile('flutter_windows_winuwp.dll.pdb'));
|
||||
outputs.add(project.ephemeralDirectory.childFile('icudtl.dat'));
|
||||
project.ephemeralDirectory.childFile('install_manifest')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(outputs.map((File file) => file.absolute.uri.path.substring(1)).join('\n'));
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
/// The uwptool command-line tool.
|
||||
///
|
||||
/// `uwptool` is a host utility command-line tool that supports a variety of
|
||||
/// actions related to Universal Windows Platform (UWP) applications, including
|
||||
/// installing and uninstalling apps, querying installed apps, and launching
|
||||
/// apps.
|
||||
class UwpTool {
|
||||
UwpTool({
|
||||
required Artifacts artifacts,
|
||||
required Logger logger,
|
||||
required ProcessManager processManager,
|
||||
}) : _artifacts = artifacts,
|
||||
_logger = logger,
|
||||
_processUtils = ProcessUtils(processManager: processManager, logger: logger);
|
||||
|
||||
final Artifacts _artifacts;
|
||||
final Logger _logger;
|
||||
final ProcessUtils _processUtils;
|
||||
|
||||
String get _binaryPath => _artifacts.getArtifactPath(Artifact.uwptool);
|
||||
|
||||
Future<List<String>> listApps() async {
|
||||
final List<String> launchCommand = <String>[
|
||||
_binaryPath,
|
||||
'listapps',
|
||||
];
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printError('Failed to list installed UWP apps: ${result.stderr}');
|
||||
return <String>[];
|
||||
}
|
||||
final List<String> packageFamilies = <String>[];
|
||||
for (final String line in result.stdout.split('\n')) {
|
||||
final String packageFamily = line.trim();
|
||||
if (packageFamily.isNotEmpty) {
|
||||
packageFamilies.add(packageFamily);
|
||||
}
|
||||
}
|
||||
return packageFamilies;
|
||||
}
|
||||
|
||||
/// Returns the package family name for the specified package name.
|
||||
///
|
||||
/// If no installed application on the system matches the specified package
|
||||
/// name, returns null.
|
||||
Future<String?> getPackageFamilyName(String packageName) async {
|
||||
for (final String packageFamily in await listApps()) {
|
||||
if (packageFamily.startsWith(packageName)) {
|
||||
return packageFamily;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Launches the app with the specified package family name.
|
||||
///
|
||||
/// On success, returns the process ID of the launched app, otherwise null.
|
||||
Future<int?> launchApp(String packageFamily, List<String> args) async {
|
||||
final List<String> launchCommand = <String>[
|
||||
_binaryPath,
|
||||
'launch',
|
||||
packageFamily
|
||||
] + args;
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printError('Failed to launch app $packageFamily: ${result.stderr}');
|
||||
return null;
|
||||
}
|
||||
// Read the process ID from stdout.
|
||||
final int? processId = int.tryParse(result.stdout.trim());
|
||||
_logger.printTrace('Launched application $packageFamily with process ID $processId');
|
||||
return processId;
|
||||
}
|
||||
|
||||
/// Returns `true` if the specified package signature is valid.
|
||||
Future<bool> isSignatureValid(String packagePath) async {
|
||||
final List<String> launchCommand = <String>[
|
||||
'powershell.exe',
|
||||
'-command',
|
||||
'if ((Get-AuthenticodeSignature "$packagePath").Status -eq "Valid") { exit 0 } else { exit 1 }'
|
||||
];
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printTrace('Invalid signature found for $packagePath');
|
||||
return false;
|
||||
}
|
||||
_logger.printTrace('Valid signature found for $packagePath');
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Installs a developer signing certificate.
|
||||
///
|
||||
/// Returns `true` on success.
|
||||
Future<bool> installCertificate(String certificatePath) async {
|
||||
final List<String> launchCommand = <String>[
|
||||
'powershell.exe',
|
||||
'start',
|
||||
'certutil',
|
||||
'-argumentlist',
|
||||
'\'-addstore TrustedPeople "$certificatePath"\'',
|
||||
'-verb',
|
||||
'runas'
|
||||
];
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printError('Failed to install certificate $certificatePath');
|
||||
return false;
|
||||
}
|
||||
_logger.printTrace('Waiting for certificate store update');
|
||||
// TODO(cbracken): Determine how we can query for success until some timeout.
|
||||
// https://github.com/flutter/flutter/issues/82665
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
_logger.printTrace('Installed certificate $certificatePath');
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Installs the app with the specified build directory.
|
||||
///
|
||||
/// Returns `true` on success.
|
||||
Future<bool> installApp(String packageUri, List<String> dependencyUris) async {
|
||||
final List<String> launchCommand = <String>[
|
||||
_binaryPath,
|
||||
'install',
|
||||
packageUri,
|
||||
] + dependencyUris;
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printError('Failed to install $packageUri');
|
||||
return false;
|
||||
}
|
||||
_logger.printTrace('Installed application $packageUri');
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> uninstallApp(String packageFamily) async {
|
||||
final List<String> launchCommand = <String>[
|
||||
_binaryPath,
|
||||
'uninstall',
|
||||
packageFamily
|
||||
];
|
||||
final RunResult result = await _processUtils.run(launchCommand);
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printError('Failed to uninstall $packageFamily');
|
||||
return false;
|
||||
}
|
||||
_logger.printTrace('Uninstalled application $packageFamily');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,15 @@ import 'dart:async';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../desktop_device.dart';
|
||||
import '../device.dart';
|
||||
import '../device_port_forwarder.dart';
|
||||
import '../features.dart';
|
||||
import '../project.dart';
|
||||
import 'application_package.dart';
|
||||
import 'build_windows.dart';
|
||||
import 'uwptool.dart';
|
||||
import 'windows_workflow.dart';
|
||||
|
||||
/// A device that represents a desktop Windows target.
|
||||
@@ -72,332 +67,6 @@ class WindowsDevice extends DesktopDevice {
|
||||
}
|
||||
}
|
||||
|
||||
// A device that represents a desktop Windows UWP target.
|
||||
class WindowsUWPDevice extends Device {
|
||||
WindowsUWPDevice({
|
||||
required ProcessManager processManager,
|
||||
required Logger logger,
|
||||
required FileSystem fileSystem,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
required UwpTool uwptool,
|
||||
}) : _logger = logger,
|
||||
_processManager = processManager,
|
||||
_operatingSystemUtils = operatingSystemUtils,
|
||||
_fileSystem = fileSystem,
|
||||
_uwptool = uwptool,
|
||||
super(
|
||||
'winuwp',
|
||||
platformType: PlatformType.windows,
|
||||
ephemeral: false,
|
||||
category: Category.desktop,
|
||||
);
|
||||
|
||||
final ProcessManager _processManager;
|
||||
final Logger _logger;
|
||||
final FileSystem _fileSystem;
|
||||
final OperatingSystemUtils _operatingSystemUtils;
|
||||
final UwpTool _uwptool;
|
||||
BuildMode? _buildMode;
|
||||
|
||||
int? _processId;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
|
||||
@override
|
||||
String get name => 'Windows (UWP)';
|
||||
|
||||
@override
|
||||
Future<TargetPlatform> get targetPlatform async => TargetPlatform.windows_uwp_x64;
|
||||
|
||||
@override
|
||||
bool isSupportedForProject(FlutterProject flutterProject) {
|
||||
return flutterProject.windowsUwp.existsSync();
|
||||
}
|
||||
|
||||
@override
|
||||
void clearLogs() { }
|
||||
|
||||
@override
|
||||
Future<void> dispose() async { }
|
||||
|
||||
@override
|
||||
Future<String?> get emulatorId async => null;
|
||||
|
||||
@override
|
||||
FutureOr<DeviceLogReader> getLogReader({covariant BuildableUwpApp? app, bool includePastLogs = false}) {
|
||||
return NoOpDeviceLogReader('winuwp');
|
||||
}
|
||||
|
||||
// Returns `true` if the specified file is a valid package based on file extension.
|
||||
bool _isValidPackage(String packagePath) {
|
||||
const List<String> validPackageExtensions = <String>[
|
||||
'.appx', '.msix', // Architecture-specific application.
|
||||
'.appxbundle', '.msixbundle', // Architecture-independent application.
|
||||
'.eappx', '.emsix', // Encrypted architecture-specific application.
|
||||
'.eappxbundle', '.emsixbundle', // Encrypted architecture-independent application.
|
||||
];
|
||||
return validPackageExtensions.any(packagePath.endsWith);
|
||||
}
|
||||
|
||||
// Walks the build directory for any dependent packages for the specified architecture.
|
||||
List<String> _getPackagePaths(String directory) {
|
||||
if (!_fileSystem.isDirectorySync(directory)) {
|
||||
return <String>[];
|
||||
}
|
||||
final List<String> packagePaths = <String>[];
|
||||
for (final FileSystemEntity entity in _fileSystem.directory(directory).listSync()) {
|
||||
if (entity.statSync().type != FileSystemEntityType.file) {
|
||||
continue;
|
||||
}
|
||||
final String packagePath = entity.absolute.path;
|
||||
if (_isValidPackage(packagePath)) {
|
||||
packagePaths.add(packagePath);
|
||||
}
|
||||
}
|
||||
return packagePaths;
|
||||
}
|
||||
|
||||
// Walks the build directory for any dependent packages for the specified architecture.
|
||||
String? _getAppPackagePath(String buildDirectory) {
|
||||
final List<String> packagePaths = _getPackagePaths(buildDirectory);
|
||||
return packagePaths.isNotEmpty ? packagePaths.first : null;
|
||||
}
|
||||
|
||||
// Walks the build directory for any dependent packages for the specified architecture.
|
||||
List<String> _getDependencyPaths(String buildDirectory, String architecture) {
|
||||
final String depsDirectory = _fileSystem.path.join(buildDirectory, 'Dependencies', architecture);
|
||||
return _getPackagePaths(depsDirectory);
|
||||
}
|
||||
|
||||
String _getPackageName(String binaryName, String version, String config, {String? architecture}) {
|
||||
final List<String> components = <String>[
|
||||
binaryName,
|
||||
version,
|
||||
if (architecture != null) architecture,
|
||||
config,
|
||||
];
|
||||
return components.join('_');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> installApp(covariant BuildableUwpApp app, {String? userIdentifier}) async {
|
||||
/// The cmake build generates an install powershell script.
|
||||
/// build\winuwp\runner_uwp\AppPackages\<app-name>\<app-name>_<app-version>_<cmake-config>\Add-AppDevPackage.ps1
|
||||
final String? binaryName = app.name;
|
||||
final String? packageVersion = app.projectVersion;
|
||||
if (binaryName == null || packageVersion == null) {
|
||||
return false;
|
||||
}
|
||||
final String binaryDir = _fileSystem.path.absolute(
|
||||
_fileSystem.path.join('build', 'winuwp', 'runner_uwp', 'AppPackages', binaryName));
|
||||
final String config = sentenceCase(getNameForBuildMode(_buildMode ?? BuildMode.debug));
|
||||
|
||||
// If a multi-architecture package exists, install that; otherwise install
|
||||
// the single-architecture package.
|
||||
final List<String> packageNames = <String>[
|
||||
// Multi-archtitecture package.
|
||||
_getPackageName(binaryName, packageVersion, config),
|
||||
// Single-archtitecture package.
|
||||
_getPackageName(binaryName, packageVersion, config, architecture: 'x64'),
|
||||
];
|
||||
String? packageName;
|
||||
String? buildDirectory;
|
||||
String? packagePath;
|
||||
for (final String name in packageNames) {
|
||||
packageName = name;
|
||||
buildDirectory = _fileSystem.path.join(binaryDir, '${packageName}_Test');
|
||||
if (_fileSystem.isDirectorySync(buildDirectory)) {
|
||||
packagePath = _getAppPackagePath(buildDirectory);
|
||||
if (packagePath != null && _fileSystem.isFileSync(packagePath)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (packagePath == null) {
|
||||
_logger.printError('Failed to locate app package to install');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify package signature.
|
||||
if (!await _uwptool.isSignatureValid(packagePath)) {
|
||||
// If signature is invalid, install the developer certificate.
|
||||
final String certificatePath = _fileSystem.path.join(buildDirectory!, '$packageName.cer');
|
||||
if (_logger.terminal.stdinHasTerminal) {
|
||||
final String response = await _logger.terminal.promptForCharInput(
|
||||
<String>['Y', 'y', 'N', 'n'],
|
||||
logger: _logger,
|
||||
prompt: 'Install developer certificate.\n'
|
||||
'\n'
|
||||
'Windows UWP apps are signed with a developer certificate during the build\n'
|
||||
'process. On the first install of an app with a signature from a new\n'
|
||||
'certificate, the certificate must be installed.\n'
|
||||
'\n'
|
||||
'If desired, this certificate can later be removed by launching the \n'
|
||||
'"Manage Computer Certificates" control panel from the Start menu and deleting\n'
|
||||
'the "CMake Test Cert" certificate from the "Trusted People" > "Certificates"\n'
|
||||
'section.\n'
|
||||
'\n'
|
||||
'Press "Y" to continue, or "N" to cancel.',
|
||||
displayAcceptedCharacters: false,
|
||||
);
|
||||
if (response == 'N' || response == 'n') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
await _uwptool.installCertificate(certificatePath);
|
||||
}
|
||||
|
||||
// Install the application and dependencies.
|
||||
final String packageUri = Uri.file(packagePath).toString();
|
||||
final List<String> dependencyUris = _getDependencyPaths(buildDirectory!, 'x64')
|
||||
.map((String path) => Uri.file(path).toString())
|
||||
.toList();
|
||||
return _uwptool.installApp(packageUri, dependencyUris);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async {
|
||||
final String packageName = app.id;
|
||||
return await _uwptool.getPackageFamilyName(packageName) != null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) async => false;
|
||||
|
||||
@override
|
||||
Future<bool> get isLocalEmulator async => false;
|
||||
|
||||
@override
|
||||
DevicePortForwarder get portForwarder => const NoOpDevicePortForwarder();
|
||||
|
||||
@override
|
||||
Future<String> get sdkNameAndVersion async => '';
|
||||
|
||||
@override
|
||||
Future<LaunchResult> startApp(covariant BuildableUwpApp package, {
|
||||
String? mainPath,
|
||||
String? route,
|
||||
required DebuggingOptions debuggingOptions,
|
||||
Map<String, Object?> platformArgs = const <String, Object>{},
|
||||
bool prebuiltApplication = false,
|
||||
bool ipv6 = false,
|
||||
String? userIdentifier,
|
||||
}) async {
|
||||
_buildMode = debuggingOptions.buildInfo.mode;
|
||||
if (!prebuiltApplication) {
|
||||
await buildWindowsUwp(
|
||||
package.project,
|
||||
debuggingOptions.buildInfo,
|
||||
target: mainPath,
|
||||
);
|
||||
}
|
||||
if (await isAppInstalled(package) && !await uninstallApp(package)) {
|
||||
_logger.printError('Failed to uninstall previous app package');
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
if (!await installApp(package)) {
|
||||
_logger.printError('Failed to install app package');
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
|
||||
final String packageName = package.id;
|
||||
if (packageName == null) {
|
||||
_logger.printError('Could not find PACKAGE_GUID in ${package.project.runnerCmakeFile.path}');
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
|
||||
final String? packageFamily = await _uwptool.getPackageFamilyName(packageName);
|
||||
if (packageFamily == null) {
|
||||
_logger.printError('Could not find package family name from $packageName');
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
|
||||
if (debuggingOptions.buildInfo.mode.isRelease) {
|
||||
_processId = await _uwptool.launchApp(packageFamily, <String>[]);
|
||||
return _processId != null ? LaunchResult.succeeded() : LaunchResult.failed();
|
||||
}
|
||||
|
||||
/// If the terminal is attached, prompt the user to open the firewall port.
|
||||
if (_logger.terminal.stdinHasTerminal) {
|
||||
final String response = await _logger.terminal.promptForCharInput(
|
||||
<String>['Y', 'y', 'N', 'n'],
|
||||
logger: _logger,
|
||||
prompt: 'Enable Flutter debugging from localhost.\n'
|
||||
'\n'
|
||||
'Windows UWP apps run in a sandboxed environment. To enable Flutter debugging\n'
|
||||
'and hot reload, you will need to enable inbound connections to the app from the\n'
|
||||
'Flutter tool running on your machine. To do so:\n'
|
||||
' 1. Launch PowerShell as an Administrator\n'
|
||||
' 2. Enter the following command:\n'
|
||||
' checknetisolation loopbackexempt -is -n=$packageFamily\n'
|
||||
'\n'
|
||||
'Press "Y" once this is complete, or "N" to abort.',
|
||||
displayAcceptedCharacters: false,
|
||||
);
|
||||
if (response == 'N' || response == 'n') {
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/// Currently we do not have a way to discover the VM Service URI.
|
||||
final int port = debuggingOptions.deviceVmServicePort ?? await _operatingSystemUtils.findFreePort();
|
||||
final List<String> args = <String>[
|
||||
'--observatory-port=$port',
|
||||
'--disable-service-auth-codes',
|
||||
'--enable-dart-profiling',
|
||||
if (debuggingOptions.startPaused) '--start-paused',
|
||||
if (debuggingOptions.useTestFonts) '--use-test-fonts',
|
||||
if (debuggingOptions.debuggingEnabled) ...<String>[
|
||||
'--enable-checked-mode',
|
||||
'--verify-entry-points',
|
||||
],
|
||||
if (debuggingOptions.enableSoftwareRendering) '--enable-software-rendering',
|
||||
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
|
||||
if (debuggingOptions.traceSkia) '--trace-skia',
|
||||
if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"',
|
||||
if (debuggingOptions.traceSkiaAllowlist != null) '--trace-skia-allowlist="${debuggingOptions.traceSkiaAllowlist}"',
|
||||
if (debuggingOptions.endlessTraceBuffer) '--endless-trace-buffer',
|
||||
if (debuggingOptions.dumpSkpOnShaderCompilation) '--dump-skp-on-shader-compilation',
|
||||
if (debuggingOptions.verboseSystemLogs) '--verbose-logging',
|
||||
if (debuggingOptions.cacheSkSL) '--cache-sksl',
|
||||
if (debuggingOptions.purgePersistentCache) '--purge-persistent-cache',
|
||||
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
|
||||
];
|
||||
_processId = await _uwptool.launchApp(packageFamily, args);
|
||||
if (_processId == null) {
|
||||
return LaunchResult.failed();
|
||||
}
|
||||
return LaunchResult.succeeded(observatoryUri: Uri.parse('http://localhost:$port'));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> stopApp(covariant BuildableUwpApp app, {String? userIdentifier}) async {
|
||||
if (_processId != null) {
|
||||
return _processManager.killPid(_processId!);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> uninstallApp(covariant BuildableUwpApp app, {String? userIdentifier}) async {
|
||||
final String packageName = app.id;
|
||||
if (packageName == null) {
|
||||
_logger.printError('Could not find PACKAGE_GUID in ${app.project.runnerCmakeFile.path}');
|
||||
return false;
|
||||
}
|
||||
final String? packageFamily = await _uwptool.getPackageFamilyName(packageName);
|
||||
if (packageFamily == null) {
|
||||
// App is not installed.
|
||||
return true;
|
||||
}
|
||||
return _uwptool.uninstallApp(packageFamily);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<bool> supportsRuntimeMode(BuildMode buildMode) => buildMode != BuildMode.jitRelease;
|
||||
}
|
||||
|
||||
class WindowsDevices extends PollingDeviceDiscovery {
|
||||
WindowsDevices({
|
||||
required ProcessManager processManager,
|
||||
@@ -405,15 +74,11 @@ class WindowsDevices extends PollingDeviceDiscovery {
|
||||
required FileSystem fileSystem,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
required WindowsWorkflow windowsWorkflow,
|
||||
required FeatureFlags featureFlags,
|
||||
required UwpTool uwptool,
|
||||
}) : _fileSystem = fileSystem,
|
||||
_logger = logger,
|
||||
_processManager = processManager,
|
||||
_operatingSystemUtils = operatingSystemUtils,
|
||||
_windowsWorkflow = windowsWorkflow,
|
||||
_featureFlags = featureFlags,
|
||||
_uwptool = uwptool,
|
||||
super('windows devices');
|
||||
|
||||
final FileSystem _fileSystem;
|
||||
@@ -421,8 +86,6 @@ class WindowsDevices extends PollingDeviceDiscovery {
|
||||
final ProcessManager _processManager;
|
||||
final OperatingSystemUtils _operatingSystemUtils;
|
||||
final WindowsWorkflow _windowsWorkflow;
|
||||
final FeatureFlags _featureFlags;
|
||||
final UwpTool _uwptool;
|
||||
|
||||
@override
|
||||
bool get supportsPlatform => _windowsWorkflow.appliesToHostPlatform;
|
||||
@@ -442,14 +105,6 @@ class WindowsDevices extends PollingDeviceDiscovery {
|
||||
processManager: _processManager,
|
||||
operatingSystemUtils: _operatingSystemUtils,
|
||||
),
|
||||
if (_featureFlags.isWindowsUwpEnabled)
|
||||
WindowsUWPDevice(
|
||||
fileSystem: _fileSystem,
|
||||
logger: _logger,
|
||||
processManager: _processManager,
|
||||
operatingSystemUtils: _operatingSystemUtils,
|
||||
uwptool: _uwptool,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -457,5 +112,5 @@ class WindowsDevices extends PollingDeviceDiscovery {
|
||||
Future<List<String>> getDiagnostics() async => const <String>[];
|
||||
|
||||
@override
|
||||
List<String> get wellKnownIds => const <String>['windows', 'winuwp'];
|
||||
List<String> get wellKnownIds => const <String>['windows'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user