Skip to content

Commit 22673cb

Browse files
author
Fatme
authored
Merge pull request #4326 from NativeScript/fatme/fix-build-path
fix: use correct build output path when building for device
2 parents e9d98ee + 280d7be commit 22673cb

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

lib/definitions/platform.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
103103
* When finishes, saves .nsbuildinfo in application root folder to indicate the prepare that was used to build the app.
104104
* * .nsbuildinfo is not persisted when building for release.
105105
* @param {Mobile.IDevice} device The device where the application should be installed.
106-
* @param {IRelease} options Whether the application was built in release configuration.
106+
* @param {IBuildConfig} options The build configuration.
107107
* @param {string} @optional pathToBuiltApp Path to build artifact.
108108
* @param {string} @optional outputPath Directory containing build information and artifacts.
109109
* @param {IProjectData} projectData DTO with information about the project.
110110
* @returns {void}
111111
*/
112-
installApplication(device: Mobile.IDevice, options: IRelease, projectData: IProjectData, pathToBuiltApp?: string, outputPath?: string): Promise<void>;
112+
installApplication(device: Mobile.IDevice, options: IBuildConfig, projectData: IProjectData, pathToBuiltApp?: string, outputPath?: string): Promise<void>;
113113

114114
/**
115115
* Gets first chance to validate the options provided as command line arguments.

lib/services/livesync/livesync-service.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
267267

268268
// Of the properties below only `buildForDevice` and `release` are currently used.
269269
// Leaving the others with placeholder values so that they may not be forgotten in future implementations.
270-
const buildConfig: IBuildConfig = {
271-
buildForDevice: !settings.isEmulator,
272-
release: false,
273-
device: settings.deviceIdentifier,
274-
provision: null,
275-
teamId: null,
276-
projectDir: settings.projectDir
277-
};
270+
const buildConfig = this.getInstallApplicationBuildConfig(settings.deviceIdentifier, settings.projectDir, { isEmulator: settings.isEmulator });
278271
debugData.pathToAppPackage = this.$platformService.lastOutputPath(settings.platform, buildConfig, projectData, settings.outputPath);
279272
const debugInfo = await this.$debugService.debug(debugData, settings.debugOptions);
280273
const result = this.printDebugInformation(debugInfo, settings.debugOptions.forceDebuggerAttachedEvent);
@@ -489,7 +482,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
489482
await this.$platformService.validateInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
490483
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
491484
if (shouldInstall) {
492-
await this.$platformService.installApplication(options.device, { release: false }, options.projectData, pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
485+
const buildConfig = this.getInstallApplicationBuildConfig(options.device.deviceInfo.identifier, options.projectData.projectDir, { isEmulator: options.device.isEmulator });
486+
await this.$platformService.installApplication(options.device, buildConfig, options.projectData, pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
493487
appInstalledOnDeviceResult.appInstalled = true;
494488
}
495489

@@ -502,7 +496,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
502496
if (rebuildInfo) {
503497
// Case where we have three devices attached, a change that requires build is found,
504498
// we'll rebuild the app only for the first device, but we should install new package on all three devices.
505-
await this.$platformService.installApplication(options.device, { release: false }, options.projectData, rebuildInfo.pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
499+
const buildConfig = this.getInstallApplicationBuildConfig(options.device.deviceInfo.identifier, options.projectData.projectDir, { isEmulator: options.device.isEmulator });
500+
await this.$platformService.installApplication(options.device, buildConfig, options.projectData, rebuildInfo.pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
506501
return rebuildInfo.pathToBuildItem;
507502
}
508503

@@ -875,6 +870,19 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
875870
}
876871
}
877872

873+
private getInstallApplicationBuildConfig(deviceIdentifier: string, projectDir: string, opts: { isEmulator: boolean }): IBuildConfig {
874+
const buildConfig: IBuildConfig = {
875+
buildForDevice: !opts.isEmulator,
876+
release: false,
877+
device: deviceIdentifier,
878+
provision: null,
879+
teamId: null,
880+
projectDir
881+
};
882+
883+
return buildConfig;
884+
}
885+
878886
public emitLivesyncEvent(event: string, livesyncData: ILiveSyncEventData): boolean {
879887
this.$logger.trace(`Will emit event ${event} with data`, livesyncData);
880888
return this.emit(event, livesyncData);

0 commit comments

Comments
 (0)